Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: David Laight <david.laight.linux@gmail.com>
Cc: Song Liu <song@kernel.org>, Yu Kuai <yukuai@fnnas.com>,
	Li Nan <linan122@huawei.com>, Xiao Ni <xiao@kernel.org>,
	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()
Date: Wed, 27 May 2026 14:12:20 +0300	[thread overview]
Message-ID: <ahbRlHKXTRUR7a-C@kernel.org> (raw)
In-Reply-To: <20260527093720.1261e697@pumpkin>

On Wed, May 27, 2026 at 09:37:20AM +0100, David Laight wrote:
> On Tue, 26 May 2026 17:38:24 +0300
> Mike Rapoport <rppt@kernel.org> 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)" <rppt@kernel.org> 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.


      reply	other threads:[~2026-05-27 11:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  8:17 [PATCH 0/2] lib/raid: replace __get_free_pages() call with kmalloc() Mike Rapoport (Microsoft)
2026-05-20  8:17 ` [PATCH 1/2] lib/raid: use kmalloc() in calibrate_xor_blocks() Mike Rapoport (Microsoft)
2026-05-20 13:00   ` David Laight
2026-05-20  8:17 ` [PATCH 2/2] lib/raid6: use kmalloc() in raid6_select_algo() Mike Rapoport (Microsoft)
2026-05-20 13:06   ` David Laight
2026-05-26 14:38     ` Mike Rapoport
2026-05-27  8:37       ` David Laight
2026-05-27 11:12         ` Mike Rapoport [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ahbRlHKXTRUR7a-C@kernel.org \
    --to=rppt@kernel.org \
    --cc=david.laight.linux@gmail.com \
    --cc=linan122@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=xiao@kernel.org \
    --cc=yukuai@fnnas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox