All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org, linux-pm@lists.linux-foundation.org
Cc: a.p.zijlstra@chello.nl, ego@in.ibm.com, tglx@linutronix.de,
	mingo@elte.hu, andi@firstfloor.org,
	venkatesh.pallipadi@intel.com, vatsa@linux.vnet.ibm.com,
	arjan@infradead.org, arun@linux.vnet.ibm.com
Subject: [RFC PATCH 4/4] timers: Migrating non pinned regular and hrtimers.
Date: Thu, 16 Oct 2008 17:22:19 +0530	[thread overview]
Message-ID: <20081016115219.GE7641@linux.vnet.ibm.com> (raw)

This patch migrates all the non cpu-pinned regular and hrtimers
from a particular cpu to the target cpu specified.

The migration is triggered by setting the target cpu number at
/sys/devices/system/cpu/cpuX/timer_migration.

In the situation where the cpuX goes offline *after* the user sets
X as the target_cpu, then timers are not migrated and stay on
the source cpu. But this is just a short term fix and any discussion
in this regard will help greatly.

I have tested this patch by stressing the system using a script
which continuously hotplug-add and removes the cpus.


Signed-off-by: Arun R Bharadwaj <arun@linux.vnet.ibm.com>
---
 kernel/hrtimer.c |    6 ++++++
 kernel/timer.c   |    7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

Index: linux-2.6.27/kernel/timer.c
===================================================================
--- linux-2.6.27.orig/kernel/timer.c
+++ linux-2.6.27/kernel/timer.c
@@ -547,7 +547,7 @@ int __mod_timer(struct timer_list *timer
 {
 	struct tvec_base *base, *new_base;
 	unsigned long flags;
-	int ret = 0;
+	int ret = 0, target_cpu;
 
 	timer_stats_timer_set_start_info(timer);
 	BUG_ON(!timer->function);
@@ -562,6 +562,11 @@ int __mod_timer(struct timer_list *timer
 	debug_timer_activate(timer);
 
 	new_base = __get_cpu_var(tvec_bases);
+	target_cpu = __get_cpu_var(enable_timer_migration);
+	if (target_cpu != smp_processor_id() && !tbase_get_pinned(timer->base)
+			&& cpu_online(target_cpu))
+		new_base = per_cpu(tvec_bases, target_cpu);
+
 
 	if (base != new_base) {
 		/*
Index: linux-2.6.27/kernel/hrtimer.c
===================================================================
--- linux-2.6.27.orig/kernel/hrtimer.c
+++ linux-2.6.27/kernel/hrtimer.c
@@ -206,8 +206,14 @@ switch_hrtimer_base(struct hrtimer *time
 {
 	struct hrtimer_clock_base *new_base;
 	struct hrtimer_cpu_base *new_cpu_base;
+	int target_cpu;
 
 	new_cpu_base = &__get_cpu_var(hrtimer_bases);
+	target_cpu = __get_cpu_var(enable_timer_migration);
+	if (target_cpu != smp_processor_id() && !is_hrtimer_pinned(timer)
+			&& cpu_online(target_cpu))
+		new_cpu_base = &per_cpu(hrtimer_bases, target_cpu);
+
 	new_base = &new_cpu_base->clock_base[base->index];
 
 	if (base != new_base) {

             reply	other threads:[~2008-10-16 11:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-16 11:52 Arun R Bharadwaj [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-10-16 11:52 [RFC PATCH 4/4] timers: Migrating non pinned regular and hrtimers Arun R Bharadwaj

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=20081016115219.GE7641@linux.vnet.ibm.com \
    --to=arun@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=andi@firstfloor.org \
    --cc=arjan@infradead.org \
    --cc=ego@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=vatsa@linux.vnet.ibm.com \
    --cc=venkatesh.pallipadi@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.