<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
Acked-by: Patrick Farrell <paf@cray.com></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> lustre-devel <lustre-devel-bounces@lists.lustre.org> on behalf of NeilBrown <neilb@suse.com><br>
<b>Sent:</b> Tuesday, December 12, 2017 9:15:55 PM<br>
<b>To:</b> Oleg Drokin; James Simmons; Andreas Dilger; Greg Kroah-Hartman<br>
<b>Cc:</b> linux-kernel@vger.kernel.org; lustre-devel@lists.lustre.org<br>
<b>Subject:</b> [lustre-devel] [PATCH 07/12] staging: lustre: libcfs: simplify memory allocation.</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText">1/ Use kvmalloc() instead of kmalloc or vmalloc<br>
2/ Discard the _GFP() interfaces that are never used.<br>
  We only ever do GFP_NOFS and GFP_ATOMIC allocations,<br>
  so support each of those explicitly.<br>
<br>
Signed-off-by: NeilBrown <neilb@suse.com><br>
---<br>
 .../lustre/include/linux/libcfs/libcfs_private.h   |   42 ++++++--------------<br>
 1 file changed, 12 insertions(+), 30 deletions(-)<br>
<br>
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h<br>
index 2f4ff595fac9..c874f9d15c72 100644<br>
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h<br>
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h<br>
@@ -84,14 +84,6 @@ do {                                                             \<br>
         lbug_with_loc(&msgdata);                                        \<br>
 } while (0)<br>
 <br>
-#ifndef LIBCFS_VMALLOC_SIZE<br>
-#define LIBCFS_VMALLOC_SIZE    (2 << PAGE_SHIFT) /* 2 pages */<br>
-#endif<br>
-<br>
-#define LIBCFS_ALLOC_PRE(size, mask)                                   \<br>
-       LASSERT(!in_interrupt() || ((size) <= LIBCFS_VMALLOC_SIZE &&    \<br>
-                                   !gfpflags_allow_blocking(mask)))<br>
-<br>
 #define LIBCFS_ALLOC_POST(ptr, size)                                        \<br>
 do {                                                                        \<br>
         if (unlikely(!(ptr))) {                                             \<br>
@@ -103,46 +95,36 @@ do {                                                                           \<br>
 } while (0)<br>
 <br>
 /**<br>
- * allocate memory with GFP flags @mask<br>
+ * default allocator<br>
  */<br>
-#define LIBCFS_ALLOC_GFP(ptr, size, mask)                                  \<br>
+#define LIBCFS_ALLOC(ptr, size)                                                    \<br>
 do {                                                                        \<br>
-       LIBCFS_ALLOC_PRE((size), (mask));                                   \<br>
-       (ptr) = (size) <= LIBCFS_VMALLOC_SIZE ?                             \<br>
-               kmalloc((size), (mask)) : vmalloc(size);            \<br>
+       LASSERT(!in_interrupt());                                           \<br>
+       (ptr) = kvmalloc((size), GFP_NOFS);                                 \<br>
         LIBCFS_ALLOC_POST((ptr), (size));                                   \<br>
 } while (0)<br>
 <br>
-/**<br>
- * default allocator<br>
- */<br>
-#define LIBCFS_ALLOC(ptr, size) \<br>
-       LIBCFS_ALLOC_GFP(ptr, size, GFP_NOFS)<br>
-<br>
 /**<br>
  * non-sleeping allocator<br>
  */<br>
-#define LIBCFS_ALLOC_ATOMIC(ptr, size) \<br>
-       LIBCFS_ALLOC_GFP(ptr, size, GFP_ATOMIC)<br>
+#define LIBCFS_ALLOC_ATOMIC(ptr, size)                                 \<br>
+do {                                                                   \<br>
+       (ptr) = kmalloc((size), GFP_ATOMIC);                            \<br>
+       LIBCFS_ALLOC_POST(ptr, size);                                   \<br>
+} while (0)<br>
 <br>
 /**<br>
  * allocate memory for specified CPU partition<br>
  *   \a cptab != NULL, \a cpt is CPU partition id of \a cptab<br>
  *   \a cptab == NULL, \a cpt is HW NUMA node id<br>
  */<br>
-#define LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, mask)                  \<br>
+#define LIBCFS_CPT_ALLOC(ptr, cptab, cpt, size)                                    \<br>
 do {                                                                        \<br>
-       LIBCFS_ALLOC_PRE((size), (mask));                                   \<br>
-       (ptr) = (size) <= LIBCFS_VMALLOC_SIZE ?                             \<br>
-               kmalloc_node((size), (mask), cfs_cpt_spread_node(cptab, cpt)) :\<br>
-               vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt));        \<br>
+       LASSERT(!in_interrupt());                                           \<br>
+       (ptr) = kvmalloc_node((size), GFP_NOFS, cfs_cpt_spread_node(cptab, cpt)); \<br>
         LIBCFS_ALLOC_POST((ptr), (size));                                   \<br>
 } while (0)<br>
 <br>
-/** default numa allocator */<br>
-#define LIBCFS_CPT_ALLOC(ptr, cptab, cpt, size)                                    \<br>
-       LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, GFP_NOFS)<br>
-<br>
 #define LIBCFS_FREE(ptr, size)                                    \<br>
 do {                                                                \<br>
         if (unlikely(!(ptr))) {                                         \<br>
<br>
<br>
_______________________________________________<br>
lustre-devel mailing list<br>
lustre-devel@lists.lustre.org<br>
<a href="http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org">http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org</a><br>
</div>
</span></font></div>
</body>
</html>