From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D23C6CD5BC9 for ; Wed, 27 May 2026 11:12:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CA606B00A2; Wed, 27 May 2026 07:12:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12A556B00A5; Wed, 27 May 2026 07:12:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 019206B00A7; Wed, 27 May 2026 07:12:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E5A5E6B00A2 for ; Wed, 27 May 2026 07:12:29 -0400 (EDT) Received: from smtpin23.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 80DF3C2034 for ; Wed, 27 May 2026 11:12:29 +0000 (UTC) X-FDA: 84812936418.23.4BF60CA Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf01.hostedemail.com (Postfix) with ESMTP id D754340013 for ; Wed, 27 May 2026 11:12:27 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ACC0jpyF; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1779880348; a=rsa-sha256; cv=none; b=EV68U+0Bj5e67zlHA3NzWxBYduy+qhwl7rXqsRkUdPWwJG0jeaZT+UlLN8nCaefW1FtvBE d/AegJpXc9WBvezvRvXJ+4MLuTjBSJes5tqujZqmuIuAQ4bVcYgNOf6AFHRG+k51U4GN2g KFEbCapM/zaEOcK9UnhKzL6WvEhadrA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ACC0jpyF; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1779880348; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FOPWFf5iskkWPh+w/MW97eAXySaXHhiPn9n33M/hFWU=; b=s5lkUWTJiP8i33QyPYXqfGulYgeETEknncoCCNWr5iL/Sd4iInJV93N7hQy7qbAVulypRL 5aw59g9wcCCrzphbqMJ3YNekxTsuE3MgwjA6JVU/Qs2TgYlY4ifR5ys3JfP98mhKyIVqvx cMdxCXx+XsfoNwpMTv595HzJlthU/n0= Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B7C82444D4; Wed, 27 May 2026 11:12:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F6E41F000E9; Wed, 27 May 2026 11:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779880346; bh=FOPWFf5iskkWPh+w/MW97eAXySaXHhiPn9n33M/hFWU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=ACC0jpyFzYuGPzHT0IpPesOKu6k+b1ZeJtN0/42mOJWfTwNecuSpl5c6cZfhh/WHX H6TqQ4mwS0dVvD6E65TunVe5sYJ+Eovn9YjvNgN4PPhgT2fhgLwE1p6gWPQZMKnrz1 xhmCKZe8eUgGmBjCNgA95sCZBfyugTErfeJCYIcqD66VF1a7NljSrJODWLX/gzjdrf Gdt00RsZ7cedKPCfGnbjetIsxu2Mk9b8RxDtJl1HmcMANffJ3sU0qXlVJKckNljB3f Cqic25AcXbv6NUCQNy4zO08xyH3GHBV1e62E22Wn7gr7JDSf4qWdZDXd2lpCjgvw4S f8SCy70xyuNHQ== Date: Wed, 27 May 2026 14:12:20 +0300 From: Mike Rapoport To: David Laight 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 2/2] lib/raid6: use kmalloc() in raid6_select_algo() Message-ID: References: <20260520-lib-v1-0-cb3045bef2d8@kernel.org> <20260520-lib-v1-2-cb3045bef2d8@kernel.org> <20260520140657.2b5b5f3b@pumpkin> <20260527093720.1261e697@pumpkin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260527093720.1261e697@pumpkin> X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D754340013 X-Stat-Signature: iypdpgwxndq9kuu9p7d8kimo9jnjxaeg X-HE-Tag: 1779880347-378654 X-HE-Meta: U2FsdGVkX1+IYa76r5xmswI303z4ewSTK2jK9+00ENREjB6ypjLFpxcZtB/qpy7IT+6qhdp89h0gfIlG/FMtbSpmoD5XNWABcJswqWrtq0W+p98lfsl+JqMvQYiZB+wwJKX5VZl8limje5GLrs9hma3DoRAVowPjfprS3I0UWeRIZxWEGwCKNH0W/NE+Bjol9AXcYVKSSmenEqDKHOhdvhq6QySYeOrc8eL9qV9KcDnw4JoLvdhdfaTuSFgVJfxi6imrS+y79lduBtyljau2GEuZjchYUw1ULssBcCapp2aO7A2h/LC6M2WSq1Aq1oJEQpfXb18jQ886MJiFK1REjdkZcgDmbfQiVPodzE1JLM6l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ID: List-Subscribe: List-Unsubscribe: On Wed, May 27, 2026 at 09:37:20AM +0100, David Laight wrote: > On Tue, 26 May 2026 17:38:24 +0300 > Mike Rapoport wrote: > > > On Wed, May 20, 2026 at 02:06:57PM +0100, David Laight wrote: > > > On Wed, 20 May 2026 11:17:52 +0300 > > > "Mike Rapoport (Microsoft)" wrote: > > > > > > > raid6_select_algo() allocates an order 3 (8 pages) buffer that is used > > > > as a scratch area for selection of the best algorithm. > > > > > > Should this code really be using a 4k buffer rather than a PAGE_SIZE one? > > > > Why? > > Why a PAGE_SIZE buffer at all? > The real data will either be file-system block/fragment or raid stripe sized. > Neither is directly related to the memory system page size. > > This actually a valid question for pretty much all of these changes. > > Most architectures use 4k pages (probably because 3-level page tables > fit nicely into a 32bit word and it gave a reasonable number of pages > for 1980s systems) but some use much larger pages; I think 64k and 256k > both get used. > (IIRC m68k hardware uses 2k pages, but Linux uses them in pairs.) > Larger pages reduce allocation costs, TLB pressure and memory overhead. > But can waste memory especially for mmap() of small files. > > Most of these functions just want 'a reasonable sized buffer'. > Possibly requesting whole pages was originally cheaper. > But I also suspect people have written PAGE_SIZE as a name for 4096. > (Much the same as they forget that some systems have 256 byte cache lines.) > > For these changes I think I'd at least add a note in the commit message > when nothing external relies in the size of the buffer and that it could > be changed to 4k. The changes from gfp to kmalloc are intentionally mechanical and intentionally keep the same allocation size. The point of these changes is to stop using ancient and ugly gfp and change users that need a buffer to use kmalloc(). It will also make it easier to differentiate uses that actually need the *page* for the folio project. What is the actual buffer size required is a completely different audit and it's not related to API usage change. > -- David -- Sincerely yours, Mike.