2012-10-05 19:50:14

by Fabio Estevam

[permalink] [raw]
Subject: [PATCH 1/2] sched: fair: Fix 'defined but not used' warning

commit 4ae834f767 (sched/numa: Implement NUMA home-node selection code)
caused the following warning on a !CONFIG_SMP system:

kernel/sched/fair.c:1013:13: warning: 'account_offnode_enqueue' defined but not used [-Wunused-function]

Since account_offnode_enqueue() is only used in a path that requires CONFIG_SMP
to be enabled, make its definition dependent on CONFIG_SMP.

Signed-off-by: Fabio Estevam <[email protected]>
---
kernel/sched/fair.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f586f17..b75a336 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -801,12 +801,14 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
static unsigned long task_h_load(struct task_struct *p);

#ifdef CONFIG_SCHED_NUMA
+#ifdef CONFIG_SMP
static void account_offnode_enqueue(struct rq *rq, struct task_struct *p)
{
p->numa_contrib = task_h_load(p);
rq->offnode_weight += p->numa_contrib;
rq->offnode_running++;
}
+#endif /* CONFIG_SMP */

static void account_offnode_dequeue(struct rq *rq, struct task_struct *p)
{
@@ -1010,9 +1012,11 @@ void task_tick_numa(struct rq *rq, struct task_struct *curr)
}
}
#else
+#ifdef CONFIG_SMP
static void account_offnode_enqueue(struct rq *rq, struct task_struct *p)
{
}
+#endif /* CONFIG_SMP */

static void account_offnode_dequeue(struct rq *rq, struct task_struct *p)
{
--
1.7.9.5


2012-10-05 19:50:18

by Fabio Estevam

[permalink] [raw]
Subject: [PATCH 2/2] sched: fair: Fix "declared 'static' but never defined" warning

commit 4ae834f767 (sched/numa: Implement NUMA home-node selection code)
caused the following warning on a !CONFIG_SMP system:

kernel/sched/fair.c:801:22: warning: 'task_h_load' declared 'static' but never defined [-Wunused-function]

Instead of doing the forward declaration of task_h_load(), declare it sooner to avoid
the warning in the !CONFIG_SMP case.

Signed-off-by: Fabio Estevam <[email protected]>
---
kernel/sched/fair.c | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b75a336..d57b5fd 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -798,7 +798,25 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
* information we have.
*/

-static unsigned long task_h_load(struct task_struct *p);
+#ifdef CONFIG_SMP
+#ifdef CONFIG_FAIR_GROUP_SCHED
+static unsigned long task_h_load(struct task_struct *p)
+{
+ struct cfs_rq *cfs_rq = task_cfs_rq(p);
+ unsigned long load;
+
+ load = p->se.load.weight;
+ load = div_u64(load * cfs_rq->h_load, cfs_rq->load.weight + 1);
+
+ return load;
+}
+#else
+static unsigned long task_h_load(struct task_struct *p)
+{
+ return p->se.load.weight;
+}
+#endif /* CONFIG_FAIR_GROUP_SCHED */
+#endif /* CONFIG_SMP */

#ifdef CONFIG_SCHED_NUMA
#ifdef CONFIG_SMP
@@ -3757,17 +3775,6 @@ static void update_h_load(long cpu)
walk_tg_tree(tg_load_down, tg_nop, (void *)cpu);
rcu_read_unlock();
}
-
-static unsigned long task_h_load(struct task_struct *p)
-{
- struct cfs_rq *cfs_rq = task_cfs_rq(p);
- unsigned long load;
-
- load = p->se.load.weight;
- load = div_u64(load * cfs_rq->h_load, cfs_rq->load.weight + 1);
-
- return load;
-}
#else
static inline void update_shares(int cpu)
{
@@ -3776,11 +3783,6 @@ static inline void update_shares(int cpu)
static inline void update_h_load(long cpu)
{
}
-
-static unsigned long task_h_load(struct task_struct *p)
-{
- return p->se.load.weight;
-}
#endif

/********** Helpers for find_busiest_group ************************/
--
1.7.9.5