linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Wang <wangyun@linux.vnet.ibm.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Paul Turner <pjt@google.com>,
	Dhaval Giani <dhaval.giani@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [RFC PATCH 4/4] linsched: add the simulation of schedule after ipi interrupt
Date: Mon, 03 Sep 2012 11:58:14 +0800	[thread overview]
Message-ID: <50442AD6.7000109@linux.vnet.ibm.com> (raw)

From: Michael Wang <wangyun@linux.vnet.ibm.com>

In real world of x86, during an interrupt, if current thread need to
be reschedule, we will do it after invoke do_IRQ.

And in linsched, while handle the softirq, it may cause the
reschedule ipi on other cpu, so we need to do schedule for them at
that time, otherwise we will got inaccuracy results.

Signed-off-by: Michael Wang <wangyun@linux.vnet.ibm.com>
---
 tools/linsched/hrtimer.c  |   21 +++++++++++++++++++++
 tools/linsched/linsched.h |    2 ++
 tools/linsched/numa.c     |    2 ++
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/tools/linsched/hrtimer.c b/tools/linsched/hrtimer.c
index 3203253..4df4e14 100644
--- a/tools/linsched/hrtimer.c
+++ b/tools/linsched/hrtimer.c
@@ -158,6 +158,24 @@ void linsched_enter_idle(void)
                tick_nohz_idle_enter();
 }

+cpumask_t linsched_cpu_resched_pending;
+void process_pending_resched(void)
+{
+       int cpu, old_cpu = smp_processor_id();
+
+       if (cpumask_empty(&linsched_cpu_resched_pending))
+               return;
+
+       while (!cpumask_empty(&linsched_cpu_resched_pending)) {
+               cpu = cpumask_first(&linsched_cpu_resched_pending);
+               linsched_change_cpu(cpu);
+               cpumask_clear_cpu(cpu, &linsched_cpu_resched_pending);
+               schedule();
+       }
+
+       linsched_change_cpu(old_cpu);
+}
+
 /* Run a simulation for some number of ticks. Each tick,
  * scheduling and load balancing decisions are made. Obviously, we
  * could create tasks, change priorities, etc., at certain ticks
@@ -217,6 +235,9 @@ void linsched_run_sim(int sim_ticks)
 
                        linsched_rcu_invoke();
 
+                       process_pending_resched();
+                       linsched_check_idle_cpu();
+
                        BUG_ON(irqs_disabled());
                        if (idle_cpu(active_cpu) && !need_resched()) {
                                linsched_enter_idle();
diff --git a/tools/linsched/linsched.h b/tools/linsched/linsched.h
index d56d801..c4964c5 100644
--- a/tools/linsched/linsched.h
+++ b/tools/linsched/linsched.h
@@ -34,6 +34,8 @@ extern struct cgroup *root_cgroup;

 extern u64 current_time;

+extern cpumask_t linsched_cpu_resched_pending;
+
 struct sleep_run_data {
        struct hrtimer timer;
        struct task_struct *p;
diff --git a/tools/linsched/numa.c b/tools/linsched/numa.c
index 255ff51..e2e7568 100644
--- a/tools/linsched/numa.c
+++ b/tools/linsched/numa.c
@@ -113,6 +113,8 @@ void linsched_trigger_cpu(int cpu)
         * Call the scheduler ipi when queueing up tasks on the wakelist
         */
        scheduler_ipi();
+       if (need_resched())
+               cpumask_set_cpu(cpu, &linsched_cpu_resched_pending);
        linsched_change_cpu(curr_cpu);
 }

-- 
1.7.1


             reply	other threads:[~2012-09-03  3:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-03  3:58 Michael Wang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-04-16  3:38 [RFC PATCH 4/4] linsched: add the simulation of schedule after ipi interrupt Michael Wang

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=50442AD6.7000109@linux.vnet.ibm.com \
    --to=wangyun@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dhaval.giani@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pjt@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;
as well as URLs for NNTP newsgroup(s).