linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] arm64/spinlock: fix a -Wunused-function warning
@ 2020-01-23 16:29 Qian Cai
  2020-01-23 16:56 ` Will Deacon
  2020-01-23 17:11 ` Waiman Long
  0 siblings, 2 replies; 6+ messages in thread
From: Qian Cai @ 2020-01-23 16:29 UTC (permalink / raw)
  To: peterz
  Cc: catalin.marinas, linux-kernel, clang-built-linux, mingo,
	Qian Cai, longman, will, linux-arm-kernel

The commit f5bfdc8e3947 ("locking/osq: Use optimized spinning loop for
arm64") introduced a warning from Clang because vcpu_is_preempted() is
compiled away,

kernel/locking/osq_lock.c:25:19: warning: unused function 'node_cpu'
[-Wunused-function]
static inline int node_cpu(struct optimistic_spin_node *node)
                  ^
1 warning generated.

Since vcpu_is_preempted() had already been defined in
include/linux/sched.h as false, just comment out the redundant macro, so
it can still be served for the documentation purpose.

Fixes: f5bfdc8e3947 ("locking/osq: Use optimized spinning loop for arm64")
Signed-off-by: Qian Cai <cai@lca.pw>
---
 arch/arm64/include/asm/spinlock.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h
index 102404dc1e13..b05f82e8ba19 100644
--- a/arch/arm64/include/asm/spinlock.h
+++ b/arch/arm64/include/asm/spinlock.h
@@ -17,7 +17,8 @@
  *
  * See:
  * https://lore.kernel.org/lkml/20200110100612.GC2827@hirez.programming.kicks-ass.net
+ *
+ * #define vcpu_is_preempted(cpu)	false
  */
-#define vcpu_is_preempted(cpu)	false
 
 #endif /* __ASM_SPINLOCK_H */
-- 
2.21.0 (Apple Git-122.2)


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] arm64/spinlock: fix a -Wunused-function warning
  2020-01-23 16:29 [PATCH -next] arm64/spinlock: fix a -Wunused-function warning Qian Cai
@ 2020-01-23 16:56 ` Will Deacon
  2020-01-23 17:23   ` Qian Cai
  2020-01-23 17:31   ` Qian Cai
  2020-01-23 17:11 ` Waiman Long
  1 sibling, 2 replies; 6+ messages in thread
From: Will Deacon @ 2020-01-23 16:56 UTC (permalink / raw)
  To: Qian Cai
  Cc: peterz, catalin.marinas, linux-kernel, clang-built-linux, mingo,
	longman, linux-arm-kernel

On Thu, Jan 23, 2020 at 11:29:45AM -0500, Qian Cai wrote:
> The commit f5bfdc8e3947 ("locking/osq: Use optimized spinning loop for
> arm64") introduced a warning from Clang because vcpu_is_preempted() is
> compiled away,
> 
> kernel/locking/osq_lock.c:25:19: warning: unused function 'node_cpu'
> [-Wunused-function]
> static inline int node_cpu(struct optimistic_spin_node *node)
>                   ^
> 1 warning generated.
> 
> Since vcpu_is_preempted() had already been defined in
> include/linux/sched.h as false, just comment out the redundant macro, so
> it can still be served for the documentation purpose.
> 
> Fixes: f5bfdc8e3947 ("locking/osq: Use optimized spinning loop for arm64")
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  arch/arm64/include/asm/spinlock.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h
> index 102404dc1e13..b05f82e8ba19 100644
> --- a/arch/arm64/include/asm/spinlock.h
> +++ b/arch/arm64/include/asm/spinlock.h
> @@ -17,7 +17,8 @@
>   *
>   * See:
>   * https://lore.kernel.org/lkml/20200110100612.GC2827@hirez.programming.kicks-ass.net
> + *
> + * #define vcpu_is_preempted(cpu)	false
>   */
> -#define vcpu_is_preempted(cpu)	false

Damn, the whole point of this was to warn in the case that
vcpu_is_preempted() does get defined for arm64. Can we force it to evaluate
the macro argument instead (e.g. ({ (cpu), false; }) or something)?

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] arm64/spinlock: fix a -Wunused-function warning
  2020-01-23 16:29 [PATCH -next] arm64/spinlock: fix a -Wunused-function warning Qian Cai
  2020-01-23 16:56 ` Will Deacon
@ 2020-01-23 17:11 ` Waiman Long
  1 sibling, 0 replies; 6+ messages in thread
From: Waiman Long @ 2020-01-23 17:11 UTC (permalink / raw)
  To: Qian Cai, peterz
  Cc: catalin.marinas, linux-kernel, clang-built-linux, mingo, will,
	linux-arm-kernel

