From: Michal Hocko <mhocko@suse.com>
To: Shakeel Butt <shakeel.butt@linux.dev>
Cc: alexei.starovoitov@gmail.com, bpf@vger.kernel.org,
andrii@kernel.org, memxor@gmail.com, akpm@linux-foundation.org,
peterz@infradead.org, vbabka@suse.cz, bigeasy@linutronix.de,
rostedt@goodmis.org, houtao1@huawei.com, hannes@cmpxchg.org,
willy@infradead.org, tglx@linutronix.de, jannh@google.com,
tj@kernel.org, linux-mm@kvack.org, kernel-team@fb.com
Subject: Re: [PATCH bpf-next v3 1/6] mm, bpf: Introduce try_alloc_pages() for opportunistic page allocation
Date: Thu, 19 Dec 2024 08:18:21 +0100 [thread overview]
Message-ID: <Z2PIva9w8OKW9yYv@tiehlicka> (raw)
In-Reply-To: <mnvsu2v4tnhhbzmebzg6mdmglcs3kq2nxqj2kz3v6p2eigcy6l@c5amf2pgd4zq>
On Wed 18-12-24 16:05:25, Shakeel Butt wrote:
> On Wed, Dec 18, 2024 at 12:32:20PM +0100, Michal Hocko wrote:
> > I like this proposal better. I am still not convinced that we really
> > need internal __GFP_TRYLOCK though.
> >
> > If we reduce try_alloc_pages to the gfp usage we are at the following
> >
> > On Tue 17-12-24 19:07:14, alexei.starovoitov@gmail.com wrote:
> > [...]
> > > +struct page *try_alloc_pages_noprof(int nid, unsigned int order)
> > > +{
> > > + gfp_t alloc_gfp = __GFP_NOWARN | __GFP_ZERO |
> > > + __GFP_NOMEMALLOC | __GFP_TRYLOCK;
> > > + unsigned int alloc_flags = ALLOC_TRYLOCK;
> > [...]
> > > + prepare_alloc_pages(alloc_gfp, order, nid, NULL, &ac,
> > > + &alloc_gfp, &alloc_flags);
> > [...]
> > > + page = get_page_from_freelist(alloc_gfp, order, alloc_flags, &ac);
> > > +
> > > + /* Unlike regular alloc_pages() there is no __alloc_pages_slowpath(). */
> > > +
> > > + trace_mm_page_alloc(page, order, alloc_gfp & ~__GFP_TRYLOCK, ac.migratetype);
> > > + kmsan_alloc_page(page, order, alloc_gfp);
> > [...]
> >
> > From those that care about __GFP_TRYLOCK only kmsan_alloc_page doesn't
> > have alloc_flags. Those could make the locking decision based on
> > ALLOC_TRYLOCK.
> >
> > I am not familiar with kmsan internals and my main question is whether
> > this specific usecase really needs a dedicated reentrant
> > kmsan_alloc_page rather than rely on gfp flag to be sufficient.
> > Currently kmsan_in_runtime bails out early in some contexts. The
> > associated comment about hooks is not completely clear to me though.
> > Memory allocation down the road is one of those but it is not really
> > clear to me whether this is the only one.
>
> Is the suggestion that just introduce and use ALLOC_TRYLOCK without the
> need of __GFP_TRYLOCK?
Exactly! Because ALLOC_$FOO is strictly internal allocator flag that
cannot leak out to external users by design. __GFP_TRYLOCK in this
implementation tries to achieve the same by hiding it which would work
but it is both ugly and likely unnecessary.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2024-12-19 7:18 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 3:07 [PATCH bpf-next v3 0/6] bpf, mm: Introduce try_alloc_pages() alexei.starovoitov
2024-12-18 3:07 ` [PATCH bpf-next v3 1/6] mm, bpf: Introduce try_alloc_pages() for opportunistic page allocation alexei.starovoitov
2024-12-18 11:32 ` Michal Hocko
2024-12-19 0:05 ` Shakeel Butt
2024-12-19 7:18 ` Michal Hocko [this message]
2024-12-19 1:18 ` Alexei Starovoitov
2024-12-19 7:13 ` Michal Hocko
2024-12-20 0:41 ` Alexei Starovoitov
2024-12-19 0:10 ` Shakeel Butt
2024-12-19 1:39 ` Alexei Starovoitov
2024-12-18 3:07 ` [PATCH bpf-next v3 2/6] mm, bpf: Introduce free_pages_nolock() alexei.starovoitov
2024-12-18 4:58 ` Yosry Ahmed
2024-12-18 5:33 ` Alexei Starovoitov
2024-12-18 5:57 ` Yosry Ahmed
2024-12-18 6:37 ` Alexei Starovoitov
2024-12-18 6:49 ` Yosry Ahmed
2024-12-18 7:25 ` Alexei Starovoitov
2024-12-18 7:40 ` Yosry Ahmed
2024-12-18 11:32 ` Michal Hocko
2024-12-19 1:45 ` Alexei Starovoitov
2024-12-19 7:03 ` Michal Hocko
2024-12-20 0:42 ` Alexei Starovoitov
2024-12-18 3:07 ` [PATCH bpf-next v3 3/6] locking/local_lock: Introduce local_trylock_irqsave() alexei.starovoitov
2024-12-18 3:07 ` [PATCH bpf-next v3 4/6] memcg: Use trylock to access memcg stock_lock alexei.starovoitov
2024-12-18 11:32 ` Michal Hocko
2024-12-19 1:53 ` Alexei Starovoitov
2024-12-19 7:08 ` Michal Hocko
2024-12-19 7:27 ` Michal Hocko
2024-12-19 7:52 ` Michal Hocko
2024-12-20 0:39 ` Alexei Starovoitov
2024-12-20 8:24 ` Michal Hocko
2024-12-20 16:10 ` Alexei Starovoitov
2024-12-20 19:45 ` Shakeel Butt
2024-12-21 7:20 ` Michal Hocko
2024-12-18 3:07 ` [PATCH bpf-next v3 5/6] mm, bpf: Use memcg in try_alloc_pages() alexei.starovoitov
2024-12-18 3:07 ` [PATCH bpf-next v3 6/6] bpf: Use try_alloc_pages() to allocate pages for bpf needs alexei.starovoitov
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=Z2PIva9w8OKW9yYv@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=houtao1@huawei.com \
--cc=jannh@google.com \
--cc=kernel-team@fb.com \
--cc=linux-mm@kvack.org \
--cc=memxor@gmail.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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