linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	bpf <bpf@vger.kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	 Martin KaFai Lau <martin.lau@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Peter Zijlstra <peterz@infradead.org>,
	Sebastian Sewior <bigeasy@linutronix.de>,
	 Steven Rostedt <rostedt@goodmis.org>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	 Michal Hocko <mhocko@suse.com>, linux-mm <linux-mm@kvack.org>,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/page_alloc: Fix try_alloc_pages
Date: Tue, 1 Apr 2025 10:56:02 -0700	[thread overview]
Message-ID: <CAADnVQ+V_RAMfM9GLfMq4pyAM6xaSnUQ2sqS0oisDZmaWvC5Uw@mail.gmail.com> (raw)
In-Reply-To: <ac5d6544-32cb-4ae1-a62a-7720b67b4042@suse.cz>

On Tue, Apr 1, 2025 at 12:53 AM Vlastimil Babka <vbabka@suse.cz> wrote:
>
> On 4/1/25 05:23, Alexei Starovoitov wrote:
> > From: Alexei Starovoitov <ast@kernel.org>
> >
> > Fix an obvious bug. try_alloc_pages() should set_page_refcounted.
> >
> > Fixes: 97769a53f117 ("mm, bpf: Introduce try_alloc_pages() for opportunistic page allocation")
> > Signed-off-by: Alexei Starovoitov <ast@kernel.org>
>
> Acked-by: Vlastimil BAbka <vbabka@suse.cz>
>
> > ---
> >
> > As soon as I fast forwarded and rerun the tests the bug was
> > seen immediately.
> > I'm completely baffled how I managed to lose this hunk.
>
> I think the earlier versions were done on older base than v6.14-rc1 which
> acquired efabfe1420f5 ("mm/page_alloc: move set_page_refcounted() to callers
> of get_page_from_freelist()")

ohh. Thanks.
Still, I have no excuse for not doing full integration testing.
I will learn this hard lesson.

> > I'm pretty sure I manually tested various code paths of
> > trylock logic with CONFIG_DEBUG_VM=y.
> > Pure incompetence :(
> > Shame.
> > ---
> >  mm/page_alloc.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index ffbb5678bc2f..c0bcfe9d0dd9 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -7248,6 +7248,9 @@ struct page *try_alloc_pages_noprof(int nid, unsigned int order)
> >
> >       /* Unlike regular alloc_pages() there is no __alloc_pages_slowpath(). */
> >
> > +     if (page)
> > +             set_page_refcounted(page);
>
> Note for the later try-kmalloc integration, slab uses frozen pages now, so
> we'll need to split out a frozen variant of this API.

Thanks for the heads up.

> But this is ok as a bugfix for now.
>
> > +
> >       if (memcg_kmem_online() && page &&
> >           unlikely(__memcg_kmem_charge_page(page, alloc_gfp, order) != 0)) {
> >               free_pages_nolock(page, order);
>


  reply	other threads:[~2025-04-01 17:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01  3:23 Alexei Starovoitov
2025-04-01  3:41 ` Harry Yoo
2025-04-01  7:53 ` Vlastimil Babka
2025-04-01 17:56   ` Alexei Starovoitov [this message]
2025-04-01  8:42 ` Michal Hocko
2025-04-02  4:30 ` Shakeel Butt
2025-04-02 22:01 ` patchwork-bot+netdevbpf

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=CAADnVQ+V_RAMfM9GLfMq4pyAM6xaSnUQ2sqS0oisDZmaWvC5Uw@mail.gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=martin.lau@kernel.org \
    --cc=mhocko@suse.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=shakeel.butt@linux.dev \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    /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