From: Suresh Siddha <suresh.b.siddha@intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Arjan van de Ven <arjan@linux.jf.intel.com>
Cc: Venkatesh Pallipadi <venki@google.com>,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
ego@in.ibm.com, LKML <linux-kernel@vger.kernel.org>,
Dominik Brodowski <linux@dominikbrodowski.net>,
Nigel Cunningham <ncunningham@crca.org.au>,
Suresh Siddha <suresh.b.siddha@intel.com>
Subject: [patch 6/7] sched: change nohz.load_balancer to be nr_cpu_ids based
Date: Mon, 17 May 2010 11:27:32 -0700 [thread overview]
Message-ID: <20100517184028.032341083@sbs-t61.sc.intel.com> (raw)
In-Reply-To: <20100517182726.089700767@sbs-t61.sc.intel.com>
[-- Attachment #1: sched_change_nohz_load_balancer_to_nr_cpu_ids.patch --]
[-- Type: text/plain, Size: 4310 bytes --]
From: Venkatesh Pallipadi <venki@google.com>
Subject: sched: change nohz.load_balancer to be nr_cpu_ids based
nohz.load_balancer was using -1 when it is not set to any cpu. Change it
to nr_cpu_ids, making it similar to other such variables in this file.
Signed-off-by: Venkatesh Pallipadi <venki@google.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
kernel/hrtimer.c | 2 +-
kernel/sched.c | 1 +
kernel/sched_fair.c | 26 ++++++++++++++++----------
kernel/timer.c | 2 +-
4 files changed, 19 insertions(+), 12 deletions(-)
Index: tip/kernel/sched_fair.c
===================================================================
--- tip.orig/kernel/sched_fair.c
+++ tip/kernel/sched_fair.c
@@ -3101,13 +3101,15 @@ static struct {
cpumask_var_t idle_cpus_mask;
cpumask_var_t grp_idle_mask;
unsigned long next_balance; /* in jiffy units */
-} nohz ____cacheline_aligned = {
- .load_balancer = ATOMIC_INIT(-1),
-};
+} nohz ____cacheline_aligned;
int get_nohz_load_balancer(void)
{
- return atomic_read(&nohz.load_balancer);
+ int load_balancer = atomic_read(&nohz.load_balancer);
+ if (load_balancer >= nr_cpu_ids)
+ return nr_cpu_ids;
+
+ return load_balancer;
}
#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
@@ -3237,7 +3239,8 @@ static void nohz_balancer_kick(int cpu)
nohz.next_balance++;
ilb_cpu = get_nohz_load_balancer();
- if (ilb_cpu < 0) {
+
+ if (ilb_cpu >= nr_cpu_ids) {
ilb_cpu = cpumask_first(nohz.idle_cpus_mask);
if (ilb_cpu >= nr_cpu_ids)
return;
@@ -3279,7 +3282,8 @@ void select_nohz_load_balancer(int stop_
* If we are going offline and still the leader,
* give up!
*/
- if (atomic_cmpxchg(&nohz.load_balancer, cpu, -1) != cpu)
+ if (atomic_cmpxchg(&nohz.load_balancer, cpu,
+ nr_cpu_ids) != cpu)
BUG();
return;
@@ -3292,11 +3296,12 @@ void select_nohz_load_balancer(int stop_
if (atomic_read(&nohz.second_pick_cpu) == cpu)
atomic_cmpxchg(&nohz.second_pick_cpu, cpu, nr_cpu_ids);
- if (atomic_read(&nohz.load_balancer) == -1) {
+ if (atomic_read(&nohz.load_balancer) >= nr_cpu_ids) {
int new_ilb;
/* make me the ilb owner */
- if (atomic_cmpxchg(&nohz.load_balancer, -1, cpu) != -1)
+ if (atomic_cmpxchg(&nohz.load_balancer, nr_cpu_ids,
+ cpu) != nr_cpu_ids)
return;
/*
@@ -3305,7 +3310,7 @@ void select_nohz_load_balancer(int stop_
*/
new_ilb = find_new_ilb(cpu);
if (new_ilb < nr_cpu_ids && new_ilb != cpu) {
- atomic_set(&nohz.load_balancer, -1);
+ atomic_set(&nohz.load_balancer, nr_cpu_ids);
resched_cpu(new_ilb);
return;
}
@@ -3318,7 +3323,8 @@ void select_nohz_load_balancer(int stop_
cpumask_clear_cpu(cpu, nohz.idle_cpus_mask);
if (atomic_read(&nohz.load_balancer) == cpu)
- if (atomic_cmpxchg(&nohz.load_balancer, cpu, -1) != cpu)
+ if (atomic_cmpxchg(&nohz.load_balancer, cpu,
+ nr_cpu_ids) != cpu)
BUG();
}
return;
Index: tip/kernel/sched.c
===================================================================
--- tip.orig/kernel/sched.c
+++ tip/kernel/sched.c
@@ -7656,6 +7656,7 @@ void __init sched_init(void)
#ifdef CONFIG_NO_HZ
zalloc_cpumask_var(&nohz.idle_cpus_mask, GFP_NOWAIT);
alloc_cpumask_var(&nohz.grp_idle_mask, GFP_NOWAIT);
+ atomic_set(&nohz.load_balancer, nr_cpu_ids);
atomic_set(&nohz.first_pick_cpu, nr_cpu_ids);
atomic_set(&nohz.second_pick_cpu, nr_cpu_ids);
#endif
Index: tip/kernel/hrtimer.c
===================================================================
--- tip.orig/kernel/hrtimer.c
+++ tip/kernel/hrtimer.c
@@ -147,7 +147,7 @@ static int hrtimer_get_target(int this_c
if (!pinned && get_sysctl_timer_migration() && idle_cpu(this_cpu)) {
int preferred_cpu = get_nohz_load_balancer();
- if (preferred_cpu >= 0)
+ if (preferred_cpu < nr_cpu_ids)
return preferred_cpu;
}
#endif
Index: tip/kernel/timer.c
===================================================================
--- tip.orig/kernel/timer.c
+++ tip/kernel/timer.c
@@ -682,7 +682,7 @@ __mod_timer(struct timer_list *timer, un
if (!pinned && get_sysctl_timer_migration() && idle_cpu(cpu)) {
int preferred_cpu = get_nohz_load_balancer();
- if (preferred_cpu >= 0)
+ if (preferred_cpu < nr_cpu_ids)
cpu = preferred_cpu;
}
#endif
next prev parent reply other threads:[~2010-05-17 19:03 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-17 18:27 [patch 0/7] sched: change nohz idle load balancing logic to push model Suresh Siddha
2010-05-17 18:27 ` [patch 1/7] softirq: Add a no local fallback option to send_remote_softirq Suresh Siddha
2010-05-17 18:27 ` [patch 2/7] softirq: add init_remote_softirq_csd() Suresh Siddha
2010-05-17 18:27 ` [patch 3/7] softirq: avoid softirq_work_list for SCHED_SOFTIRQ when sent remotely Suresh Siddha
2010-05-20 8:12 ` Peter Zijlstra
2010-05-20 8:14 ` David Miller
2010-05-20 8:23 ` Jens Axboe
2010-05-20 8:29 ` Peter Zijlstra
2010-05-20 9:18 ` David Miller
2010-05-17 18:27 ` [patch 4/7] sched: Change nohz ilb logic from pull to push model Suresh Siddha
2010-06-01 23:47 ` Vaidyanathan Srinivasan
2010-06-02 22:27 ` Suresh Siddha
2010-05-17 18:27 ` [patch 5/7] sched: Change select_nohz_load_balancer to return void Suresh Siddha
2010-05-17 18:27 ` Suresh Siddha [this message]
2010-05-20 9:49 ` [patch 6/7] sched: change nohz.load_balancer to be nr_cpu_ids based Peter Zijlstra
2010-05-17 18:27 ` [patch 7/7] timers: use nearest busy cpu for migrating timers from an idle cpu Suresh Siddha
2010-06-01 23:37 ` Vaidyanathan Srinivasan
2010-06-02 22:02 ` Suresh Siddha
2010-05-17 22:39 ` [patch 0/7] sched: change nohz idle load balancing logic to push model Nigel Cunningham
2010-05-19 9:19 ` Dominik Brodowski
2010-05-20 10:50 ` Peter Zijlstra
2010-05-22 0:09 ` Suresh Siddha
2010-05-31 9:17 ` Peter Zijlstra
2010-06-09 10:13 ` [tip:sched/core] sched: Change " tip-bot for Venkatesh Pallipadi
2010-05-20 11:07 ` [patch 0/7] sched: change " Nigel Cunningham
2010-05-20 11:17 ` Dominik Brodowski
2010-05-20 11:35 ` Nigel Cunningham
2010-05-20 12:13 ` Dominik Brodowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100517184028.032341083@sbs-t61.sc.intel.com \
--to=suresh.b.siddha@intel.com \
--cc=arjan@linux.jf.intel.com \
--cc=ego@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=mingo@elte.hu \
--cc=ncunningham@crca.org.au \
--cc=peterz@infradead.org \
--cc=svaidy@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
--cc=venki@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®