* [PATCH v4] sched/core: silence a warning in sched_init()
@ 2019-07-20 1:23 Qian Cai
2019-07-25 16:26 ` [tip:sched/core] sched/core: Silence " tip-bot for Qian Cai
0 siblings, 1 reply; 2+ messages in thread
From: Qian Cai @ 2019-07-20 1:23 UTC (permalink / raw)
To: mingo, peterz; +Cc: valentin.schneider, linux-kernel, Qian Cai
Compiling a kernel with both FAIR_GROUP_SCHED=n and RT_GROUP_SCHED=n
will generate a compiler warning,
kernel/sched/core.c: In function 'sched_init':
kernel/sched/core.c:5906:32: warning: variable 'ptr' set but not used
[-Wunused-but-set-variable]
unsigned long alloc_size = 0, ptr;
^~~
It is unnecessary to have both "alloc_size" and "ptr", so just combine
them.
Signed-off-by: Qian Cai <cai@lca.pw>
---
v4: Combine "alloc_size" and "ptr" together.
v3: Use a different approach to see if Peter will like it.
v2: Incorporate the feedback from Valentin.
kernel/sched/core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2b037f195473..6eefaeea4c88 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6371,19 +6371,19 @@ DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
void __init sched_init(void)
{
- unsigned long alloc_size = 0, ptr;
+ unsigned long ptr = 0;
int i;
wait_bit_init();
#ifdef CONFIG_FAIR_GROUP_SCHED
- alloc_size += 2 * nr_cpu_ids * sizeof(void **);
+ ptr += 2 * nr_cpu_ids * sizeof(void **);
#endif
#ifdef CONFIG_RT_GROUP_SCHED
- alloc_size += 2 * nr_cpu_ids * sizeof(void **);
+ ptr += 2 * nr_cpu_ids * sizeof(void **);
#endif
- if (alloc_size) {
- ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
+ if (ptr) {
+ ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
#ifdef CONFIG_FAIR_GROUP_SCHED
root_task_group.se = (struct sched_entity **)ptr;
--
2.20.1 (Apple Git-117)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:sched/core] sched/core: Silence a warning in sched_init()
2019-07-20 1:23 [PATCH v4] sched/core: silence a warning in sched_init() Qian Cai
@ 2019-07-25 16:26 ` tip-bot for Qian Cai
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Qian Cai @ 2019-07-25 16:26 UTC (permalink / raw)
To: linux-tip-commits; +Cc: torvalds, hpa, linux-kernel, cai, tglx, peterz, mingo
Commit-ID: a1dc0446d64966dc0ae756aebdc449f335742c13
Gitweb: https://git.kernel.org/tip/a1dc0446d64966dc0ae756aebdc449f335742c13
Author: Qian Cai <cai@lca.pw>
AuthorDate: Fri, 19 Jul 2019 21:23:19 -0400
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 25 Jul 2019 15:55:05 +0200
sched/core: Silence a warning in sched_init()
Compiling a kernel with both FAIR_GROUP_SCHED=n and RT_GROUP_SCHED=n
will generate a compiler warning:
kernel/sched/core.c: In function 'sched_init':
kernel/sched/core.c:5906:32: warning: variable 'ptr' set but not used
It is unnecessary to have both "alloc_size" and "ptr", so just combine
them.
Signed-off-by: Qian Cai <cai@lca.pw>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: valentin.schneider@arm.com
Link: https://lkml.kernel.org/r/20190720012319.884-1-cai@lca.pw
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 042c736b2b73..46f3ca9e392a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6430,19 +6430,19 @@ DECLARE_PER_CPU(cpumask_var_t, select_idle_mask);
void __init sched_init(void)
{
- unsigned long alloc_size = 0, ptr;
+ unsigned long ptr = 0;
int i;
wait_bit_init();
#ifdef CONFIG_FAIR_GROUP_SCHED
- alloc_size += 2 * nr_cpu_ids * sizeof(void **);
+ ptr += 2 * nr_cpu_ids * sizeof(void **);
#endif
#ifdef CONFIG_RT_GROUP_SCHED
- alloc_size += 2 * nr_cpu_ids * sizeof(void **);
+ ptr += 2 * nr_cpu_ids * sizeof(void **);
#endif
- if (alloc_size) {
- ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
+ if (ptr) {
+ ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
#ifdef CONFIG_FAIR_GROUP_SCHED
root_task_group.se = (struct sched_entity **)ptr;
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-25 16:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-20 1:23 [PATCH v4] sched/core: silence a warning in sched_init() Qian Cai
2019-07-25 16:26 ` [tip:sched/core] sched/core: Silence " tip-bot for Qian Cai
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).