Whamcloud - gitweb
b=1933
authorphil <phil>
Sat, 29 Nov 2003 04:28:12 +0000 (04:28 +0000)
committerphil <phil>
Sat, 29 Nov 2003 04:28:12 +0000 (04:28 +0000)
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
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-p30.h
lustre/portals/include/linux/kp30.h
lustre/portals/include/portals/lib-p30.h

index 3e6d5e3..65cfa17 100644 (file)
@@ -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)
 
index 55fd720..f11c17a 100644 (file)
@@ -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);
index 55fd720..f11c17a 100644 (file)
@@ -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);
index 3e6d5e3..65cfa17 100644 (file)
@@ -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)
 
index 55fd720..f11c17a 100644 (file)
@@ -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);