aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph/messenger.c
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2014-01-09 13:08:21 -0500
committerIlya Dryomov <ilya.dryomov@inktank.com>2014-01-26 05:34:23 -0500
commiteeb0bed5572b1282009dfc2635604df5a35d1a02 (patch)
tree6b90792affac20b326daa59a59227766f746ee2f /net/ceph/messenger.c
parent80213a84a96c3040f5824bce646a184d5dd3dd2b (diff)
libceph: add ceph_kv{malloc,free}() and switch to them
Encapsulate kmalloc vs vmalloc memory allocation and freeing logic into two helpers, ceph_kvmalloc() and ceph_kvfree(), and switch to them. ceph_kvmalloc() kmalloc()'s a maximum of 8 pages, anything bigger is vmalloc()'ed with __GFP_HIGHMEM set. This changes the existing behaviour: - for buffers (ceph_buffer_new()), from trying to kmalloc() everything and using vmalloc() just as a fallback - for messages (ceph_msg_new()), from going to vmalloc() for anything bigger than a page - for messages (ceph_msg_new()), from disallowing vmalloc() to use high memory Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph/messenger.c')
-rw-r--r--net/ceph/messenger.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 252ad4e01cf8..2ed1304d22a7 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -3131,13 +3131,7 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
3131 3131
3132 /* front */ 3132 /* front */
3133 if (front_len) { 3133 if (front_len) {
3134 if (front_len > PAGE_CACHE_SIZE) { 3134 m->front.iov_base = ceph_kvmalloc(front_len, flags);
3135 m->front.iov_base = __vmalloc(front_len, flags,
3136 PAGE_KERNEL);
3137 m->front_is_vmalloc = true;
3138 } else {
3139 m->front.iov_base = kmalloc(front_len, flags);
3140 }
3141 if (m->front.iov_base == NULL) { 3135 if (m->front.iov_base == NULL) {
3142 dout("ceph_msg_new can't allocate %d bytes\n", 3136 dout("ceph_msg_new can't allocate %d bytes\n",
3143 front_len); 3137 front_len);
@@ -3259,10 +3253,7 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
3259void ceph_msg_kfree(struct ceph_msg *m) 3253void ceph_msg_kfree(struct ceph_msg *m)
3260{ 3254{
3261 dout("msg_kfree %p\n", m); 3255 dout("msg_kfree %p\n", m);
3262 if (m->front_is_vmalloc) 3256 ceph_kvfree(m->front.iov_base);
3263 vfree(m->front.iov_base);
3264 else
3265 kfree(m->front.iov_base);
3266 kmem_cache_free(ceph_msg_cache, m); 3257 kmem_cache_free(ceph_msg_cache, m);
3267} 3258}
3268 3259