mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
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>
This commit is contained in:
parent
d280a26a98
commit
19c000ba93
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user