From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6A4E1F2B8D for ; Wed, 20 May 2026 13:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779282028; cv=none; b=VVhz+DdqU7FkNjm8XYWaipcLBCbydkIV+G28CCn/37vlBnTMbCV+i9BBsZqwUlYJLuO2AsrhucZcRBfkWCf07b04N0+8RY+wT+wrh71XpHR4l4l+J0XADQE+GEI8mlIBdIjp1wacVgh0Pl4EppWoM984Ty1G1ymddpUIjczGHhE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779282028; c=relaxed/simple; bh=yC7d2+7mmczzqAaA3iSgC5WYrl3+G5bH2ZE9/gsmyck=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UEdgw19pTQf6spefluYs3xAtGUtJY710A2hX801fePZFJm/f5ACkdd68uWgKoa4O5UVkV3cnDaKlGKJHYyWYwD9pM3l8LlCntDkGMhZcTPstU71NgAK/gejLeQqgBMi2RmQwVusG8nyRILn6dEjejlIN8Cn96ZpEO5vYTKKAUZg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ntjLy5nk; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ntjLy5nk" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-48a3e9862f0so28006275e9.1 for ; Wed, 20 May 2026 06:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779282025; x=1779886825; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=VBgKpCt1/7Dv0saCawyTFbR0vQ6ctxhe2NKjIH0ysvE=; b=ntjLy5nk3+7qXUn+gdYzFwLA76EJBpiV0hC58PDAhT8F+RLtHbMPtzYM9tQRBVAqVV YBBRCcX78JGZAqk9Q1aBjyPf6tSd8YpopX1ZAIjJC7kpi4nClGTO5muTLNoSMoBikArj AQql3s0dX4sdqWQNbZJ9zkWERTHAA3jM9QySq8ahKSANmlDg42/HZbd4eTOUj/FBH31p kPs6BAhhWXNOMYY8sIUaUPVe1FljAs1/Eg3KG6nXdrJohkeQ9c+XRtGJ/NSU1DEDtZqz gjoyKXEXPLDIeMci41y4kkb3rMcpHjCjULl11awTu1YSUMNMjkJVMRfvyCmJ9hmoZRal ZUcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779282025; x=1779886825; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=VBgKpCt1/7Dv0saCawyTFbR0vQ6ctxhe2NKjIH0ysvE=; b=gnGlTbTiuTu6k8lm2IDcduG0vWkxssyLYl4iaVwCGO06PY5o06+oQb6BFiyKbD+Udt BB9rTtkM+JVYlljJvE4Jq8E7J5TLSKIHw6d3e32/wU7TvX8qxqG+mCLRCUHjjXZgtCmZ WVUTtXqDFQfvQ7QMAsouwzhYEYLvlmrhDUJmkyprq0srEtiS96tKlG1lJigVLOMOjiRO L24kweU+TUzo5AGcmVWBuj59wqkSJ8fUWLkvLtEa+0L/m28VIaz6dbOxWcee9bt/c10S /0g2PiiLiCzIkjf1SByUSYY6J/YVl5mJ+58/o/UZZ1Li1xu8e899G4f6rO37HMZglOPG vEIw== X-Forwarded-Encrypted: i=1; AFNElJ+NxqhlLIFIpsxTiDe1CaKHaIsDISAsyoxBBvzZF0Q59axYkhejQGv9CN95yfuhpHRuQCXENAMmvHmauTo=@vger.kernel.org X-Gm-Message-State: AOJu0YzYwddhYT2tNJjRoEUVV/YpfjphFeys2Xr3bMjYWtLvVACN4Ikl R/oxsPAyZ6txZUzHuj9gjUqYhzNQlaNw3JgyDGPX2FPrA08Seq4ncCzp X-Gm-Gg: Acq92OGhuqFTEE6xJzrca1yzQMK252hTlD/PAl0iCLBAYsheWjuMtEjfq/45Kbi+jxm FaN55fGvlDj1wv+ltjJcI7+L9PGs2I+xSs5b/tGxKtPzKGfABc+QWfRbnyRrEN6ZWavyO1kp/n+ fOtJUw+imzpBTMZZm7EbaGqafSPOOaI3pjdvdaEQud1IcciKbHowDAO6TL2ZXgiX7WOhAq95sg2 306HrLBjBeQZ4jH1PQ0xGziqvM+stbbLSFkaZ+aEOLg5Iegaqa21BIcA+JR6mAVAM/qoiwZOGsL tuMmIeO6/9fZMON3Uz9DiqaG6KY/p9zpwIs0OlOtc9pp+HJGO6+HLra17TkB3ioGDN1ZH6THMap /V03D12cfMveuTOxK2JZUhtPJY6WmpaqUYfpuZ94yYV07QpzyeoiWZf/JitbG7z9jeDblypOfXO nKR/yh3hnVVFMlcFhnjI6BAFk7ea2OukUZQvo0EP5pq4zmEZN/viICFNiwQ8SImhYt X-Received: by 2002:a05:600c:83c7:b0:48f:e230:29f5 with SMTP id 5b1f17b1804b1-48fe53a8eccmr362118815e9.16.1779282023422; Wed, 20 May 2026 06:00:23 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe53804aesm376693965e9.15.2026.05.20.06.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 06:00:23 -0700 (PDT) Date: Wed, 20 May 2026 14:00:21 +0100 From: David Laight To: "Mike Rapoport (Microsoft)" Cc: Song Liu , Yu Kuai , Li Nan , Xiao Ni , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-raid@vger.kernel.org Subject: Re: [PATCH 1/2] lib/raid: use kmalloc() in calibrate_xor_blocks() Message-ID: <20260520140021.1d36c0b4@pumpkin> In-Reply-To: <20260520-lib-v1-1-cb3045bef2d8@kernel.org> References: <20260520-lib-v1-0-cb3045bef2d8@kernel.org> <20260520-lib-v1-1-cb3045bef2d8@kernel.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 20 May 2026 11:17:51 +0300 "Mike Rapoport (Microsoft)" wrote: > The xor benchmark allocates an order 2 (4 pages) scratch buffer that is > used purely as a CPU-only XOR working area. > > For such large allocations kmalloc() would fall back to alloc_pages() but > still kmalloc() is a better API as it does not require unnecessary > castings and may provide more debugging possibilities. > > Replace __get_free_pages() call with kmalloc(). You might want to use kvalloc() here. It is less likely to fail. -- David > > Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.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..50931fbf0324 100644 > --- a/lib/raid/xor/xor-core.c > +++ b/lib/raid/xor/xor-core.c > @@ -8,6 +8,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -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 = 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); > > - free_pages((unsigned long)b1, 2); > + kfree(b1); > return 0; > } > >