From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 288CC353A74 for ; Mon, 13 Jul 2026 21:41:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783978867; cv=none; b=f9SlC7jL96Lx/q3tZcBKOYONdZIXYuEBSdaT37+j+l2G9hR2CMjIVE1EnK7jzyBdli4UeRR7Jayh3F7G9XlLknZ3oUNJBYuPEwU9Nr0OwR4a5BvnDZ7tdj0/TVMEcfPMBUpXvTvW6Z8zJhvcGd1tlB88ICG1o7mxmlrTH5OLKuw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783978867; c=relaxed/simple; bh=SVMywLRbIFXVQzPixM0IKsUfpey0KwU4tI6WH0yTSZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=EInCroFtIsJd8qqN5SIxx4oljwWPMUD+5Rsd4WypBfcpIUdQ/wkMinVzVj6cLHZkurkZNEXHc7sLaHtVLrE+5/Zs8t/lTm8vF9Et135Ir0Vo0/TezIEJhjytamBNJ4ZLqGkXe+LFXH4Ibc4ZnbYMS7ME6qU36M2wVjDqGH4xMRk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rUOev3u5; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rUOev3u5" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-493ece78b0cso26822465e9.0 for ; Mon, 13 Jul 2026 14:41:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783978864; x=1784583664; darn=vger.kernel.org; h=content-transfer-encoding:content-disposition:content-type :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=kBTvf+Z85P+YG7179a/IzMuusmQi/QF8ZEk+OKIxHQ8=; b=rUOev3u5sqq6ntZvKlT0xQcJirUIn+jt6GHolSh991C62w5fNtatBhIrImoRORxWTm B093d40ip/uH0opeJZA9RudYhBpSLSdiaM0EG3uu0gvUEPX3LM9/D1fxDmQbf8FMEtlI ROMFaUchBRcUsAzfnkK3Xlz42C2+v859vZgCKQLtmBgW0xO856G3c+Wr4ZOFjV4IKvZn Oj5Ley3NalMryuQJ1gaS6oPnjahYdZry6AlCCE5zeXJV1i0PKAGHvtz0mk2kWyTV10iu CbpMdaWcrWCuxxqWmmzsxv6XP3LUEbh6suvUXzrGDk8jsytoJGZlNje4xUaUldLAwaze O1BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783978864; x=1784583664; h=content-transfer-encoding:content-disposition:content-type :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=kBTvf+Z85P+YG7179a/IzMuusmQi/QF8ZEk+OKIxHQ8=; b=X+Rq7qoKBOABuqK9VGqhTXOjZlSDzNTARTLWVlXKhkRhxUq6M2uJ8gUI0Hn8sWrFic OvLH28HbGsnLkqEh7v5ohRYGjIMLEMoNeLThnFtllMU25ROiPt4DkcwykWIggASJObIc j0r9UEIpm3fIaJ5SvvrBjsaHI2DOVaRwoOka1IYHMBYHc9/ESMahfMEMEK6Nl78g9r41 eJmyASW1/HoWHZO1JKUrM9n2nKOIi+/e0FI9m6apYHotiUbGUz/DaprMbPIDCHo7idBy 3NW6+om7MxBGL53njPYiyCO96xFJm/zNACg4+c6ZeYLF/TuDRsVpZ19Nd5E+m8/peWZ1 Pr4A== X-Forwarded-Encrypted: i=1; AHgh+RqYl2fZWozK76PeUpghQz6SLha0SHxb8LooPqYGMG1hW8FWBr6oXF837YFZAHnvlen2bkz0sRi1XlSgp/o=@vger.kernel.org X-Gm-Message-State: AOJu0YyimI3Cao6IMExj1B8nM4/b+UIyIo655N963fZ8GdQWfxD31ncC g820aL+6r8x309rVIKo9S3f3nOEdySMeRyM1Mg53OnglNf0C2Vfu/Nq3 X-Gm-Gg: AfdE7cnQzlud5vwwyRqXSk0ejzrHg2tqsb8POmhbUfOERQWomL82RKoMxNHQCL6jbuH ghnQUYkMeGSus/0BIbexWETFULriBe4/7+jeI1rBWwR1RMlT8KLxVjIEEH0fbiJ4PhIhuevYrN/ DM5ySEwCtLJlJsD1h1baKB9YgXTVEREmg4rIKyaamjnS8t1NUpXw1AScEl4i0EAckeBhQKxPKBT APHOUK1zHRMZrxbCp1/bMcoVuEYD9SvBWp9+yK9+Hw9/Zs7aFUV3HNuG5SG4/AjawIGQ2FwZAy0 Uez3OI/2AStWXSvoK1x1DM9xVd7vkPCaM3M/FbwiVoADW8DejueQ0Ig7eLnUxrlPjbg8rfwoU+e I3DWBEtDspt2K2cMtnWQElbvSXXTM04j/VuXhJWaPajLAoxr6oE/pJaJY0NmJFaTGS/DZuiLXJ0 rUmwO7fvtzBkFsCtSAnv1kww== X-Received: by 2002:a05:600c:1908:b0:492:3e66:6c84 with SMTP id 5b1f17b1804b1-4951830e089mr11315545e9.30.1783978864353; Mon, 13 Jul 2026 14:41:04 -0700 (PDT) Received: from WindFlash.powerhub ([2a0a:ef40:f61:3b01:d08a:833b:756:8fce]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-495087384casm23602415e9.8.2026.07.13.14.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 14:41:03 -0700 (PDT) From: Leonardo Bras To: Sebastian Andrzej Siewior Cc: Leonardo Bras , Jonathan Corbet , Shuah Khan , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , Brendan Jackman , Johannes Weiner , Zi Yan , Harry Yoo , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , Qi Zheng , Shakeel Butt , Axel Rasmussen , Yuanchu Xie , Wei Xu , "Borislav Petkov (AMD)" , Randy Dunlap , Feng Tang , Dapeng Mi , Kees Cook , Marco Elver , Jakub Kicinski , Li RongQing , Eric Biggers , "Paul E. McKenney" , Nathan Chancellor , Nicolas Schier , Miguel Ojeda , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Thomas Gleixner , Douglas Anderson , Gary Guo , Christian Brauner , Pasha Tatashin , Coiby Xu , Masahiro Yamada , Frederic Weisbecker , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rt-devel@lists.linux.dev, Marcelo Tosatti Subject: Re: [PATCH v4 4/4] slub: apply new pw_queue_on() interface Date: Mon, 13 Jul 2026 18:40:57 -0300 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260713073634.3Hrxpfcx@linutronix.de> References: <20260519012754.240804-1-leobras.c@gmail.com> <20260519012754.240804-5-leobras.c@gmail.com> <20260520145308.nay9zt6r@linutronix.de> <20260713073634.3Hrxpfcx@linutronix.de> 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 Content-Transfer-Encoding: 8bit On Mon, Jul 13, 2026 at 09:36:34AM +0200, Sebastian Andrzej Siewior wrote: > On 2026-07-12 19:35:28 [-0300], Leonardo Bras wrote: > > On Wed, May 20, 2026 at 04:53:08PM +0200, Sebastian Andrzej Siewior wrote: > > > On 2026-05-18 22:27:50 [-0300], Leonardo Bras wrote: > > > > @@ -4733,121 +4735,121 @@ void *alloc_from_pcs(struct kmem_cache *s, gfp_t gfp, int node) > > > > > > > > /* > > > > * We assume the percpu sheaves contain only local objects although it's > > > > * not completely guaranteed, so we verify later. > > > > */ > > > > if (unlikely(node_requested && node != numa_mem_id())) { > > > > stat(s, ALLOC_NODE_MISMATCH); > > > > return NULL; > > > > } > > > > > > > > - if (!local_trylock(&s->cpu_sheaves->lock)) > > > > + if (!pw_trylock_local(&s->cpu_sheaves->lock)) > > > > return NULL; > > > > > > alloc_from_pcs() can be called from kmalloc_nolock()/ NMI context. > > > I don't remember why exactly local_trylock_t was introduced here instead > > > of a per-CPU spinlock_t. > > > > Probably to save the cost of using atomic operations on locking, and having > > about the same restrictions that would allow using local_locks > > > > > But there should be nothing wrong with a > > > trylock on it from NMI as you do here. > > > > Awesome! > > The problem is always the unlock which requires full locking and is > usually the problem from NMI. > You mean, like, the trylock succeeds in the NMI handle, does the per-cpu operations, and then unlock()s? Or by full locking you mean local_lock() instead of local_trylock() ? > > > > > > One thing worth noting, on !PREEMPT_RT, spin_trylock() always succeeds > > > on UP. kmalloc_nolock() checks for it, not sure about other callers. > > > > > > Sorry, I did not sure I understand that part. > > You mean we have since it always returns true, we may be in NMI context, > > after it was interrupted holding this lock, and it will return true which > > will use the protected area even though the lock should avoid it? > > from include/linux/spinlock_api_up.h: > | static __always_inline int _raw_spin_trylock(raw_spinlock_t *lock) > | __cond_acquires(true, lock) > | { > | __LOCK(lock); > | return 1; > | } > > on UP a spin_trylock() always succeeds. > Right, I got that part, I was wondering the scenarios in which would that be an issue. Thanks! Leo