From mboxrd@z Thu Jan 1 00:00:00 1970 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 AF55DC433EF for ; Wed, 23 Mar 2022 11:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238105AbiCWLLO (ORCPT ); Wed, 23 Mar 2022 07:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbiCWLLM (ORCPT ); Wed, 23 Mar 2022 07:11:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0F5675C36 for ; Wed, 23 Mar 2022 04:09:42 -0700 (PDT) Date: Wed, 23 Mar 2022 12:09:40 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648033781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Y/9QlDKkQgJIDKLYV7PPTv1CBQEArmZvtFf+nq36eLQ=; b=VCuJqmw4XFfaZutmSwF5amYHYfC1m76r7PhRsHgIhfcogPDP8f2u9lZ5tWWME1oILrqTem ZmFvQHTQZaOKeckDMGLynD8NCTtNEyp2r35N1D2JmXDD6MbEy5AAmV7y80O60V0i1tLNd8 dn6z54ABxTkLUPa1aWX9aHdU7E1K1EuwwIWM8Yj1NrA4E5qehIUWv8Phat8O5L+p7s3U/O e5xWdHDo1H/rd5EOzLD0nx98rE/tVve/ppBAuhn/vlJsJ+zXPBTRxcxdAebmVODrGQXZW0 M8bt7Zb/vkXNgn7JypQszCOU1kXsZS/9vnZGL+NPp719rG0o2a1qYP4Djm2HSg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648033781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Y/9QlDKkQgJIDKLYV7PPTv1CBQEArmZvtFf+nq36eLQ=; b=f2flnjoxpv42V4Isvy48bFJS9P6bMY4ZORKXpweyTqNP3wGNq4aFPqqEyv53r+gZFS79gG ai5pyve9T6BsGEBA== From: Sebastian Andrzej Siewior To: Linus Torvalds Cc: Borislav Petkov , Ingo Molnar , Linux Kernel Mailing List , Peter Zijlstra , Will Deacon , Waiman Long , Boqun Feng , Thomas Gleixner , Andrew Morton Subject: [PATCH] locking/local_lock: Pretend to use the per-CPU variable if not needed. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the !RT && !LOCKDEP case the per-CPU variables aren't used. The commit mentioned below tried to avoid the usage of this_cpu_ptr() because it generates code, clobbers registers which is not needed. This change generated so little reference to the variable that llvm assumed that it is not used and created a warning. Revert local_lock_*() to its previous static inline implementation for type checking. Replace this_cpu_ptr() with __ll_cpu_ptr() which points to this_cpu_ptr() when it is used. In the !RT && !LOCKDEP case use per_cpu_ptr(, 0) which does not leave any code behind and llvm does not complain either. It also ensures that it is a per-CPU pointer. The assembly output in this case is unchanged. Fixes: 9983a9d577db4 ("locking/local_lock: Make the empty local_lock_*() function a macro.") Signed-off-by: Sebastian Andrzej Siewior --- include/linux/local_lock_internal.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock_internal.h index 6d635e8306d64..e671ead5fbad5 100644 --- a/include/linux/local_lock_internal.h +++ b/include/linux/local_lock_internal.h @@ -24,6 +24,8 @@ typedef struct { }, \ .owner = NULL, +#define __ll_cpu_ptr(__ll_cpuptr) (this_cpu_ptr(__ll_cpuptr)) + static inline void local_lock_acquire(local_lock_t *l) { lock_map_acquire(&l->dep_map); @@ -44,9 +46,10 @@ 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) +# define __ll_cpu_ptr(__ll_cpuptr) per_cpu_ptr(__ll_cpuptr, 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 */ #define INIT_LOCAL_LOCK(lockname) { LOCAL_LOCK_DEBUG_INIT(lockname) } @@ -65,36 +68,36 @@ do { \ #define __local_lock(lock) \ do { \ preempt_disable(); \ - local_lock_acquire(this_cpu_ptr(lock)); \ + local_lock_acquire(__ll_cpu_ptr(lock)); \ } while (0) #define __local_lock_irq(lock) \ do { \ local_irq_disable(); \ - local_lock_acquire(this_cpu_ptr(lock)); \ + local_lock_acquire(__ll_cpu_ptr(lock)); \ } while (0) #define __local_lock_irqsave(lock, flags) \ do { \ local_irq_save(flags); \ - local_lock_acquire(this_cpu_ptr(lock)); \ + local_lock_acquire(__ll_cpu_ptr(lock)); \ } while (0) #define __local_unlock(lock) \ do { \ - local_lock_release(this_cpu_ptr(lock)); \ + local_lock_release(__ll_cpu_ptr(lock)); \ preempt_enable(); \ } while (0) #define __local_unlock_irq(lock) \ do { \ - local_lock_release(this_cpu_ptr(lock)); \ + local_lock_release(__ll_cpu_ptr(lock)); \ local_irq_enable(); \ } while (0) #define __local_unlock_irqrestore(lock, flags) \ do { \ - local_lock_release(this_cpu_ptr(lock)); \ + local_lock_release(__ll_cpu_ptr(lock)); \ local_irq_restore(flags); \ } while (0) -- 2.35.1