From nobody Mon Jun 8 16:28:13 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AC3733263F; Thu, 28 May 2026 07:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779953287; cv=none; b=ORJC7J7PYTPuMgs+UXUlhuATjGGDoDOwQjhppfvDlmjQeuxkd17AHNdh5tcI+TWnB6pUX7rofhSQcJkeMJR3U/fG1TI3VvXipsJTTDcHfpCDbI2sMtfhT9f+drFDW2IJND67/gLG3fgB69PTsWi9UBDteSqf9PXHdndYN6MN3sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779953287; c=relaxed/simple; bh=slLGSrh1ppM0MXR+lg2It408Rmx9smVRMw0zj6DPg9E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jzLWhxu2PtCHoSVEvIYGRz6dCRIxPJdjVWUNUFdYx0/907L8QNUmMRcZ3kDQ/rNFpIxONmzI0OOR+yE3qF+y2krPDZYGcQxz6nuwiyvI7IZzIQCJOYRbjSbh/FI2a12/bKbMAB7zyJnob/Ad0yK99ydDzKlEVV9W9tJrdsfrJUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mC/kwi6U; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mC/kwi6U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4F8A1F00A3C; Thu, 28 May 2026 07:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779953286; bh=vK6XINV85j2s6TrgSUq08NPf3qvCIuW4cqZINOK3rPs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=mC/kwi6Us+Mzhj4xAvTHS5kxwU9UeMAmB0sQKTZCMBfY25IK4gsFMM3ydQLs1zjzq zJekufNp37Cz6cKdT9UztYZUKsRww4WsfKBw4h3xo8ZG9gFuWzpg5puC3sTdlgk4Br FxqTwbyYJUT7ixVWza5yfEiprUHPJTwzSogSa6V7YeaLjby7sYaFvF2gnliBJVg01f rAkfgW5IbBuqvoYQLndkKHFegPRiE7Gz85i+375gEkLBD+dwrVn7SnWX6DfLCtZhue 250wtDJ4rL78Mo+9dW2Pd8GoYM3SX/kMXec6t+Cr/RDpQ5XyoYkVwCyfGHk9fjbMBw 74AdQFn3iQ37Q== From: "Mike Rapoport (Microsoft)" Date: Thu, 28 May 2026 10:27:55 +0300 Subject: [PATCH v3 1/2] xor: use kmalloc() in calibrate_xor_blocks() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260528-lib-v3-1-feccddf1cb6d@kernel.org> References: <20260528-lib-v3-0-feccddf1cb6d@kernel.org> In-Reply-To: <20260528-lib-v3-0-feccddf1cb6d@kernel.org> To: Andrew Morton Cc: Christoph Hellwig , David Laight , Li Nan , Mike Rapoport , Song Liu , Xiao Ni , Yu Kuai , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-raid@vger.kernel.org X-Mailer: b4 0.15.2 The xor benchmark allocates 4 pages for a scratch buffer that is used purely as a CPU-only XOR working area. 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@redh= at.com Signed-off-by: Mike Rapoport (Microsoft) --- 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..7f6436774644 100644 --- a/lib/raid/xor/xor-core.c +++ b/lib/raid/xor/xor-core.c @@ -8,6 +8,7 @@ =20 #include #include +#include #include #include #include @@ -114,7 +115,7 @@ static int __init calibrate_xor_blocks(void) if (forced_template) return 0; =20 - b1 =3D (void *) __get_free_pages(GFP_KERNEL, 2); + b1 =3D kmalloc(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); =20 - free_pages((unsigned long)b1, 2); + kvfree(b1); return 0; } =20 --=20 2.53.0 From nobody Mon Jun 8 16:28:13 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6D0F338936; Thu, 28 May 2026 07:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779953290; cv=none; b=VMVC6rviPEKL8gWfFRq+iz0nkuqE7Ny3gAe1ZFI6YB6Y51RE5vfXjDqcSm02uWXzEQnCFyk7+Rfnu5H8YRwofKlyx5kzJD12eYGYXenNlSUwWltBbw6nFbTQoYg1W7dzRy5XAPL6eOvpw8GsBfIECbhTaWmJJ75c+TXoCXz4GtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779953290; c=relaxed/simple; bh=hmQK5CIlFl2AvJIzl6zmbj4LT69qjpHZ564dgQ4OYk4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HLio7wcfQG74kG4KkwJrvmtjFP+0enEbmMSLwp333WZbqPYUpp1Ogp/Mg/j1cyWUuQ5ARl0lZXsKDgwSe9ucGI3h8TWtq6zmxhUanBoButamisV/v2N1Lx5BV+tzhMFP+7qxI1Vs/sB+M7qSPtKWckL19m0L/yXKV7xma7imN3E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kgJkJFPY; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kgJkJFPY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B714E1F000E9; Thu, 28 May 2026 07:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779953289; bh=XEeN37H8h/7BFZlOijbo/XwxvG5JbF06mBE8+arc+so=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=kgJkJFPYhHjM8mv5iClIhg36up2oojmFtfnY1wVYRTJ7/24fTpLlPxNEvEAw2+Yhd iAe/SQOAecbd6x3iEdLDZvS2Pc4lkTxiGn/D/ZjU5qg28/N02o01ou1wPK2BF2pwBL HsnywiEzFWCAL7TQpPPCyHE5H+ArLHrVXrEd3W7mziDAXwhg+36pdITWg8amMaEpz2 kYS/x8midsVs+mPfdFZg/NKhhtUlsTgrL5HtNZC+emHlaWvK8g3ZopY0A3i/ernUkr TvEyA6prgpTW+YFYTApj3ZT43BgMWtJxcmBeczun9u1jEjfTO7rHLM6UvTt+oQamRJ cxGp/OeDwhIvg== From: "Mike Rapoport (Microsoft)" Date: Thu, 28 May 2026 10:27:56 +0300 Subject: [PATCH v3 2/2] raid6: use kmalloc() in raid6_select_algo() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260528-lib-v3-2-feccddf1cb6d@kernel.org> References: <20260528-lib-v3-0-feccddf1cb6d@kernel.org> In-Reply-To: <20260528-lib-v3-0-feccddf1cb6d@kernel.org> To: Andrew Morton Cc: Christoph Hellwig , David Laight , Li Nan , Mike Rapoport , Song Liu , Xiao Ni , Yu Kuai , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-raid@vger.kernel.org X-Mailer: b4 0.15.2 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@redh= at.com Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Christoph Hellwig --- lib/raid6/algos.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c index 799e0e5eac26..89e627c62e30 100644 --- a/lib/raid6/algos.c +++ b/lib/raid6/algos.c @@ -12,6 +12,7 @@ */ =20 #include +#include #ifndef __KERNEL__ #include #include @@ -129,7 +130,6 @@ const struct raid6_recov_calls *const raid6_recov_algos= [] =3D { #endif =20 #define RAID6_TEST_DISKS 8 -#define RAID6_TEST_DISKS_ORDER 3 =20 static inline const struct raid6_recov_calls *raid6_choose_recov(void) { @@ -250,7 +250,7 @@ int __init raid6_select_algo(void) int i, cycle; =20 /* prepare the buffer and fill it circularly with gfmul table */ - disk_ptr =3D (char *)__get_free_pages(GFP_KERNEL, RAID6_TEST_DISKS_ORDER); + disk_ptr =3D kmalloc(PAGE_SIZE * RAID6_TEST_DISKS, GFP_KERNEL); if (!disk_ptr) { pr_err("raid6: Yikes! No memory available.\n"); return -ENOMEM; @@ -275,7 +275,7 @@ int __init raid6_select_algo(void) /* select raid recover functions */ rec_best =3D raid6_choose_recov(); =20 - free_pages((unsigned long)disk_ptr, RAID6_TEST_DISKS_ORDER); + kfree(disk_ptr); =20 return gen_best && rec_best ? 0 : -EINVAL; } --=20 2.53.0