From nobody Sat Jun 20 00:56:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4271CC433EF for ; Thu, 24 Mar 2022 17:39:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352333AbiCXRlR (ORCPT ); Thu, 24 Mar 2022 13:41:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239345AbiCXRlP (ORCPT ); Thu, 24 Mar 2022 13:41:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D1D891572 for ; Thu, 24 Mar 2022 10:39:43 -0700 (PDT) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648143581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4KQxr5oJ0K8+nt7jNJuq4MVZPPDUKGy53NQZ0DdOjis=; b=X00bF5WRAfgXO35kUZA7+Mynd7cc4jHPhjP4rTt4cVkOjUQ4wgfVd2xw06a+JFOWBfjjM9 sg6g+iiJNpWCWk2lCRgeKijKX8hwpgSSNjsbCuzefHbJPTwVcHvr/2FGYtVLlmIEg0TCQT 9C2/g5YhMj/TKiniNpwvPFKkPTNHPzvdyI74OJV/nZh03nez1IBZRXwGdXtvYKYsSWjgnf zboHXqwvGUc4YezjNsHRIV/U49RfYq7kBOW6u4fZvy7u6UyUWcmsUl0XkZ96t38p6XYvcJ fVQotLId6F67KhrCgbBf+JONquPHO1fqzeBph5rrfayhIORSamojKmlfSMBcfw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648143581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4KQxr5oJ0K8+nt7jNJuq4MVZPPDUKGy53NQZ0DdOjis=; b=yn0/gUbocPgO65/CVGQlTEPNDplx1MznixwfsgIgjHC0y1vC3GGSUc8sfHfRLfT2r3RXZh xbC/ZTzrsCi1teAg== To: torvalds@linux-foundation.org Cc: akpm@linux-foundation.org, bigeasy@linutronix.de, boqun.feng@gmail.com, bp@alien8.de, linux-kernel@vger.kernel.org, longman@redhat.com, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, will@kernel.org, Dennis Zhou , Tejun Heo , Christoph Lameter Subject: [PATCH 1/3] x86/percpu: Remove volatile from arch_raw_cpu_ptr(). Date: Thu, 24 Mar 2022 18:39:25 +0100 Message-Id: <20220324173927.2230447-2-bigeasy@linutronix.de> In-Reply-To: <20220324173927.2230447-1-bigeasy@linutronix.de> References: <20220324173927.2230447-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The volatile attribute in the inline assembly of arch_raw_cpu_ptr() forces the compiler to always generate the code, even if the compiler can decide upfront that its result is not needed. For instance invoking __intel_pmu_disable_all(false) (like intel_pmu_snapshot_arch_branch_stack() does) leads to loading the address of &cpu_hw_events into the register while compiler knows that it has no need for it. This ends up with code like: | movq $cpu_hw_events, %rax #, tcp_ptr__ | add %gs:this_cpu_off(%rip), %rax # this_cpu_off, tcp_ptr__ | xorl %eax, %eax # tmp93 It also creates additional code within local_lock() with !RT && !LOCKDEP which is not desired. By removing the volatile attribute the compiler can place the function freely and avoid it if it is not needed in the end. By using the function twice the compiler properly caches only the variable offset and always loads the CPU-offset. Remove volatile from arch_raw_cpu_ptr(). Suggested-by: Linus Torvalds Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/include/asm/percpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index a3c33b79fb865..5d572a19a389c 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -38,7 +38,7 @@ #define arch_raw_cpu_ptr(ptr) \ ({ \ unsigned long tcp_ptr__; \ - asm volatile("add " __percpu_arg(1) ", %0" \ + asm ("add " __percpu_arg(1) ", %0" \ : "=3Dr" (tcp_ptr__) \ : "m" (this_cpu_off), "0" (ptr)); \ (typeof(*(ptr)) __kernel __force *)tcp_ptr__; \ --=20 2.35.1 From nobody Sat Jun 20 00:56:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B172C433EF for ; Thu, 24 Mar 2022 17:39:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352344AbiCXRlT (ORCPT ); Thu, 24 Mar 2022 13:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352325AbiCXRlQ (ORCPT ); Thu, 24 Mar 2022 13:41:16 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 608AA91AF4 for ; Thu, 24 Mar 2022 10:39:44 -0700 (PDT) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648143582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G2K1bd9HAywoNYrUHng0l9se10lIg8eInYuxNMOXcG4=; b=IG+Jsu6xJoPNea+9yEPMBFIoYU5UwvP5LwmJY+sO8P4uAGj2JWW0GZ9eTvfrP5puQT4DWR yjO/IC3R+XtrOMF3naF6IdNtluZHjNuAZeGQsBzkcU5GW9MeEAmlj3P3rtpL2lFBReFm6F zg4sidf3kSc4rcwDHAARj//bneagHVRhN+cH+GrCpjkPCtHFYfQy447lnn2oAEvWwf0JbZ wFZjAkuYinpwuxKsgi4haMTUfyoDOSxv4Gz+Jt5jCVI+4q5bFzyO/cLr9Qrrq1+COXWXDX emTxgpTOiICqg0gOd7pboKoex2SDiua39Q/ryt2krD+IhjUFisvIU0KZEclezA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648143582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G2K1bd9HAywoNYrUHng0l9se10lIg8eInYuxNMOXcG4=; b=ScpZeZ4n6mXN+Srm59nk50TSTHLHjzLgc+gXeSO/vZplZ/UWoB9cZ6kx09KKFWxqkdr4jl Wum0MFgxtRK/fYBA== To: torvalds@linux-foundation.org Cc: akpm@linux-foundation.org, bigeasy@linutronix.de, boqun.feng@gmail.com, bp@alien8.de, linux-kernel@vger.kernel.org, longman@redhat.com, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, will@kernel.org, Dennis Zhou , Tejun Heo , Christoph Lameter Subject: [PATCH 2/3] Revert "locking/local_lock: Make the empty local_lock_*() function a macro." Date: Thu, 24 Mar 2022 18:39:26 +0100 Message-Id: <20220324173927.2230447-3-bigeasy@linutronix.de> In-Reply-To: <20220324173927.2230447-1-bigeasy@linutronix.de> References: <20220324173927.2230447-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With volatile removed from arch_raw_cpu_ptr() the compiler no longer creates the per-CPU reference. The usage of the macro can be reverted now. Signed-off-by: Sebastian Andrzej Siewior --- include/linux/local_lock_internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock= _internal.h index 6d635e8306d64..975e33b793a77 100644 --- a/include/linux/local_lock_internal.h +++ b/include/linux/local_lock_internal.h @@ -44,9 +44,9 @@ static inline void local_lock_debug_init(local_lock_t *l) } #else /* CONFIG_DEBUG_LOCK_ALLOC */ # define LOCAL_LOCK_DEBUG_INIT(lockname) -# define local_lock_acquire(__ll) do { typecheck(local_lock_t *, __ll); }= while (0) -# define local_lock_release(__ll) do { typecheck(local_lock_t *, __ll); }= while (0) -# define local_lock_debug_init(__ll) do { typecheck(local_lock_t *, __ll)= ; } while (0) +static inline void local_lock_acquire(local_lock_t *l) { } +static inline void local_lock_release(local_lock_t *l) { } +static inline void local_lock_debug_init(local_lock_t *l) { } #endif /* !CONFIG_DEBUG_LOCK_ALLOC */ =20 #define INIT_LOCAL_LOCK(lockname) { LOCAL_LOCK_DEBUG_INIT(lockname) } --=20 2.35.1 From nobody Sat Jun 20 00:56:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C401C433F5 for ; Thu, 24 Mar 2022 17:39:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352354AbiCXRlX (ORCPT ); Thu, 24 Mar 2022 13:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352327AbiCXRlR (ORCPT ); Thu, 24 Mar 2022 13:41:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53EDC887A4 for ; Thu, 24 Mar 2022 10:39:45 -0700 (PDT) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648143584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sqozYXnqHX0EsWoXfQvZzN68iU7pMU+FQPHZRVNv12s=; b=K17dgMFuo4ar6ml8TOh8B80I5sifIsv3CQ1mJLO28r4DPnuGPskL1FhoBA2+uyjta5Y3TN CVS6kIoWlz8TuGCO0bnbsKUbVadvacN6Bn4s4KBZ/wdanhYtlGH/YKiEjMVNn++9VZap6q Sp/IdjRf+P0sg4xtnNMkLSI3FgSo6aG+FVtPOb5fS2ziLHwq2HuWBDrU5/FtYxuD4cCTgr 8Ak52Iie6xJ6hkQupYDIyCoLjnw3fU3MdTWDRjFVM8TjrIdXz01l678Hd5Sf8KvgHx4GPc zECXuwngRdgaBm5UYpFub1rsTVH0jdWFolFEzmq2SBO6UE/LliwI+CQG25UhDQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648143584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sqozYXnqHX0EsWoXfQvZzN68iU7pMU+FQPHZRVNv12s=; b=hHpUYOYHXRjOHhW6btjl3H7cLf8hnEg1m6mErJ9CGZc7xba4x2VO4VyYn19tm+JfOW6fcf 9LM6RCr25g3I0sDA== To: torvalds@linux-foundation.org Cc: akpm@linux-foundation.org, bigeasy@linutronix.de, boqun.feng@gmail.com, bp@alien8.de, linux-kernel@vger.kernel.org, longman@redhat.com, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, will@kernel.org, Dennis Zhou , Tejun Heo , Christoph Lameter Subject: [PATCH 3/3] Revert "mm/page_alloc: mark pagesets as __maybe_unused" Date: Thu, 24 Mar 2022 18:39:27 +0100 Message-Id: <20220324173927.2230447-4-bigeasy@linutronix.de> In-Reply-To: <20220324173927.2230447-1-bigeasy@linutronix.de> References: <20220324173927.2230447-1-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The local_lock() is now using a proper static inline function which is enough for llvm to accept that the variable is used. Signed-off-by: Sebastian Andrzej Siewior --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6e0b4596cde9b..8f83e9929c7d2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -128,7 +128,7 @@ static DEFINE_MUTEX(pcp_batch_high_lock); struct pagesets { local_lock_t lock; }; -static DEFINE_PER_CPU(struct pagesets, pagesets) __maybe_unused =3D { +static DEFINE_PER_CPU(struct pagesets, pagesets) =3D { .lock =3D INIT_LOCAL_LOCK(lock), }; =20 --=20 2.35.1