Skip to contentSkip to conversation

sched: fix an unused function "node_cpu" warning

PATCH Applied Qian Cai 3 participants 3 messages Sep 17, 2019 – Sep 18, 2019 Scheduler

lore
Share & tools
lore

Qian Cai

author
#0 lore raw

PATCH 1/1 sched: fix an unused function "node_cpu" warning

Clang reports a warning,

kernel/locking/osq_lock.c:25:19: warning: unused function 'node_cpu' [-Wunused-function]

due to osq_lock() calls vcpu_is_preempted(node_cpu(node->prev))), but vcpu_is_preempted() is compiled away. Fix it by converting the dummy vcpu_is_preempted() from a macro to a proper static inline function.

---
 include/linux/sched.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/sched.h +4 -1
index f0edee94834a..e2e91960d79f 100644
@@ -1856,7 +1856,10 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
  * running or not.
  */
 #ifndef vcpu_is_preempted
-# define vcpu_is_preempted(cpu)	false
+static inline bool vcpu_is_preempted(int cpu)
+{
+	return false;
+}
 #endif
 
 extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);
Signature · 1 line
1.8.3.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Qian Cai

Clang reports a warning,

kernel/locking/osq_lock.c:25:19: warning: unused function 'node_cpu' [-Wunused-function]

due to osq_lock() calls vcpu_is_preempted(node_cpu(node->prev))), but vcpu_is_preempted() is compiled away. Fix it by converting the dummy vcpu_is_preempted() from a macro to a proper static inline function.

Signature · 2 lines
Mel Gorman
SUSE Labs
merge bot Applied
#2 lore raw

[tip: sched/urgent] sched/core: Convert vcpu_is_preempted() from macro to an inline function

In reply to Qian Cai
The following commit has been merged into the sched/urgent branch of tip:

The following commit has been merged into the sched/urgent branch of tip:

Commit-ID:     42fd8baab31f53bed2952485fcf0e92f244c5e55
Gitweb:        https://git.kernel.org/tip/42fd8baab31f53bed2952485fcf0e92f244c5e55
Author:        Qian Cai <[email protected]>
AuthorDate:    Tue, 17 Sep 2019 10:34:54 -04:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 18 Sep 2019 12:38:17 +02:00

sched/core: Convert vcpu_is_preempted() from macro to an inline function

Clang reports this warning:

kernel/locking/osq_lock.c:25:19: warning: unused function 'node_cpu' [-Wunused-function]

due to osq_lock() calling vcpu_is_preempted(node_cpu(node->prev))), but vcpu_is_preempted() is compiled away. Fix it by converting the dummy vcpu_is_preempted() from a macro to a proper static inline function.

---
 include/linux/sched.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/sched.h +4 -1
index f0edee9..e2e9196 100644
@@ -1856,7 +1856,10 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
  * running or not.
  */
 #ifndef vcpu_is_preempted
-# define vcpu_is_preempted(cpu)	false
+static inline bool vcpu_is_preempted(int cpu)
+{
+	return false;
+}
 #endif
 
 extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask);