mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: George Guo <dongtai.guo@linux.dev>
Cc: chenhuacai@kernel.org, hengqi.chen@gmail.com,
	loongarch@lists.linux.dev, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] LoongArch: BPF: Make arena support depend on SCQ extension
Date: Thu, 5 Nov 2026 09:50:11 +0800	[thread overview]
Message-ID: <4e9bcddf-7dfe-b78f-035f-8a4b76584fdd@loongson.cn> (raw)
In-Reply-To: <20261104101753.20704-1-dongtai.guo@linux.dev>

On 11/4/26 6:17 PM, George Guo wrote:
> Hi Tiezhu,
> 
> On 2026/11/2 15:28, Tiezhu Yang wrote:
>> This is because the arena range tree uses kmalloc_nolock(), which requires
>> 128-bit atomic cmpxchg support, provided by SCQ extension on LoongArch.
> 
> There is an existing SLUB debug fallback worth checking before making
> arena support depend on SCQ.
> 
> In __kmalloc_nolock_noprof(), the rejection condition is:
> 
>          if (!(s->flags & __CMPXCHG_DOUBLE) && !kmem_cache_debug(s))
>                  return NULL;
> 
> Debug caches do not require cmpxchg128 for this path. They use
> kmem_cache_node->list_lock with spin_trylock_irqsave() instead.
> With CONFIG_SLUB_DEBUG=y, booting with slab_debug enables this path;
> CONFIG_SLUB_DEBUG_ON=y enables debugging by default as well.
> 
> The proposed bpf_jit_supports_arena() check would reject arena maps on
> CPUs without SCQ, even when the SLUB debug fallback is available.
> This would prevent us from running arena tests on those machines
> with slab_debug enabled.
> 
> Could you rerun jit_insns/cast_to_user on the 3A5000 with slab_debug
> enabled, before and after this patch? The claim that kmalloc_nolock()
> requires 128-bit cmpxchg should account for debug caches, and it would
> be useful to preserve that fallback when addressing the error reporting.

I noticed that a similar concern regarding the slub_debug exception
was previously raised by the CI bot in the RISC-V ZACAS patch:
https://lore.kernel.org/bpf/594ed4944926f6a7202b016eca03d879d11bfdf09a2cbaea039421ae4ab962c0@mail.kernel.org/

I highly agree with the bot's conclusion there:
 > "That narrowing is arguably desirable (BPF should not depend on a SLUB
 > debug-mode escape hatch)."

Moreover, handling this runtime debug mode inside the architecture's JIT
layer would inevitably introduce undesirable cross-module coupling with
SLUB internals. Restricting the JIT capability solely to native hardware
and toolchain support keeps the implementation clean and robust.

Thanks,
Tiezhu


  reply	other threads:[~2026-11-05  1:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  7:28 [PATCH v1 0/2] LoongArch: BPF: Fix arena and trampoline Tiezhu Yang
2026-11-02  7:28 ` [PATCH v1 1/2] LoongArch: BPF: Make arena support depend on SCQ extension Tiezhu Yang
2026-11-02 14:20   ` Huacai Chen
2026-11-03  2:24     ` Tiezhu Yang
2026-11-04  4:29       ` Huacai Chen
2026-11-04  6:58         ` Tiezhu Yang
2026-11-04  9:54           ` Huacai Chen
2026-11-04 13:06             ` Tiezhu Yang
2026-11-05  2:24               ` Tiezhu Yang
2026-11-04 10:17   ` George Guo
2026-11-05  1:50     ` Tiezhu Yang [this message]
2026-11-02  7:28 ` [PATCH v1 2/2] LoongArch: BPF: Use beqz and bnez instructions for trampoline Tiezhu Yang
2026-11-02  7:53   ` bot+bpf-ci
2026-11-03  2:27     ` Tiezhu Yang

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=4e9bcddf-7dfe-b78f-035f-8a4b76584fdd@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=bpf@vger.kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=dongtai.guo@linux.dev \
    --cc=hengqi.chen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    /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®