mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
	Mike Travis <travis@sgi.com>
Subject: Re: [PULL] x86 cpumask work
Date: Tue, 17 Mar 2009 14:50:34 +1030	[thread overview]
Message-ID: <200903171450.34549.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20090316084802.GB1062@elte.hu>

On Monday 16 March 2009 19:18:02 Ingo Molnar wrote:
> 
> * Rusty Russell <rusty@rustcorp.com.au> wrote:
> > As the comments says, it can only be NULL during boot of the first CPU.
> > 
> > start_kernel -> check_bugs -> identify_boot_cpu -> identify_cpu
> >   -> select_idle_routine.
> > 
> > Did you want me to panic if it fails?
> 
> Ah, ok. But i think it's very unobvious to embedd a "once per 
> bootup" dynamic allocation like that. Please put it into a 
> separate init routine instead. That way select_idle() [which 
> runs during every CPU hotplug event] wont have this allocation.

There wasn't an obvious place to put the init; I've created one.

How's this?
===

Subject: cpumask: fix CONFIG_CPUMASK_OFFSTACK=y cpu hotunplug crash

Impact: Fix cpu offline when CONFIG_MAXSMP=y

Changeset bc9b83dd1f66402b870301c3c7117b9c1484abb4 "cpumask: convert c1e_mask
in arch/x86/kernel/process.c to cpumask_var_t" contained a bug: c1e_mask is
manipulated even if C1E isn't detected (and hence not allocated).  This is
simply fixed by checking for NULL (which gcc optimizes out anyway of
CONFIG_CPUMASK_OFFSTACK=n, since it knows ce1_mask can never be NULL).

In addition, fix a leak where select_idle_routine re-allocates (and re-clears)
c1e_mask on every cpu init.

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index d794d94..9874dd9 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -733,6 +733,7 @@ static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
 extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
 
 extern void select_idle_routine(const struct cpuinfo_x86 *c);
+extern void init_c1e_mask(void);
 
 extern unsigned long		boot_option_idle_override;
 extern unsigned long		idle_halt;
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 82f6cc0..d7dd3c2 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -812,6 +812,7 @@ static void vgetcpu_set_mode(void)
 void __init identify_boot_cpu(void)
 {
 	identify_cpu(&boot_cpu_data);
+	init_c1e_mask();
 #ifdef CONFIG_X86_32
 	sysenter_setup();
 	enable_sep_cpu();
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 6638294..78533a5 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -479,7 +479,8 @@ static int c1e_detected;
 
 void c1e_remove_cpu(int cpu)
 {
-	cpumask_clear_cpu(cpu, c1e_mask);
+	if (c1e_mask != NULL)
+		cpumask_clear_cpu(cpu, c1e_mask);
 }
 
 /*
@@ -556,13 +557,20 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
 		pm_idle = mwait_idle;
 	} else if (check_c1e_idle(c)) {
 		printk(KERN_INFO "using C1E aware idle routine\n");
-		alloc_cpumask_var(&c1e_mask, GFP_KERNEL);
-		cpumask_clear(c1e_mask);
 		pm_idle = c1e_idle;
 	} else
 		pm_idle = default_idle;
 }
 
+void __init init_c1e_mask(void)
+{
+	/* If we're using c1e_idle, we need to allocate c1e_mask. */
+	if (pm_idle == c1e_idle) {
+		alloc_cpumask_var(&c1e_mask, GFP_KERNEL);
+		cpumask_clear(c1e_mask);
+	}
+}
+
 static int __init idle_setup(char *str)
 {
 	if (!str)

  reply	other threads:[~2009-03-17  4:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-12  4:23 Rusty Russell
2009-03-12 10:26 ` Ingo Molnar
2009-03-12 10:37   ` Ingo Molnar
2009-03-12 22:54     ` Rusty Russell
2009-03-13  0:57       ` Ingo Molnar
2009-03-13  2:46         ` Rusty Russell
2009-03-13  3:20           ` Ingo Molnar
2009-03-13  4:34             ` Rusty Russell
2009-03-13  4:55               ` Ingo Molnar
2009-03-13  5:27                 ` Ingo Molnar
2009-03-13  5:32                   ` Ingo Molnar
2009-03-13  6:44                     ` Rusty Russell
2009-03-13 13:12                     ` Rusty Russell
2009-03-13 13:45                       ` [tip:cpus4096] cpumask: convert node_to_cpumask_map[] to cpumask_var_t Rusty Russell
2009-03-13 15:27                       ` [PULL] x86 cpumask work Ingo Molnar
2009-03-15  2:56                         ` Rusty Russell
2009-03-15  6:00                           ` Ingo Molnar
2009-03-16  3:03                             ` Rusty Russell
2009-03-16  8:48                               ` Ingo Molnar
2009-03-17  4:20                                 ` Rusty Russell [this message]
2009-03-17 10:51                                   ` Ingo Molnar
2009-03-17 21:27                                     ` Rusty Russell
2009-03-18  8:51                                   ` [tip:cpus4096] cpumask: fix CONFIG_CPUMASK_OFFSTACK=y cpu hotunplug crash Rusty Russell
2009-03-13 13:13                     ` [PATCH] Move numa_node_id default implementation to topology.h Rusty Russell
2009-03-13 13:45                       ` [tip:cpus4096] numa, cpumask: move " Rusty Russell
2009-03-17 18:56 [PULL] x86 cpumask work Cliff Wickman
2009-03-17 21:52 ` Rusty Russell
2009-03-18 12:57   ` Cliff Wickman

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=200903171450.34549.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=travis@sgi.com \
    --cc=x86@kernel.org \
    /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

Powered by JetHome