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 3/4] linsched: avoid invoke tick_nohz_idle_enter() multiple times in idle
Date: Mon, 03 Sep 2012 11:58:10 +0800	[thread overview]
Message-ID: <50442AD2.6060109@linux.vnet.ibm.com> (raw)

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

In real world, tick_nohz_idle_enter() will be invoked by idle thread 
when the cpu change from active to idle, and will only be invoked
again after tick_nohz_idle_exit() was invoked by idle thread when
cpu is going to recover, invoke it multiple times in one idle may
cause unexpected troubles.

The patch add a check to avoid invoke tick_nohz_idle_enter() again
after idle.

Signed-off-by: Michael Wang <wangyun@linux.vnet.ibm.com>
---
 tools/linsched/hrtimer.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/tools/linsched/hrtimer.c b/tools/linsched/hrtimer.c
index de88b25..3203253 100644
--- a/tools/linsched/hrtimer.c
+++ b/tools/linsched/hrtimer.c
@@ -149,6 +149,15 @@ void linsched_check_idle_cpu(void)
        } 
 }
 
+void linsched_enter_idle(void)
+{
+       int cpu = smp_processor_id();
+       struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
+
+       if (!ts->inidle && idle_cpu(cpu))
+               tick_nohz_idle_enter();
+}              
+
 /* 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
@@ -210,7 +219,7 @@ void linsched_run_sim(int sim_ticks)
 
                        BUG_ON(irqs_disabled());
                        if (idle_cpu(active_cpu) && !need_resched()) {
-                               tick_nohz_idle_enter();
+                               linsched_enter_idle();
                        } else {
                                linsched_current_handler();
                        }
-- 
1.7.1


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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=50442AD2.6060109@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).