linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: wangkefeng.wang@huawei.com (Kefeng Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: Support hard limit of cpu count by nr_cpus
Date: Fri, 5 Aug 2016 14:03:55 +0800	[thread overview]
Message-ID: <1470377035-1591-1-git-send-email-wangkefeng.wang@huawei.com> (raw)

Enable the hard limit of cpu count by nr_cpus on arm64.
The code is borrowed from MIPS.

Reported-by: Shiyuan Hu <hushiyuan@huawei.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 arch/arm64/kernel/setup.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 536dce2..597b777 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -224,6 +224,21 @@ static void __init request_standard_resources(void)
 
 u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
 
+static void __init prefill_possible_map(void)
+{
+	int i, possible = num_possible_cpus();
+
+	if (possible > nr_cpu_ids)
+		possible = nr_cpu_ids;
+
+	for (i = 0; i < possible; i++)
+		set_cpu_possible(i, true);
+	for (; i < NR_CPUS; i++)
+		set_cpu_possible(i, false);
+
+	nr_cpu_ids = possible;
+}
+
 void __init setup_arch(char **cmdline_p)
 {
 	pr_info("Boot CPU: AArch64 Processor [%08x]\n", read_cpuid_id());
@@ -285,6 +300,7 @@ void __init setup_arch(char **cmdline_p)
 	cpu_read_bootcpu_ops();
 	smp_init_cpus();
 	smp_build_mpidr_hash();
+	prefill_possible_map();
 
 #ifdef CONFIG_VT
 #if defined(CONFIG_VGA_CONSOLE)
-- 
1.7.12.4

             reply	other threads:[~2016-08-05  6:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05  6:03 Kefeng Wang [this message]
2016-08-05  8:32 ` [PATCH] arm64: Support hard limit of cpu count by nr_cpus Will Deacon
2016-08-05  9:58   ` Kefeng Wang
2016-08-05 10:19     ` Suzuki K Poulose
2016-08-08  5:29       ` Kefeng Wang
2016-08-08  6:05       ` [PATCH v2] " Kefeng Wang
2016-08-08 10:50         ` Suzuki K Poulose
2016-08-08 11:28           ` Kefeng Wang
2016-08-08 12:52             ` Suzuki K Poulose
2016-08-09  1:15               ` Kefeng Wang
2016-08-09  2:30               ` [PATCH v3] " Kefeng Wang

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=1470377035-1591-1-git-send-email-wangkefeng.wang@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.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).