diff options
author | 2018-01-09 12:19:38 +1100 | |
---|---|---|
committer | 2018-01-09 15:48:45 +0100 | |
commit | 8d60ecd99c9bafedfb49e7a3bc0cc31887100559 (patch) | |
tree | 24ac46d2f98c6cd72d7bff33de328e05e358858f /drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | |
parent | staging: lustre: opencode LIBCFS_ALLOC_ATOMIC calls. (diff) | |
download | linux-8d60ecd99c9bafedfb49e7a3bc0cc31887100559.tar.gz linux-8d60ecd99c9bafedfb49e7a3bc0cc31887100559.tar.bz2 linux-8d60ecd99c9bafedfb49e7a3bc0cc31887100559.zip |
staging: lustre: replace LIBCFS_CPT_ALLOC()
LIBCFS_APT_ALLOC() calls kvmalloc_node() with GFP_NOFS
which is not permitted.
Mostly, a kmalloc_node(GFP_NOFS) is appropriate, though occasionally
the allocation is large and GFP_KERNEL is acceptable, so
kvmalloc_node() can be used.
This patch introduces 4 alternatives to LIBCFS_CPT_ALLOC():
kmalloc_cpt()
kzalloc_cpt()
kvmalloc_cpt()
kvzalloc_cpt().
Each takes a size, gfp flags, and cpt number.
Almost every call to LIBCFS_CPT_ALLOC() passes lnet_cpt_table()
as the table. This patch embeds that choice in the k*alloc_cpt()
macros, and opencode kzalloc_node(..., cfs_cpt_spread_node(..))
in the one case that lnet_cpt_table() isn't used.
When LIBCFS_CPT_ALLOC() is replaced, the matching LIBCFS_FREE()
is also replaced, with with kfree() or kvfree() as appropriate.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/include/linux/libcfs/libcfs_private.h')
-rw-r--r-- | drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index d230c7f7cced..50a600564fb2 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -126,6 +126,25 @@ do { \ kvfree(ptr); \ } while (0) +/* + * Use #define rather than inline, as lnet_cpt_table() might + * not be defined yet + */ +#define kmalloc_cpt(size, flags, cpt) \ + kmalloc_node(size, flags, cfs_cpt_spread_node(lnet_cpt_table(), cpt)) + +#define kzalloc_cpt(size, flags, cpt) \ + kmalloc_node(size, flags | __GFP_ZERO, \ + cfs_cpt_spread_node(lnet_cpt_table(), cpt)) + +#define kvmalloc_cpt(size, flags, cpt) \ + kvmalloc_node(size, flags, \ + cfs_cpt_spread_node(lnet_cpt_table(), cpt)) + +#define kvzalloc_cpt(size, flags, cpt) \ + kvmalloc_node(size, flags | __GFP_ZERO, \ + cfs_cpt_spread_node(lnet_cpt_table(), cpt)) + /******************************************************************************/ void libcfs_debug_dumplog(void); |