linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] kernel/smp: Define pr_fmt() for smp.c
@ 2016-10-26  5:37 Michael Ellerman
  2016-10-26  5:37 ` [PATCH v2 2/3] kernel/smp: Make the SMP boot message common on all arches Michael Ellerman
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michael Ellerman @ 2016-10-26  5:37 UTC (permalink / raw)
  To: akpm
  Cc: tglx, mingo, hpa, x86, peterz, jgross, mgorman, richard,
	len.brown, bp, boris.ostrovsky, tim.c.chen, ak, jolsa,
	linux-kernel

This makes all our pr_xxx()'s start with "smp: ", which helps pin down
where they come from and generally looks nice. There is actually only
one pr_xxx() use in smp.c at the moment, but we will add some more in
the next commit.

Suggested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 kernel/smp.c | 3 +++
 1 file changed, 3 insertions(+)

v2: New in v2.

diff --git a/kernel/smp.c b/kernel/smp.c
index bba3b201668d..2d1f15d43022 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -3,6 +3,9 @@
  *
  * (C) Jens Axboe <jens.axboe@oracle.com> 2008
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/irq_work.h>
 #include <linux/rcupdate.h>
 #include <linux/rculist.h>
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] kernel/smp: Make the SMP boot message common on all arches
  2016-10-26  5:37 [PATCH v2 1/3] kernel/smp: Define pr_fmt() for smp.c Michael Ellerman
@ 2016-10-26  5:37 ` Michael Ellerman
  2016-10-26 10:08   ` [tip:core/smp] " tip-bot for Michael Ellerman
  2016-10-26  5:37 ` [PATCH v2 3/3] kernel/smp: Tell the user we're bringing up secondary CPUs Michael Ellerman
  2016-10-26 10:07 ` [tip:core/smp] kernel/smp: Define pr_fmt() for smp.c tip-bot for Michael Ellerman
  2 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2016-10-26  5:37 UTC (permalink / raw)
  To: akpm
  Cc: tglx, mingo, hpa, x86, peterz, jgross, mgorman, richard,
	len.brown, bp, boris.ostrovsky, tim.c.chen, ak, jolsa,
	linux-kernel

Currently after bringing up secondary CPUs all arches print "Brought up
%d CPUs". On x86 they also print the number of nodes that were brought
online.

It would be nice to also print the number of nodes on other arches.
Although we could override smp_announce() on the other ~10 NUMA aware
arches, it seems simpler to just always print the number of nodes. On
non-NUMA arches there is just always 1 node.

Having done that, smp_announce() is no longer weak, and seems small
enough to just pull directly into smp_init().

Also update the printing of "%d CPUs" to be smart when an SMP kernel is
booted on a single CPU system, or when only one CPU is available, eg:

   smp: Brought up 2 nodes, 1 CPU

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/kernel/smpboot.c |  8 --------
 kernel/smp.c              | 13 +++++++------
 2 files changed, 7 insertions(+), 14 deletions(-)

v2: Print singular CPU when only 1 CPU is found.
    Drop "smp:" from pr_info() now we have pr_fmt() defined.

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 42f5eb7b4f6c..b9f02383f372 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -821,14 +821,6 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
 	return (send_status | accept_status);
 }
 
-void smp_announce(void)
-{
-	int num_nodes = num_online_nodes();
-
-	printk(KERN_INFO "x86: Booted up %d node%s, %d CPUs\n",
-	       num_nodes, (num_nodes > 1 ? "s" : ""), num_online_cpus());
-}
-
 /* reduce the number of lines printed when booting a large cpu count system */
 static void announce_cpu(int cpu, int apicid)
 {
diff --git a/kernel/smp.c b/kernel/smp.c
index 2d1f15d43022..4323c5db7d26 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -546,14 +546,10 @@ void __init setup_nr_cpu_ids(void)
 	nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
 }
 
-void __weak smp_announce(void)
-{
-	printk(KERN_INFO "Brought up %d CPUs\n", num_online_cpus());
-}
-
 /* Called by boot processor to activate the rest. */
 void __init smp_init(void)
 {
+	int num_nodes, num_cpus;
 	unsigned int cpu;
 
 	idle_threads_init();
@@ -567,8 +563,13 @@ void __init smp_init(void)
 			cpu_up(cpu);
 	}
 
+	num_nodes = num_online_nodes();
+	num_cpus  = num_online_cpus();
+	pr_info("Brought up %d node%s, %d CPU%s\n",
+		num_nodes, (num_nodes > 1 ? "s" : ""),
+		num_cpus,  (num_cpus  > 1 ? "s" : ""));
+
 	/* Any cleanup work */
-	smp_announce();
 	smp_cpus_done(setup_max_cpus);
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] kernel/smp: Tell the user we're bringing up secondary CPUs
  2016-10-26  5:37 [PATCH v2 1/3] kernel/smp: Define pr_fmt() for smp.c Michael Ellerman
  2016-10-26  5:37 ` [PATCH v2 2/3] kernel/smp: Make the SMP boot message common on all arches Michael Ellerman
