mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Chris Down <chris@chrisdown.name>
Cc: "David Hildenbrand" <david@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Michal Hocko" <mhocko@suse.com>,
	"David Rientjes" <rientjes@google.com>,
	"Shakeel Butt" <shakeel.butt@linux.dev>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Jann Horn" <jannh@google.com>,
	"Pedro Falcato" <pfalcato@suse.de>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	"Jan Kara" <jack@suse.cz>, "Nhat Pham" <nphamcs@gmail.com>,
	"Johannes Weiner" <hannes@cmpxchg.org>, "Zi Yan" <ziy@nvidia.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Joshua Hahn" <joshua.hahnjy@gmail.com>,
	"Byungchul Park" <byungchul@sk.com>,
	"Gregory Price" <gourry@gourry.net>,
	"Ying Huang" <ying.huang@linux.alibaba.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Usama Arif" <usama.arif@linux.dev>,
	"Kairui Song" <kasong@tencent.com>,
	"Balbir Singh" <balbirs@nvidia.com>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Kiryl Shutsemau" <kas@kernel.org>,
	"Yu-cheng Yu" <yu-cheng.yu@intel.com>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Dennis Zhou" <dennis@kernel.org>, "Tejun Heo" <tj@kernel.org>,
	"Christoph Lameter" <cl@gentwo.org>,
	"Peng Fan" <peng.fan@nxp.com>, "Josef Bacik" <jbacik@fb.com>,
	"Chris Mason" <mason@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	"Borislav Petkov (AMD)" <bp@alien8.de>,
	"Mark Brown" <broonie@kernel.org>,
	"Dennis Zhou (Facebook)" <dennisszhou@gmail.com>,
	"Rick Edgecombe" <rick.p.edgecombe@intel.com>
Subject: Re: [PATCH v2 11/13] percpu: fix contig hints that are too low
Date: Sun, 15 Nov 2026 13:20:33 +0000	[thread overview]
Message-ID: <avmpMjM-nrzifxYP@gremlin> (raw)
In-Reply-To: <20261114115708.18fff016c293a57b@chrisdown.name>

Chris - a lot of your replies here seem LLM-generated, and this one in
particular seems especially so.

I've been working evenings and weekends to help with the workload doing
_human_ passes over already AI-generated fixes, so please have a little
consideration for that + keep replies to technical points and as succinct
as possible, thanks.

On Sat, Nov 14, 2026 at 11:57:08AM -0800, Chris Down wrote:
> Hi Lorenzo,
>
> Lorenzo Stoakes (ARM) writes:
> > Secondly, when a free stays within one block,
> > pcpu_block_update_hint_free() passes the end of the free area to the
> > chunk hints as a block offset rather than a chunk offset, so in any block
> > but the first the chunk hints are not updated at all.
>
> Joonwon Kang sent this part earlier this year as "percpu: Fix wrong chunk
> hints update" [1]. It has Dennis' Reviewed-by, but as far as I can tell it
> was never picked up. The rest of that series goes after the scan_hint
> problems by fixing how pcpu_block_update() maintains scan_hint, rather
> than by dropping the promotion, and Dennis was still reviewing that in
> May [2]. It touches the same code as the first case here, so the two won't
> apply on top of each other. It's probably worth adding Joonwon to Cc and
> working out between you which one goes in first.

I'm sorry this is (AI-generated?) nonsense, that's not at all how kernel
development works.

This is a series that got stalled 6 months ago and does things other than
this fix. That doesn't put an indefinite hold on future work in the area,
nor does it give the submitter a veto or say on future work.

So the submitter is welcome to resend and rebase on the fix.

In general, given that this is a drive-by review, with respect, please try
to stick to technical issues, thanks.

>
> > Thirdly, that free area stops at the block boundary, even if the free
> > bits continue into a neighbouring block.
>
> Wasn't this one deliberate? The comment this patch removes says that
> chunk_md->contig_hint may be off by up to a page, as a tradeoff to avoid
> iterating over the block metadata on every free. I don't mind changing
> that, but it'd be good for the changelog to say so, because any free
> whose area reaches a block boundary now ends up in
> pcpu_chunk_refresh_hint().

'I don't mind' :)) for some reason you (or rather persumably your LLM) has
adopted the tone of a component owner which isn't quite appropriate here,
let's maybe try to avoid that in future thanks.

The changelog already covers this, it states that a contig_hint must never be
smaller than the largest free area, and lists this as the third way in
which that is violated.

That it was done on purpose doesn't make it less of a bug - the hint being
too low is what causes pcpu_find_block_fit() to reject a chunk that fits.

