From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Tony Luck <tony.luck@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Venkatesh Pallipadi <venki@google.com>,
KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Mike Travis <travis@sgi.com>,
"Paul E. McKenney" <paul.mckenney@linaro.org>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
linux-kernel@vger.kernel.org, Fenghua Yu <fenghua.yu@intel.com>,
linux-ia64@vger.kernel.org
Subject: Re: [PATCH] Avoid mask based num_possible_cpus and num_online_cpus -v5
Date: Wed, 15 Feb 2012 03:05:50 +0530 [thread overview]
Message-ID: <4F3AD3B6.8070409@linux.vnet.ibm.com> (raw)
In-Reply-To: <87wr7pbwbz.fsf@rustcorp.com.au>
On 02/14/2012 02:55 PM, Rusty Russell wrote:
> On Mon, 13 Feb 2012 13:57:45 -0800, Tony Luck <tony.luck@gmail.com> wrote:
>> On Mon, Feb 13, 2012 at 12:44 PM, Srivatsa S. Bhat
>> <srivatsa.bhat@linux.vnet.ibm.com> wrote:
>>> IOW, what output do you see from the following printk from
>>> arch/ia64/kernel/smpboot.c?
>>>
>>> printk(KERN_INFO "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
>>> (int)num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100);
>>
>> That is a complicated question - because linux-next also has patches
>> by Arjan that
>> change how (when) cpus are brought online. Initially I blamed his
>> patches and tried
>> reverting them ... and saw the symptom you are wondering about (message said
>> "Total of 1 processors", but the BogoMIPs was a number big enough to be all of
>> them. Thanks to you, I can now understand why.
>>
>> Fix will be to stop ia64 from messing directly with cpu_online_map?
>
> Yes, and the other architectures.
>
Right. And we should also ensure that nobody messes directly with
cpu_possible_map as well. I have written up a patch for ia64 (see below).
Sorry, I haven't even compile tested it - I neither have the toolchain nor the
hardware. I hope it works!
But don't expect the above printk statement to print the right value if you are
running a kernel which has the patch posted at https://lkml.org/lkml/2012/1/31/286
applied. That is another patch that can alter boot-up time and many related
things. So, it would be best to test Venki's patch + following fix without having
Arjan's patch applied.
---
From: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Subject: [PATCH] ia64: Don't use cpu_set()/cpu_clear() over cpu_[online|possible]_map
Directly using cpu_set() and cpu_clear() on cpu_online_map or cpu_possible_map
is strongly discouraged. Use the functions set_cpu_online() and
set_cpu_possible() instead. This also means that the new implementation of
num_[online|possible]_cpus can track all changes to cpu_[online|possible]_mask
and hence give the correct results always.
Reported-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---
0 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index cd57d73..4d1a550 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -486,7 +486,7 @@ mark_bsp_online (void)
{
#ifdef CONFIG_SMP
/* If we register an early console, allow CPU 0 to printk */
- cpu_set(smp_processor_id(), cpu_online_map);
+ set_cpu_online(smp_processor_id(), true);
#endif
}
diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
index 0bd537b..8551979 100644
--- a/arch/ia64/kernel/smp.c
+++ b/arch/ia64/kernel/smp.c
@@ -77,7 +77,7 @@ stop_this_cpu(void)
/*
* Remove this CPU:
*/
- cpu_clear(smp_processor_id(), cpu_online_map);
+ set_cpu_online(smp_processor_id(), false);
max_xtp();
local_irq_disable();
cpu_halt();
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 5590979..35f6e3c 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -401,7 +401,7 @@ smp_callin (void)
/* Setup the per cpu irq handling data structures */
__setup_vector_irq(cpuid);
notify_cpu_starting(cpuid);
- cpu_set(cpuid, cpu_online_map);
+ set_cpu_online(cpuid, true);
per_cpu(cpu_state, cpuid) = CPU_ONLINE;
spin_unlock(&vector_lock);
ipi_call_unlock_irq();
@@ -548,7 +548,7 @@ do_rest:
if (!cpu_isset(cpu, cpu_callin_map)) {
printk(KERN_ERR "Processor 0x%x/0x%x is stuck.\n", cpu, sapicid);
ia64_cpu_to_sapicid[cpu] = -1;
- cpu_clear(cpu, cpu_online_map); /* was set in smp_callin() */
+ set_cpu_online(cpu, false); /* was set in smp_callin() */
return -EINVAL;
}
return 0;
@@ -609,7 +609,7 @@ smp_prepare_cpus (unsigned int max_cpus)
/*
* We have the boot CPU online for sure.
*/
- cpu_set(0, cpu_online_map);
+ set_cpu_online(0, true);
cpu_set(0, cpu_callin_map);
local_cpu_data->loops_per_jiffy = loops_per_jiffy;
@@ -633,7 +633,7 @@ smp_prepare_cpus (unsigned int max_cpus)
void __devinit smp_prepare_boot_cpu(void)
{
- cpu_set(smp_processor_id(), cpu_online_map);
+ set_cpu_online(smp_processor_id(), true);
cpu_set(smp_processor_id(), cpu_callin_map);
set_numa_node(cpu_to_node_map[smp_processor_id()]);
per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
@@ -732,10 +732,10 @@ int __cpu_disable(void)
return -EBUSY;
}
- cpu_clear(cpu, cpu_online_map);
+ set_cpu_online(cpu, false);
if (migrate_platform_irqs(cpu)) {
- cpu_set(cpu, cpu_online_map);
+ set_cpu_online(cpu, true);
return -EBUSY;
}
next prev parent reply other threads:[~2012-02-14 21:36 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-18 2:07 [PATCH] Avoid mask based num_possible_cpus and num_online_cpus Venkatesh Pallipadi
2012-01-18 5:55 ` KOSAKI Motohiro
2012-01-18 18:52 ` Venki Pallipadi
2012-01-18 19:20 ` KOSAKI Motohiro
2012-01-19 20:01 ` Venkatesh Pallipadi
2012-01-19 20:40 ` KOSAKI Motohiro
2012-01-21 1:01 ` Venki Pallipadi
2012-01-19 20:43 ` Srivatsa S. Bhat
2012-01-20 23:09 ` Venki Pallipadi
2012-01-20 23:45 ` KOSAKI Motohiro
2012-01-20 23:55 ` Venki Pallipadi
2012-01-23 5:22 ` Srivatsa S. Bhat
2012-01-23 19:28 ` Venki Pallipadi
2012-01-24 2:34 ` [PATCH] Avoid mask based num_possible_cpus and num_online_cpus -v3 Venkatesh Pallipadi
2012-01-24 19:22 ` Srivatsa S. Bhat
2012-01-24 19:30 ` KOSAKI Motohiro
2012-01-24 21:01 ` Venki Pallipadi
2012-01-24 23:25 ` [PATCH] Avoid mask based num_possible_cpus and num_online_cpus -v4 Venkatesh Pallipadi
2012-01-26 17:22 ` Srivatsa S. Bhat
2012-01-26 17:27 ` Srivatsa S. Bhat
2012-01-26 21:25 ` KOSAKI Motohiro
2012-01-26 23:22 ` Andrew Morton
2012-01-27 23:58 ` Venki Pallipadi
2012-02-01 0:17 ` [PATCH] Avoid mask based num_possible_cpus and num_online_cpus -v5 Venkatesh Pallipadi
2012-02-01 22:01 ` Andrew Morton
2012-02-02 20:03 ` Rusty Russell
2012-02-02 20:19 ` Andrew Morton
2012-02-02 21:00 ` Venki Pallipadi
2012-02-13 19:54 ` Tony Luck
2012-02-13 20:04 ` Venki Pallipadi
2012-02-13 20:25 ` Srivatsa S. Bhat
2012-02-13 20:43 ` Venki Pallipadi
2012-02-13 20:55 ` Srivatsa S. Bhat
2012-02-13 20:44 ` Srivatsa S. Bhat
2012-02-13 21:57 ` Tony Luck
2012-02-14 9:25 ` Rusty Russell
2012-02-14 21:35 ` Srivatsa S. Bhat [this message]
2012-02-14 23:00 ` Tony Luck
2012-02-14 22:49 ` [PATCH 0/3] Cleanup raw handling of online/possible map Venkatesh Pallipadi
2012-02-14 22:49 ` [PATCH 1/3] hexagon: Avoid raw handling of cpu_possible_map Venkatesh Pallipadi
2012-02-14 22:49 ` [PATCH 2/3] mips: Avoid raw handling of cpu_possible_map/cpu_online_map Venkatesh Pallipadi
2012-02-27 22:19 ` David Daney
2012-02-14 22:49 ` [PATCH 3/3] um: Avoid raw handling of cpu_online_map Venkatesh Pallipadi
2012-02-27 21:55 ` [PATCH] Avoid mask based num_possible_cpus and num_online_cpus -v5 David Daney
2012-02-27 22:07 ` Andrew Morton
2012-02-27 22:16 ` David Daney
2012-03-01 18:32 ` Venki Pallipadi
2012-02-28 5:01 ` Stephen Rothwell
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=4F3AD3B6.8070409@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=fenghua.yu@intel.com \
--cc=kosaki.motohiro@gmail.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=paul.mckenney@linaro.org \
--cc=rjw@sisk.pl \
--cc=rusty@rustcorp.com.au \
--cc=tony.luck@gmail.com \
--cc=travis@sgi.com \
--cc=venki@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).