@ 2016-10-26  5:37 ` Michael Ellerman
  2016-10-26 10:08   ` [tip:core/smp] " tip-bot for Michael Ellerman
  2016-10-26 10:07 ` [tip:core/smp] kernel/smp: Define pr_fmt() for smp.c tip-bot for Michael Ellerman
  2 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2016-10-26  5:37 UTC (permalink / raw)
  To: akpm
  Cc: tglx, mingo, hpa, x86, peterz, jgross, mgorman, richard,
	len.brown, bp, boris.ostrovsky, tim.c.chen, ak, jolsa,
	linux-kernel

Currently we don't print anything before starting to bring up secondary
CPUs. This can be confusing if it takes a long time to bring up the
secondaries, or if the kernel crashes while doing so and produces no
further output.

On x86 they work around this by detecting when the first secondary CPU
comes up and printing a message (see announce_cpu()). But doing it in
smp_init() is simpler and works for all arches.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Borislav Petkov <bp@suse.de>
---
 kernel/smp.c | 2 ++
 1 file changed, 2 insertions(+)

v2: Drop "smp:" from pr_info() now we have pr_fmt() defined.

diff --git a/kernel/smp.c b/kernel/smp.c
index 4323c5db7d26..77fcdb9f2775 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -555,6 +555,8 @@ void __init smp_init(void)
 	idle_threads_init();
 	cpuhp_threads_init();
 
+	pr_info("Bringing up secondary CPUs ...\n");
+
 	/* FIXME: This should be done in userspace --RR */
 	for_each_present_cpu(cpu) {
 		if (num_online_cpus() >= setup_max_cpus)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:core/smp] kernel/smp: Define pr_fmt() for smp.c
  2016-10-26  5:37 [PATCH v2 1/3] kernel/smp: Define pr_fmt() for smp.c Michael Ellerman
  2016-10-26  5:37 ` [PATCH v2 2/3] kernel/smp: Make the SMP boot message common on all arches Michael Ellerman
  2016-10-26  5:37 ` [PATCH v2 3/3] kernel/smp: Tell the user we're bringing up secondary CPUs Michael Ellerman
@ 2016-10-26 10:07 ` tip-bot for Michael Ellerman
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Michael Ellerman @ 2016-10-26 10:07 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: mingo, hpa, bp, tglx, linux-kernel, mpe

Commit-ID:  ca7dfdbb33675151ad0854aea11340f95c38aff3
Gitweb:     http://git.kernel.org/tip/ca7dfdbb33675151ad0854aea11340f95c38aff3
Author:     Michael Ellerman <mpe@ellerman.id.au>
AuthorDate: Wed, 26 Oct 2016 16:37:53 +1100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 26 Oct 2016 12:02:35 +0200

