LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>
To: "Steven Rostedt" <rostedt@goodmis.org>,
	"LKML" <linux-kernel@vger.kernel.org>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Ingo Molnar" <mingo@elte.hu>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Brown, Len" <len.brown@intel.com>,
	"Adam Belay" <abelay@novell.com>,
	"Peter Zijlstra" <a.p.zijlstra@chello.nl>,
	"Andi Kleen" <ak@suse.de>
Subject: RE: [PATCH] Kick CPUS that might be sleeping in cpus_idle_wait
Date: Wed, 9 Jan 2008 16:12:23 -0800	[thread overview]
Message-ID: <924EFEDD5F540B4284297C4DC59F3DEE554130@orsmsx423.amr.corp.intel.com> (raw)
In-Reply-To: <1199911330.975.3.camel@localhost.localdomain>

 

>-----Original Message-----
>From: Steven Rostedt [mailto:rostedt@goodmis.org] 
>Sent: Wednesday, January 09, 2008 12:42 PM
>To: LKML
>Cc: Linus Torvalds; Andrew Morton; Ingo Molnar; Thomas 
>Gleixner; Brown, Len; Pallipadi, Venkatesh; Adam Belay; Peter 
>Zijlstra; Andi Kleen
>Subject: [PATCH] Kick CPUS that might be sleeping in cpus_idle_wait
>
>This patch is different than the first patch I sent out.
>This one just sends an IPI to all CPUS that don't check in after 1 sec.
>
>
>Sometimes cpu_idle_wait gets stuck because it might miss CPUS that are
>already in idle, have no tasks waiting to run and have no interrupts
>going to them.  This is common on bootup when switching cpu idle
>governors.
>
>This patch gives those CPUS that don't check in an IPI kick.
>

I think your RFC patch is the right solution here. As I see it, there is
no race with your RFC patch.
As long as you call a dummy smp_call_function on all CPUs, we should be
OK. We can get rid of cpu_idle_state
and the current wait forever logic altogether with dummy
smp_call_function. And so there wont be any wait forever scenario.

The whole point of cpu_idle_wait() is to make all CPUs come out of idle
loop atleast once.
The caller will use cpu_idle_wait something like this.

// Want to change idle handler
- Switch global idle handler to always present default_idle
- call cpu_idle_wait so that all cpus come out of idle for an instant
and stop using old idle pointer and start using default idle
- Change the idle handler to a new handler
- optional cpu_idle_wait if you want all cpus to start using the new
handler immediately.

May be the below 1s patch is safe bet for .24. But for .25, I would say
we just replace all complicated logic by simple dummy smp_call_function
and remove cpu_idle_state altogether.

Thanks,
Venki

>Signed-off-by: Steven Rostedt <srostedt@redhat.com>
>---
> arch/x86/kernel/process_32.c |   11 +++++++++++
> arch/x86/kernel/process_64.c |   11 +++++++++++
> 2 files changed, 22 insertions(+)
>
>Index: linux-compile-i386.git/arch/x86/kernel/process_32.c
>===================================================================
>--- linux-compile-i386.git.orig/arch/x86/kernel/process_32.c	
>2008-01-09 14:09:36.000000000 -0500
>+++ linux-compile-i386.git/arch/x86/kernel/process_32.c	
>2008-01-09 14:09:45.000000000 -0500
>@@ -204,6 +204,10 @@ void cpu_idle(void)
> 	}
> }
> 
>+static void do_nothing(void *unused)
>+{
>+}
>+
> void cpu_idle_wait(void)
> {
> 	unsigned int cpu, this_cpu = get_cpu();
>@@ -228,6 +232,13 @@ void cpu_idle_wait(void)
> 				cpu_clear(cpu, map);
> 		}
> 		cpus_and(map, map, cpu_online_map);
>+		/*
>+		 * We waited 1 sec, if a CPU still did not call idle
>+		 * it may be because it is in idle and not waking up
>+		 * because it has nothing to do.
>+		 * Give all the remaining CPUS a kick.
>+		 */
>+		smp_call_function_mask(map, do_nothing, 0, 0);
> 	} while (!cpus_empty(map));
> 
> 	set_cpus_allowed(current, tmp);
>Index: linux-compile-i386.git/arch/x86/kernel/process_64.c
>===================================================================
>--- linux-compile-i386.git.orig/arch/x86/kernel/process_64.c	
>2008-01-09 14:09:36.000000000 -0500
>+++ linux-compile-i386.git/arch/x86/kernel/process_64.c	
>2008-01-09 15:17:20.000000000 -0500
>@@ -135,6 +135,10 @@ static void poll_idle (void)
> 	cpu_relax();
> }
> 
>+static void do_nothing(void *unused)
>+{
>+}
>+
> void cpu_idle_wait(void)
> {
> 	unsigned int cpu, this_cpu = get_cpu();
>@@ -160,6 +164,13 @@ void cpu_idle_wait(void)
> 				cpu_clear(cpu, map);
> 		}
> 		cpus_and(map, map, cpu_online_map);
>+		/*
>+		 * We waited 1 sec, if a CPU still did not call idle
>+		 * it may be because it is in idle and not waking up
>+		 * because it has nothing to do.
>+		 * Give all the remaining CPUS a kick.
>+		 */
>+		smp_call_function_mask(map, do_nothing, 0, 0);
> 	} while (!cpus_empty(map));
> 
> 	set_cpus_allowed(current, tmp);
>
>
>

  parent reply	other threads:[~2008-01-10  0:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08  2:27 [RFC PATCH] kick sleeping idle CPUS on cpu_idle_wait Steven Rostedt
2008-01-08  3:33 ` Andi Kleen
2008-01-09 20:42   ` [PATCH] Kick CPUS that might be sleeping in cpus_idle_wait Steven Rostedt
2008-01-09 22:12     ` Steven Rostedt
2008-01-10 13:45       ` Ingo Molnar
2008-01-10 14:43         ` Steven Rostedt
2008-01-10 17:31           ` Pallipadi, Venkatesh
2008-01-10 18:03             ` Steven Rostedt
2008-01-09 23:42     ` Andrew Morton
2008-01-10  0:05       ` Steven Rostedt
2008-01-10  0:12     ` Pallipadi, Venkatesh [this message]
     [not found]     ` <B5B0CFF685D7DF46A05CF1678CFB42ED20E00653@orsmsx423.amr.corp.intel.com>
2008-02-08  1:05       ` [PATCH] x86: Simplify cpu_idle_wait Venki Pallipadi
2008-02-08 10:28         ` Andi Kleen
2008-02-08 17:24           ` Venki Pallipadi
2008-02-08 18:45             ` Andi Kleen
2008-02-09  9:33             ` Thomas Gleixner
2008-04-10 16:49               ` Venki Pallipadi

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=924EFEDD5F540B4284297C4DC59F3DEE554130@orsmsx423.amr.corp.intel.com \
    --to=venkatesh.pallipadi@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=abelay@novell.com \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --subject='RE: [PATCH] Kick CPUS that might be sleeping in cpus_idle_wait' \
    /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

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).