linux-mips
[Top] [All Lists]

[PATCH V3 1/8] MIPS: Support hard limit of cpu count (nr_cpu_ids)

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH V3 1/8] MIPS: Support hard limit of cpu count (nr_cpu_ids)
From: Huacai Chen <chenhc@lemote.com>
Date: Thu, 26 Jun 2014 11:41:25 +0800
Cc: John Crispin <john@phrozen.org>, "Steven J. Hill" <Steven.Hill@imgtec.com>, Aurelien Jarno <aurelien@aurel32.net>, linux-mips@linux-mips.org, Fuxin Zhang <zhangfx@lemote.com>, Zhangjin Wu <wuzhangjin@gmail.com>, Huacai Chen <chenhc@lemote.com>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9G5Kra3P8kiDOwpfEOGxFwD43+3am/iANWMx8mWHd2Y=; b=ocYjE0TaaYfE1asJrqkfZCb6meoiQLeAHzQGDqa8wf1WIVfztY3QK5LXEwofiIYYRK 8+AFTxTvOZLMgucBNhppJrRobimgNukzfhA9LPnodPx6NAHmf+FB3ZYCrJiGGMsSSQWT wRlGNdoA8EGR+XQV4JXHdvHL2GxO+SF+YTK4qFalGdHBjX6L5jHK8x4sIaDSII3b707n FmtV9u9BvE72B4nob8NhVWBxLasRYSbYQGGwWAtW3OiVmwh/j75VmYBZ7R+hSt+bRTZz H8EZSShHniZsId4gbmYhswV4+IDx+oSYMTINHaQixu413p4Tgzj7V3V3QCN4FcdMa3Xy Pv3Q==
In-reply-to: <1403754092-26607-1-git-send-email-chenhc@lemote.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1403754092-26607-1-git-send-email-chenhc@lemote.com>
Sender: linux-mips-bounce@linux-mips.org
On MIPS currently, only the soft limit of cpu count (maxcpus) has its
effect, this patch enable the hard limit (nr_cpus) as well. Processor
cores which greater than maxcpus and less than nr_cpus can be taken up
via cpu hotplug. The code is borrowed from X86.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Reviewed-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
---
 arch/mips/kernel/setup.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index a842154..2f01201 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -729,6 +729,25 @@ static void __init resource_init(void)
        }
 }
 
+#ifdef CONFIG_SMP
+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;
+}
+#else
+static inline void prefill_possible_map(void) {}
+#endif
+
 void __init setup_arch(char **cmdline_p)
 {
        cpu_probe();
@@ -752,6 +771,7 @@ void __init setup_arch(char **cmdline_p)
 
        resource_init();
        plat_smp_setup();
+       prefill_possible_map();
 
        cpu_cache_init();
 }
-- 
1.7.7.3


<Prev in Thread] Current Thread [Next in Thread>