kernel/smp: Define pr_fmt() for smp.c

This makes all our pr_xxx()'s start with "smp: ", which helps pin down
where they come from and generally looks nice. There is actually only
one pr_xxx() use in smp.c at the moment, but we will add some more in
the next commit.

Suggested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Cc: akpm@osdl.org
Cc: jgross@suse.com
Cc: ak@linux.intel.com
Cc: tim.c.chen@linux.intel.com
Cc: len.brown@intel.com
Cc: peterz@infradead.org
Cc: richard@nod.at
Cc: jolsa@redhat.com
Cc: boris.ostrovsky@oracle.com
Cc: mgorman@techsingularity.net
Link: http://lkml.kernel.org/r/1477460275-8266-1-git-send-email-mpe@ellerman.id.au
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 kernel/smp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/smp.c b/kernel/smp.c
index bba3b20..2d1f15d 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -3,6 +3,9 @@
  *
  * (C) Jens Axboe <jens.axboe@oracle.com> 2008
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/irq_work.h>
 #include <linux/rcupdate.h>
 #include <linux/rculist.h>

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:core/smp] kernel/smp: Make the SMP boot message common on all arches
  2016-10-26  5:37 ` [PATCH v2 2/3] kernel/smp: Make the SMP boot message common on all arches Michael Ellerman
@ 2016-10-26 10:08   ` tip-bot for Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Michael Ellerman @ 2016-10-26 10:08 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, mingo, bp, mpe, hpa, tglx

Commit-ID:  92b23278298304f72bbc786a737f2646f4b9aa9d
Gitweb:     http://git.kernel.org/tip/92b23278298304f72bbc786a737f2646f4b9aa9d
Author:     Michael Ellerman <mpe@ellerman.id.au>
AuthorDate: Wed, 26 Oct 2016 16:37:54 +1100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 26 Oct 2016 12:02:35 +0200

kernel/smp: Make the SMP boot message common on all arches

Currently after bringing up secondary CPUs all arches print "Brought up
%d CPUs". On x86 they also print the number of nodes that were brought
online.

It would be nice to also print the number of nodes on other arches.
Although we could override smp_announce() on the other ~10 NUMA aware
arches, it seems simpler to just always print the number of nodes. On
non-NUMA arches there is just always 1 node.

Having done that, smp_announce() is no longer weak, and seems small
enough to just pull directly into smp_init().

Also update the printing of "%d CPUs" to be smart when an SMP kernel is
booted on a single CPU system, or when only one CPU is available, eg:

   smp: Brought up 2 nodes, 1 CPU

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: akpm@osdl.org
Cc: jgross@suse.com
Cc: ak@linux.intel.com
Cc: tim.c.chen@linux.intel.com
Cc: len.brown@intel.com
Cc: peterz@infradead.org
Cc: richard@nod.at
Cc: jolsa@redhat.com
Cc: boris.ostrovsky@oracle.com
Cc: mgorman@techsingularity.net
Link: http://lkml.kernel.org/r/1477460275-8266-2-git-send-email-mpe@ellerman.id.au
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/smpboot.c |  8 --------
 kernel/smp.c              | 13 +++++++------
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 42f5eb7..b9f0238 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -821,14 +821,6 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
 	return (send_status | accept_status);
 }
 
-void smp_announce(void)
-{
-	int num_nodes = num_online_nodes();
-
-	printk(KERN_INFO "x86: Booted up %d node%s, %d CPUs\n",
-	       num_nodes, (num_nodes > 1 ? "s" : ""), num_online_cpus());
-}
-
 /* reduce the number of lines printed when booting a large cpu count system */
 static void announce_cpu(int cpu, int apicid)
 {
diff --git a/kernel/smp.c b/kernel/smp.c
index 2d1f15d..4323c5d 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -546,14 +546,10 @@ void __init setup_nr_cpu_ids(void)
 	nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
 }
 
