[PATCH v2 1/2] lib/raid: use kvmalloc() in calibrate_xor_blocks()
"Mike Rapoport (Microsoft)" <[email protected]>
| Newsgroups | gmane.linux.raid,gmane.linux.kernel,gmane.linux.kernel.mm |
|---|---|
| Message-ID | <[email protected]> |
The xor benchmark allocates an order 2 (4 pages) scratch buffer that is used purely as a CPU-only XOR working area. This buffer does not need to be physically contiguous and can be allocated with kvmalloc(). Replace __get_free_pages() call with kvmalloc(). Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Mike Rapoport (Microsoft) <[email protected]> --- lib/raid/xor/xor-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/raid/xor/xor-core.c b/lib/raid/xor/xor-core.c index bd4e6e434418..9f90620617cd 100644 --- a/lib/raid/xor/xor-core.c +++ b/lib/raid/xor/xor-core.c @@ -8,6 +8,7 @@ #include <linux/module.h> #include <linux/gfp.h> +#include <linux/slab.h> #include <linux/raid/xor.h> #include <linux/jiffies.h> #include <linux/preempt.h> @@ -114,7 +115,7 @@ static int __init calibrate_xor_blocks(void) if (forced_template) return 0; - b1 = (void *) __get_free_pages(GFP_KERNEL, 2); + b1 = kvmalloc(PAGE_SIZE * 4, GFP_KERNEL); if (!b1) { pr_warn("xor: Yikes! No memory available.\n"); return -ENOMEM; @@ -132,7 +133,7 @@ static int __init calibrate_xor_blocks(void) pr_info("xor: using function: %s (%d MB/sec)\n", fastest->name, fastest->speed); - free_pages((unsigned long)b1, 2); + kvfree(b1); return 0; } -- 2.53.0