Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
To: "Harry Yoo (Oracle)" <harry@kernel.org>, Levi Zim <i@kxxt.dev>
Cc: linux-mm@kvack.org, rcu@vger.kernel.org, bpf@vger.kernel.org,
	Hao Li <hao.li@linux.dev>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	Joel Fernandes <joelagnelf@nvidia.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Puranjay Mohan <puranjay@kernel.org>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Amery Hung <ameryhung@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>
Subject: Re: kmalloc_nolock() follow-ups, including kfree_rcu_nolock()
Date: Thu, 14 May 2026 11:39:50 +0200	[thread overview]
Message-ID: <be7a2a06-cd81-446c-9875-fafb198caf78@kernel.org> (raw)
In-Reply-To: <2dhbxmhg4l35gupk3wgwtufsf735rnk4czmcoyspzckvexie3z@nswohkoipx44>

On 5/14/26 11:25, Harry Yoo (Oracle) wrote:
> On Wed, May 13, 2026 at 09:34:01PM +0800, Levi Zim wrote:
>> On 5/13/26 9:42 AM, Harry Yoo (Oracle) wrote:
>> > On Tue, May 12, 2026 at 09:46:33PM +0800, Levi Zim wrote:
>> >> I don't know how could we fix it otherwise after removing BPF memory allocator completely.
>> >> Could we find a path to move forward without causing regressions on architectures without HAVE_CMPXCHG_DOUBLE?
>> > 
>> > Probably we can. Could you please see if this works for you?
>> > 
>> > https://git.kernel.org/pub/scm/linux/kernel/git/harry/linux.git/log/?h=slab-kmalloc-nolock-without-cmpxchg-double-rfc-v1r1-wip
>> 
>> Thanks a lot! I tested it and could confirm that it could fix the failure of
>> bpf_task_storage_get(BPF_LOCAL_STORAGE_GET_F_CREATE) on riscv64.
> 
> Thanks for confirming!
> 
> I will add this to TODO and post them and Cc you when submitting it to
> the mailing list.
> 
>> The commit message says that the allocation may still fail if the slab lock
>> acquisition fails upon the first try.
> 
> kmalloc_nolock() can always fail, unfortunately.
> We can only make it less likely to fail.

There's still the fallback to the larger bucket, right?
That pretty much guarantees that if we fail due to a local lock in one
bucket (due to preempting its holder), a local lock in another bucket won't
be locked at the same time.
However if local sheaves are exhausted, we might need a shared lock (barn,
list_lock, slab bit lock when no double cmpxchg) and that might be held by
another cpu in both buckets. But should be very rare.

>> But this is still a great improvement
>> compared to the previous always failing code.
> 
> Yup. Thanks!
> 



  reply	other threads:[~2026-05-14  9:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 12:25 kmalloc_nolock() follow-ups, including kfree_rcu_nolock() Harry Yoo (Oracle)
2026-05-12 13:46 ` Levi Zim
2026-05-13  1:42   ` Harry Yoo (Oracle)
2026-05-13 13:34     ` Levi Zim
2026-05-14  9:25       ` Harry Yoo (Oracle)
2026-05-14  9:39         ` Vlastimil Babka (SUSE) [this message]
2026-05-14 10:09           ` Harry Yoo (Oracle)
2026-05-14 14:26             ` Vlastimil Babka (SUSE)

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=be7a2a06-cd81-446c-9875-fafb198caf78@kernel.org \
    --to=vbabka@kernel.org \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=hao.li@linux.dev \
    --cc=harry@kernel.org \
    --cc=i@kxxt.dev \
    --cc=joelagnelf@nvidia.com \
    --cc=linux-mm@kvack.org \
    --cc=memxor@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=puranjay@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=urezki@gmail.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