kexec.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Pingfan Liu <kernelfans@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: cascardo@canonical.com, gpiccoli@linux.vnet.ibm.com,
	kexec@lists.infradead.org, paulus@ozlabs.org, mpe@ellerman.id.au,
	benh@kernel.crashing.org
Subject: [PATCHv4 2/3] powerpc, cpu: handling the special case when boot_cpuid greater than nr_cpus
Date: Mon, 12 Mar 2018 12:43:09 +0800	[thread overview]
Message-ID: <1520829790-14029-3-git-send-email-kernelfans@gmail.com> (raw)
In-Reply-To: <1520829790-14029-1-git-send-email-kernelfans@gmail.com>

For kexec -p, after boot_cpuid is mapping into the range of [0,
threads_per_core), then if nr_cpus is small, we will have the bitmap
[0,..., nr_cpus, ..., boot_cpuid, ...). This patch chooses cpus inside
the range of [boot_cpuid - nr_cpus +1, ..., boot_cpuid] to be online.

With this patch and the next, on a P9 machine with thread_per_core=4,
and set nr_cpus=2 for the crash kernel.
After
    taskset -c 11 sh -c "echo c > /proc/sysrq-trigger"
Then
    kdump:/sys/devices/system/cpu# cat possible
    2-3
    kdump:/sys/devices/system/cpu# cat present
    2-3
    kdump:/sys/devices/system/cpu# cat online
    2-3

Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
---
 arch/powerpc/kernel/setup-common.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 1a67344..6920b5e 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -462,6 +462,8 @@ void __init smp_setup_cpu_maps(void)
 	struct device_node *dn;
 	struct device_node *boot_dn = NULL;
 	bool handling_bootdn = true;
+	int head_thread = 0;
+	int online_cnt = 0;
 	int cpu = 0;
 	int nthreads = 1;
 
@@ -499,13 +501,19 @@ void __init smp_setup_cpu_maps(void)
 			if (boot_cpuid < nthreads &&
 				be32_to_cpu(intserv[boot_cpuid]) == boot_cpuhwid) {
 				boot_dn = dn;
+				/* choose a bunch of continous threads */
+				if (boot_cpuid > nr_cpu_ids - 1) {
+					head_thread = boot_cpuid - nr_cpu_ids + 1;
+					/* keep the mapping of logical and thread */
+					cpu = head_thread;
+				}
 			}
 			if (boot_dn == NULL)
 				continue;
 		} else if (dn == boot_dn)
 			continue;
 
-		for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
+		for (j = head_thread; j < nthreads && online_cnt < nr_cpu_ids; j++) {
 			bool avail;
 
 			DBG("    thread %d -> cpu %d (hard id %d)\n",
@@ -520,13 +528,15 @@ void __init smp_setup_cpu_maps(void)
 			set_hard_smp_processor_id(cpu, be32_to_cpu(intserv[j]));
 			set_cpu_possible(cpu, true);
 			cpu++;
+			online_cnt++;
 		}
 
-		if (cpu >= nr_cpu_ids) {
+		if (online_cnt >= nr_cpu_ids) {
 			of_node_put(dn);
 			break;
 		}
 		if (handling_bootdn) {
+			head_thread = 0;
 			handling_bootdn = false;
 			goto again;
 		}
-- 
2.7.4


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2018-03-12  4:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12  4:43 [PATCHv4 0/3] enable nr_cpus for powerpc Pingfan Liu
2018-03-12  4:43 ` [PATCHv4 1/3] powerpc, cpu: partially unbind the mapping between cpu logical id and its seq in dt Pingfan Liu
2018-03-13  2:58   ` Benjamin Herrenschmidt
2018-03-14  2:02     ` Pingfan Liu
2018-03-13  5:06   ` kbuild test robot
2018-03-12  4:43 ` Pingfan Liu [this message]
2018-03-12  4:43 ` [PATCHv4 3/3] ppc64 boot: Wait for boot cpu to show up if nr_cpus limit is about to hit Pingfan Liu

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=1520829790-14029-3-git-send-email-kernelfans@gmail.com \
    --to=kernelfans@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=cascardo@canonical.com \
    --cc=gpiccoli@linux.vnet.ibm.com \
    --cc=kexec@lists.infradead.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@ozlabs.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;
as well as URLs for NNTP newsgroup(s).