summaryrefslogtreecommitdiff
path: root/lib/raid
diff options
context:
space:
mode:
authorMike Rapoport (Microsoft) <rppt@kernel.org>2026-05-28 12:53:01 +0300
committerAndrew Morton <akpm@linux-foundation.org>2026-06-04 14:49:28 -0700
commit19c000ba93d609e15e95fed76a9e3b8055833098 (patch)
tree1a5bb24e764ad7492238f9b3421b81e345082f7d /lib/raid
parentd280a26a983f62bfeff3f134f9d5ba4035356b43 (diff)
downloadlinux-next-19c000ba93d609e15e95fed76a9e3b8055833098.tar.gz
linux-next-19c000ba93d609e15e95fed76a9e3b8055833098.zip
raid6: use kmalloc() in raid6_select_algo()
raid6_select_algo() allocates 8 pages for buffer that is used as a scratch area for selection of the best algorithm. This buffer can be allocated with kmalloc() as there's nothing special about it to go directly to the page allocator. kmalloc() provides a better API than ancient __get_free_pages(). kmalloc() does not require ugly casts and kfree() does not need to know the size of the freed object. There is no performance difference because kmalloc() redirects allocations of such size to the page allocator. Replace __get_free_pages() call with kmalloc(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com Link: https://lore.kernel.org/20260528-lib-v4-2-4e3ad1277279@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Christoph Hellwig <hch@infradead.org> Cc: Hannes Reinecke <hare@kernel.org> Cc: Li Nan <linan122@huawei.com> Cc: Song Liu <song@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib/raid')
-rw-r--r--lib/raid/raid6/algos.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/raid/raid6/algos.c b/lib/raid/raid6/algos.c
index a600d5853672..6f5c89ab2b17 100644
--- a/lib/raid/raid6/algos.c
+++ b/lib/raid/raid6/algos.c
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/gfp.h>
#include <linux/raid/pq.h>
+#include <linux/slab.h>
#include <linux/static_call.h>
#include <kunit/visibility.h>
#include "algos.h"
@@ -153,7 +154,6 @@ EXPORT_SYMBOL_GPL(raid6_recov_datap);
#define RAID6_TIME_JIFFIES_LG2 4
#define RAID6_TEST_DISKS 8
-#define RAID6_TEST_DISKS_ORDER 3
static int raid6_choose_gen(void *(*const dptrs)[RAID6_TEST_DISKS],
const int disks)
@@ -247,7 +247,7 @@ static int __init raid6_select_algo(void)
}
/* prepare the buffer and fill it circularly with gfmul table */
- disk_ptr = (char *)__get_free_pages(GFP_KERNEL, RAID6_TEST_DISKS_ORDER);
+ disk_ptr = kmalloc(PAGE_SIZE * RAID6_TEST_DISKS, GFP_KERNEL);
if (!disk_ptr) {
pr_err("raid6: Yikes! No memory available.\n");
return -ENOMEM;
@@ -269,7 +269,7 @@ static int __init raid6_select_algo(void)
/* select raid gen_syndrome function */
error = raid6_choose_gen(&dptrs, disks);
- free_pages((unsigned long)disk_ptr, RAID6_TEST_DISKS_ORDER);
+ kfree(disk_ptr);
return error;
}