From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B88337DE92 for ; Thu, 16 Apr 2026 14:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776350117; cv=none; b=BJU99FvzzcfXxAX5eHmJ8W0rAB/vdCrr7UZ/W3tSYkEX610Bqizc9txuvZGNF0ef9CCOQkAJ4JlLpDCX1IYWG1HPFxbe6CjO6SBsEkE0rtGDhPU+gaGfbZSWt/8a9zcL9Ynmtjq+sziPgpgQcvyrows3FEfeOHYPGiHaLNRfgpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776350117; c=relaxed/simple; bh=cogrMzgZEQxM7xPhwtdnRLBHYY01WZA4ogqqstyhGZk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Rm03FSkRCiitPTj/KAktmp99bfxqaeGwNGKgWtJH8ehMVZkrBHASKapLI8p/slkW6JyFGZaJwn27Q/I43qIQGxkb5UkashDdG+CGpvc4eRGPBitoCJEEmi+aKdeGg/CB4GTkk/XS3P5Yd1SheB9uvfxV6Iulwn04/5/Rsl/syck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IAEt9ZhW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IAEt9ZhW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B4F2C2BCAF; Thu, 16 Apr 2026 14:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776350116; bh=cogrMzgZEQxM7xPhwtdnRLBHYY01WZA4ogqqstyhGZk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IAEt9ZhW7IbIrs+qOCzY7b4TRDQln0yB06rerpru/HkeEmABN4EJA7eGnduu8N1Qx 66RmTLZwL6wiWz15bQUnOqTcH94svcNq9mSumPdoKZJdbMwgL7KdmK7iaAKnaZTCkb BNVHE/Mx7/eNy5llnau+nvky+W1GGUJPV3XfakxHM3q9UZqAVDdA/a9HAA9KfmHkJZ 8zJefhxu7ohSv/ZXzX2BRq3RXRuWnZZrBDVOAZF6JRbrA1DuKTM15SW9T2JGmQF1Ti g+FAD8z6yi5tIafKKCbmCxOgNUEKB8Ue08j/XSSghXGDuPXC+9rD63PKXOaRLe8j5H N6dzSUjkzHmFg== Date: Thu, 16 Apr 2026 23:35:14 +0900 From: "Harry Yoo (Oracle)" To: Alexei Starovoitov Cc: "Vlastimil Babka (SUSE)" , Matthew Wilcox , Vlastimil Babka , Peter Zijlstra , Ingo Molnar , Will Deacon , Sebastian Andrzej Siewior , LKML , "linux-mm@kvack.org" , Linus Torvalds , Waiman Long , Mel Gorman , Steven Rostedt , Hao Li , Andrew Morton , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Christoph Lameter , David Rientjes , Roman Gushchin Subject: Re: [RFC] making nested spin_trylock() work on UP? Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Apr 16, 2026 at 07:26:36AM -0700, Alexei Starovoitov wrote: > On Thu Apr 16, 2026 at 3:05 AM PDT, Vlastimil Babka (SUSE) wrote: > >> I think we need a special spinlock type that wraps something like this > >> and use them when spinlocks can be trylock'd in an unknown context: > >> pcp lock, zone lock, per-node partial slab list lock, > >> per-node barn lock, etc. > > > > Soudns like a lot of hassle for a niche config (SMP=n) where nobody would > > use e.g. bpf tracing anyway. We already have this in kmalloc_nolock(): > > > > /* > > * See the comment for the same check in > > * alloc_frozen_pages_nolock_noprof() > > */ > > if (IS_ENABLED(CONFIG_PREEMPT_RT) && (in_nmi() || in_hardirq())) > > return NULL; > > > > It would be trivial to extend this to !SMP. However it wouldn't cover the > > kprobe context. Any idea Alexei? I think Vlastimil meant it'd be trivial to do: if ((IS_ENABLED(CONFIG_PREEMPT_RT) || !IS_ENABLED(CONFIG_SMP)) && (in_nmi() || in_hardirq())) return NULL; But it doesn't cover the case where kprobe hooks an arbitrary function (in the middle of kmalloc() or kfree()) and calls kmalloc_nolock()? > Yeah. Totally fine with that. So I'm confused exactly what you're fine with. Did you mean this? if (!IS_ENABLED(CONFIG_SMP) || (IS_ENABLED(CONFIG_PREEMPT_RT) && (in_nmi() || in_hardirq()))) return NULL; Or am I missing something? -- Cheers, Harry / Hyeonggon