-void __weak smp_announce(void)
-{
-	printk(KERN_INFO "Brought up %d CPUs\n", num_online_cpus());
-}
-
 /* Called by boot processor to activate the rest. */
 void __init smp_init(void)
 {
+	int num_nodes, num_cpus;
 	unsigned int cpu;
 
 	idle_threads_init();
@@ -567,8 +563,13 @@ void __init smp_init(void)
 			cpu_up(cpu);
 	}
 
+	num_nodes = num_online_nodes();
+	num_cpus  = num_online_cpus();
+	pr_info("Brought up %d node%s, %d CPU%s\n",
+		num_nodes, (num_nodes > 1 ? "s" : ""),
+		num_cpus,  (num_cpus  > 1 ? "s" : ""));
+
 	/* Any cleanup work */
-	smp_announce();
 	smp_cpus_done(setup_max_cpus);
 }
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:core/smp] kernel/smp: Tell the user we're bringing up secondary CPUs
  2016-10-26  5:37 ` [PATCH v2 3/3] kernel/smp: Tell the user we're bringing up secondary CPUs Michael Ellerman
@ 2016-10-26 10:08   ` tip-bot for Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Michael Ellerman @ 2016-10-26 10:08 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: tglx, bp, hpa, mingo, linux-kernel, mpe

Commit-ID:  51111dce2509506d16efd321939895ff7ffe1dc2
Gitweb:     http://git.kernel.org/tip/51111dce2509506d16efd321939895ff7ffe1dc2
Author:     Michael Ellerman <mpe@ellerman.id.au>
AuthorDate: Wed, 26 Oct 2016 16:37:55 +1100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Wed, 26 Oct 2016 12:02:35 +0200

kernel/smp: Tell the user we're bringing up secondary CPUs

Currently we don't print anything before starting to bring up secondary
CPUs. This can be confusing if it takes a long time to bring up the
secondaries, or if the kernel crashes while doing so and produces no
further output.

On x86 they work around this by detecting when the first secondary CPU
comes up and printing a message (see announce_cpu()). But doing it in
smp_init() is simpler and works for all arches.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: akpm@osdl.org
Cc: jgross@suse.com
Cc: ak@linux.intel.com
Cc: tim.c.chen@linux.intel.com
Cc: len.brown@intel.com
Cc: peterz@infradead.org
Cc: richard@nod.at
Cc: jolsa@redhat.com
Cc: boris.ostrovsky@oracle.com
Cc: mgorman@techsingularity.net
Link: http://lkml.kernel.org/r/1477460275-8266-3-git-send-email-mpe@ellerman.id.au
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 kernel/smp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/smp.c b/kernel/smp.c
index 4323c5d..77fcdb9 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -555,6 +555,8 @@ void __init smp_init(void)
 	idle_threads_init();
 	cpuhp_threads_init();
 
+	pr_info("Bringing up secondary CPUs ...\n");
+
 	/* FIXME: This should be done in userspace --RR */
 	for_each_present_cpu(cpu) {
 		if (num_online_cpus() >= setup_max_cpus)

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-10-26 10:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-26  5:37 [PATCH v2 1/3] kernel/smp: Define pr_fmt() for smp.c Michael Ellerman
2016-10-26  5:37 ` [PATCH v2 2/3] kernel/smp: Make the SMP boot message common on all arches Michael Ellerman
2016-10-26 10:08   ` [tip:core/smp] " tip-bot for Michael Ellerman
2016-10-26  5:37 ` [PATCH v2 3/3] kernel/smp: Tell the user we're bringing up secondary CPUs Michael Ellerman
2016-10-26 10:08   ` [tip:core/smp] " tip-bot for Michael Ellerman
2016-10-26 10:07 ` [tip:core/smp] kernel/smp: Define pr_fmt() for smp.c tip-bot for Michael Ellerman

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