On 1/23/20 11:29 AM, Qian Cai wrote:
> The commit f5bfdc8e3947 ("locking/osq: Use optimized spinning loop for
> arm64") introduced a warning from Clang because vcpu_is_preempted() is
> compiled away,
>
> kernel/locking/osq_lock.c:25:19: warning: unused function 'node_cpu'
> [-Wunused-function]
> static inline int node_cpu(struct optimistic_spin_node *node)
>                   ^
> 1 warning generated.
>
> Since vcpu_is_preempted() had already been defined in
> include/linux/sched.h as false, just comment out the redundant macro, so
> it can still be served for the documentation purpose.
>
> Fixes: f5bfdc8e3947 ("locking/osq: Use optimized spinning loop for arm64")
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  arch/arm64/include/asm/spinlock.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h
> index 102404dc1e13..b05f82e8ba19 100644
> --- a/arch/arm64/include/asm/spinlock.h
> +++ b/arch/arm64/include/asm/spinlock.h
> @@ -17,7 +17,8 @@
>   *
>   * See:
>   * https://lore.kernel.org/lkml/20200110100612.GC2827@hirez.programming.kicks-ass.net
> + *
> + * #define vcpu_is_preempted(cpu)	false
>   */
> -#define vcpu_is_preempted(cpu)	false
>  
>  #endif /* __ASM_SPINLOCK_H */

Does adding a __maybe_unused tag help to prevent the warning? Like

diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c
index 6ef600aa0f47..0722655af34f 100644
--- a/kernel/locking/osq_lock.c
+++ b/kernel/locking/osq_lock.c
@@ -22,7 +22,7 @@ static inline int encode_cpu(int cpu_nr)
        return cpu_nr + 1;
 }
 
-static inline int node_cpu(struct optimistic_spin_node *node)
+static inline int __maybe_unused node_cpu(struct optimistic_spin_node
*node)
 {
        return node->cpu - 1;
 }

Cheers,
Longman


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] arm64/spinlock: fix a -Wunused-function warning
  2020-01-23 16:56 ` Will Deacon
@ 2020-01-23 17:23   ` Qian Cai
  2020-01-23 17:31   ` Qian Cai
  1 sibling, 0 replies; 6+ messages in thread
From: Qian Cai @ 2020-01-23 17:23 UTC (permalink / raw)
  To: Will Deacon
  Cc: peterz, catalin.marinas, linux-kernel, clang-built-linux, mingo,
	longman, linux-arm-kernel



> On Jan 23, 2020, at 11:56 AM, Will Deacon <will@kernel.org> wrote:
> 
> Damn, the whole point of this was to warn in the case that
> vcpu_is_preempted() does get defined for arm64. Can we force it to evaluate
> the macro argument instead (e.g. ({ (cpu), false; }) or something)?

That should work. Let me test it out and rinse.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] arm64/spinlock: fix a -Wunused-function warning
  2020-01-23 16:56 ` Will Deacon
  2020-01-23 17:23   ` Qian Cai
@ 2020-01-23 17:31   ` Qian Cai
  2020-01-23 17:36     ` Waiman Long
  1 sibling, 1 reply; 6+ messages in thread
From: Qian Cai @ 2020-01-23 17:31 UTC (permalink / raw)
  To: Will Deacon
  Cc: peterz, catalin.marinas, linux-kernel, clang-built-linux, mingo,
	longman, linux-arm-kernel



> On Jan 23, 2020, at 11:56 AM, Will Deacon <will@kernel.org> wrote:
> 
> Damn, the whole point of this was to warn in the case that
> vcpu_is_preempted() does get defined for arm64. Can we force it to evaluate
> the macro argument instead (e.g. ({ (cpu), false; }) or something)?

Actually, static inline should be better.

#define vcpu_is_preempted vcpu_is_preempted
static inline bool vcpu_is_preempted(int cpu)
{
	return false;
}

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] arm64/spinlock: fix a -Wunused-function warning
  2020-01-23 17:31   ` Qian Cai
@ 2020-01-23 17:36     ` Waiman Long
  0 siblings, 0 replies; 6+ messages in thread
From: Waiman Long @ 2020-01-23 17:36 UTC (permalink / raw)
  To: Qian Cai, Will Deacon
  Cc: peterz, catalin.marinas, linux-kernel, clang-built-linux, mingo,
	linux-arm-kernel

On 1/23/20 12:31 PM, Qian Cai wrote:
>
>> On Jan 23, 2020, at 11:56 AM, Will Deacon <will@kernel.org> wrote:
>>
>> Damn, the whole point of this was to warn in the case that
>> vcpu_is_preempted() does get defined for arm64. Can we force it to evaluate
>> the macro argument instead (e.g. ({ (cpu), false; }) or something)?
> Actually, static inline should be better.
>
> #define vcpu_is_preempted vcpu_is_preempted
> static inline bool vcpu_is_preempted(int cpu)
> {
> 	return false;
> }
>
Yes, that may work.

Cheers,
Longman


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-23 17:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-23 16:29 [PATCH -next] arm64/spinlock: fix a -Wunused-function warning Qian Cai
2020-01-23 16:56 ` Will Deacon
2020-01-23 17:23   ` Qian Cai
2020-01-23 17:31   ` Qian Cai
2020-01-23 17:36     ` Waiman Long
2020-01-23 17:11 ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).