From fc93afb3c1636562a5c67c781ea968fa10a13371 Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 29 Nov 2003 04:28:12 +0000 Subject: [PATCH] b=1933 The lib_*_alloc functions in portals were calling kmem_cache_alloc(GFP_NOFS) instead of PORTAL_SLAB_ALLOC, which uses GFP_MEMALLOC. These calls are _more_ likely to return NULL, because they won't use the emergency pool and can't descend into the file system to free memory. Unsurprisingly, these lib functions eventually failed to allocate at NCSA, so this is not just a theoretical risk. --- lnet/include/linux/kp30.h | 2 +- lnet/include/lnet/lib-lnet.h | 12 ++++++++---- lnet/include/lnet/lib-p30.h | 12 ++++++++---- lustre/portals/include/linux/kp30.h | 2 +- lustre/portals/include/portals/lib-p30.h | 12 ++++++++---- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/lnet/include/linux/kp30.h b/lnet/include/linux/kp30.h index 3e6d5e3..65cfa17 100644 --- a/lnet/include/linux/kp30.h +++ b/lnet/include/linux/kp30.h @@ -334,7 +334,7 @@ do { \ portal_kmem_inc((ptr), (size)); \ memset((ptr), 0, (size)); \ } \ - CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %ld at %p (tot %d).\n", \ + CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d).\n", \ (int)(size), (ptr), atomic_read(&portal_kmemory)); \ } while (0) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 55fd720..f11c17a 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -168,7 +168,8 @@ static inline lib_eq_t * lib_eq_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS); + lib_eq_t *eq; + PORTAL_SLAB_ALLOC(eq, ptl_eq_slab, sizeof(*eq)); if (eq == NULL) return (NULL); @@ -189,7 +190,8 @@ static inline lib_md_t * lib_md_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS); + lib_md_t *md; + PORTAL_SLAB_ALLOC(md, ptl_md_slab, sizeof(*md)); if (md == NULL) return (NULL); @@ -210,7 +212,8 @@ static inline lib_me_t * lib_me_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS); + lib_me_t *me; + PORTAL_SLAB_ALLOC(me, ptl_me_slab, sizeof(*me)); if (me == NULL) return (NULL); @@ -231,7 +234,8 @@ static inline lib_msg_t * lib_msg_alloc(nal_cb_t *nal) { /* ALWAYS called with statelock held */ - lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); + lib_msg_t *msg; + PORTAL_SLAB_ALLOC(msg, ptl_msg_slab, sizeof(*msg)); if (msg == NULL) return (NULL); diff --git a/lnet/include/lnet/lib-p30.h b/lnet/include/lnet/lib-p30.h index 55fd720..f11c17a 100644 --- a/lnet/include/lnet/lib-p30.h +++ b/lnet/include/lnet/lib-p30.h @@ -168,7 +168,8 @@ static inline lib_eq_t * lib_eq_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS); + lib_eq_t *eq; + PORTAL_SLAB_ALLOC(eq, ptl_eq_slab, sizeof(*eq)); if (eq == NULL) return (NULL); @@ -189,7 +190,8 @@ static inline lib_md_t * lib_md_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS); + lib_md_t *md; + PORTAL_SLAB_ALLOC(md, ptl_md_slab, sizeof(*md)); if (md == NULL) return (NULL); @@ -210,7 +212,8 @@ static inline lib_me_t * lib_me_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS); + lib_me_t *me; + PORTAL_SLAB_ALLOC(me, ptl_me_slab, sizeof(*me)); if (me == NULL) return (NULL); @@ -231,7 +234,8 @@ static inline lib_msg_t * lib_msg_alloc(nal_cb_t *nal) { /* ALWAYS called with statelock held */ - lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); + lib_msg_t *msg; + PORTAL_SLAB_ALLOC(msg, ptl_msg_slab, sizeof(*msg)); if (msg == NULL) return (NULL); diff --git a/lustre/portals/include/linux/kp30.h b/lustre/portals/include/linux/kp30.h index 3e6d5e3..65cfa17 100644 --- a/lustre/portals/include/linux/kp30.h +++ b/lustre/portals/include/linux/kp30.h @@ -334,7 +334,7 @@ do { \ portal_kmem_inc((ptr), (size)); \ memset((ptr), 0, (size)); \ } \ - CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %ld at %p (tot %d).\n", \ + CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d).\n", \ (int)(size), (ptr), atomic_read(&portal_kmemory)); \ } while (0) diff --git a/lustre/portals/include/portals/lib-p30.h b/lustre/portals/include/portals/lib-p30.h index 55fd720..f11c17a 100644 --- a/lustre/portals/include/portals/lib-p30.h +++ b/lustre/portals/include/portals/lib-p30.h @@ -168,7 +168,8 @@ static inline lib_eq_t * lib_eq_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_eq_t *eq = kmem_cache_alloc(ptl_eq_slab, GFP_NOFS); + lib_eq_t *eq; + PORTAL_SLAB_ALLOC(eq, ptl_eq_slab, sizeof(*eq)); if (eq == NULL) return (NULL); @@ -189,7 +190,8 @@ static inline lib_md_t * lib_md_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_md_t *md = kmem_cache_alloc(ptl_md_slab, GFP_NOFS); + lib_md_t *md; + PORTAL_SLAB_ALLOC(md, ptl_md_slab, sizeof(*md)); if (md == NULL) return (NULL); @@ -210,7 +212,8 @@ static inline lib_me_t * lib_me_alloc (nal_cb_t *nal) { /* NEVER called with statelock held */ - lib_me_t *me = kmem_cache_alloc(ptl_me_slab, GFP_NOFS); + lib_me_t *me; + PORTAL_SLAB_ALLOC(me, ptl_me_slab, sizeof(*me)); if (me == NULL) return (NULL); @@ -231,7 +234,8 @@ static inline lib_msg_t * lib_msg_alloc(nal_cb_t *nal) { /* ALWAYS called with statelock held */ - lib_msg_t *msg = kmem_cache_alloc(ptl_msg_slab, GFP_ATOMIC); + lib_msg_t *msg; + PORTAL_SLAB_ALLOC(msg, ptl_msg_slab, sizeof(*msg)); if (msg == NULL) return (NULL); -- 1.8.3.1