>
> > Fix these by always rescanning when a contig_hint is broken, passing the
> > correct offset, and refreshing the chunk hints whenever a free area
> > reaches a block boundary.
>
> Similarly, da3afdd5bb54 ("percpu: use block scan_hint to only scan
> forward") and d33d9f3dd96b ("percpu: use chunk scan_hint to skip some
> scanning") added the scan_hint promotion to avoid exactly these rescans,
> so do you have any numbers for what always rescanning from first_free
> costs on the allocation path?

Nope, I am reworking AI-generated fix patches and this is currently broken,
it doesn't require perf numbers. It needs to be made right first.

In any case the block rescan is bounded at PCPU_BITMAP_BLOCK_BITS and this
issue only happens if a contig_hint is broken.

>
> The result does look right to me, though. From a quick check with the
> hint code lifted into a userspace harness and random allocations and
> frees thrown at it, contig_hint regularly ends up below the largest free
> area before this patch (for both blocks and the chunk) but is fine after
> this patch is applied.

OK thanks.

>
> [1] https://lore.kernel.org/r/20260513085117.1024175-1-joonwonkang@google.com
> [2] https://lore.kernel.org/r/ahVWu38ymnSeLnv3@palisades.local
>
> Thanks!
>
> Chris

--
Cheers, Lorenzo

  reply	other threads:[~2026-11-15 13:20 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 21:45 [PATCH v2 00/13] mm: batch of (urgentish?) fixes in oomk, cachestat, dev-migrate, percpu Lorenzo Stoakes (ARM)
2026-11-13 21:45 ` [PATCH v2 01/13] mm/mmap: free gathered pages before MMF_OOM_SKIP Lorenzo Stoakes (ARM)
2026-11-14 19:56   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 02/13] mm: cachestat: count each page only once Lorenzo Stoakes (ARM)
2026-11-14 19:56   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 03/13] mm: cachestat: restart the walk after each entry Lorenzo Stoakes (ARM)
2026-11-14 18:08   ` Nhat Pham
2026-11-14 19:56   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 04/13] mm/migrate_device: allocate THP deferred split heads Lorenzo Stoakes (ARM)
2026-11-14 19:56   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 05/13] mm/migrate_device: don't collect a range twice Lorenzo Stoakes (ARM)
2026-11-14  5:09   ` Balbir Singh
2026-11-14  6:45     ` Mika Penttilä
2026-11-14 18:34       ` Lorenzo Stoakes (ARM)
2026-11-15  9:24         ` Mika Penttilä
2026-11-14 19:56   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 06/13] mm/migrate_device: don't let go of the fault page Lorenzo Stoakes (ARM)
2026-11-13 22:31   ` Balbir Singh
2026-11-14 19:56   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 07/13] mm/migrate_device: look up fault folio after a split Lorenzo Stoakes (ARM)
2026-11-13 22:20   ` Balbir Singh
2026-11-14 19:56   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 08/13] mm/migrate_device: fix ksmd oops on a migrated KSM page Lorenzo Stoakes (ARM)
2026-11-14 19:56   ` Chris Down
2026-11-15 12:43     ` Lorenzo Stoakes (ARM)
2026-11-13 21:45 ` [PATCH v2 09/13] mm/migrate_device: fix use-after-free of the anon rmap Lorenzo Stoakes (ARM)
2026-11-14 19:57   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 10/13] mm/migrate_device: refuse to migrate shadow stacks Lorenzo Stoakes (ARM)
2026-11-14 19:57   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 11/13] percpu: fix contig hints that are too low Lorenzo Stoakes (ARM)
2026-11-14 19:57   ` Chris Down
2026-11-15 13:20     ` Lorenzo Stoakes (ARM) [this message]
2026-11-13 21:45 ` [PATCH v2 12/13] percpu: search the whole reserved chunk Lorenzo Stoakes (ARM)
2026-11-14 19:57   ` Chris Down
2026-11-13 21:45 ` [PATCH v2 13/13] percpu: queue the balance work on an unbound workqueue Lorenzo Stoakes (ARM)
2026-11-14 19:57   ` Chris Down
2026-11-14 23:07   ` Balbir Singh
2026-11-15 12:41     ` Lorenzo Stoakes (ARM)

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=avmpMjM-nrzifxYP@gremlin \
    --to=ljs@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=balbirs@nvidia.com \
    --cc=bp@alien8.de \
    --cc=broonie@kernel.org \
    --cc=byungchul@sk.com \
    --cc=chris@chrisdown.name \
    --cc=cl@gentwo.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@kernel.org \
    --cc=dennis@kernel.org \
    --cc=dennisszhou@gmail.com \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=jbacik@fb.com \
    --cc=jglisse@redhat.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kas@kernel.org \
    --cc=kasong@tencent.com \
    --cc=liam@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mason@kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=mhocko@suse.com \
    --cc=nphamcs@gmail.com \
    --cc=peng.fan@nxp.com \
    --cc=pfalcato@suse.de \
    --cc=rick.p.edgecombe@intel.com \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=willy@infradead.org \
    --cc=ying.huang@linux.alibaba.com \
    --cc=yu-cheng.yu@intel.com \
    --cc=ziy@nvidia.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

all inboxes | Powered by JetHome®