From: Pingfan Liu <kernelfans@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: x86@kernel.org, "Peter Zijlstra (Intel)" <peterz@infradead.org>,
Rik van Riel <riel@surriel.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Ingo Molnar <mingo@kernel.org>, Jiri Kosina <jkosina@suse.cz>,
Mukesh Ojha <mojha@codeaurora.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Lutomirski <luto@amacapital.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] smp: force all cpu to boot once under maxcpus option
Date: Wed, 24 Jul 2019 16:39:36 +0800 [thread overview]
Message-ID: <20190724083936.GA3965@dhcp-128-55.nay.redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1907221137090.1782@nanos.tec.linutronix.de>
On Mon, Jul 22, 2019 at 11:41:29AM +0200, Thomas Gleixner wrote:
> On Wed, 10 Jul 2019, Pingfan Liu wrote:
> >
> > +static inline bool maxcpus_allowed(unsigned int cpu)
> > +{
> > + /* maxcpus only takes effect during system bootup */
> > + if (smp_boot_done)
> > + return true;
> > + if (num_online_cpus() < setup_max_cpus)
> > + return true;
> > + /*
> > + * maxcpus should allow cpu to set CR4.MCE asap, otherwise the set may
> > + * be deferred indefinitely.
> > + */
> > + if (!per_cpu(cpuhp_state, cpu).booted_once)
> > + return true;
>
> As this is a x86 only issue, you cannot inflict this magic on every
> architecture.
OK.
In my developing patch which fixes nr_cpus issue, I takes the following way:
(I am diverted to other things, have not finished test yet, hope to
turn back soon.)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 362dd89..c009169 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -956,6 +956,87 @@ int common_cpu_up(unsigned int cpu, struct task_struct *idle)
return 0;
}
+void __init bring_capped_cpu_steady(void)
+{
[...]
+}
+
/*
* NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad
* (ie clustered apic addressing mode), this is a LOGICAL apic ID.
diff --git a/kernel/smp.c b/kernel/smp.c
index d155374..b04961c 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -560,6 +560,10 @@ void __init setup_nr_cpu_ids(void)
nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
}
+void __weak bring_capped_cpu_steady(void)
+{
+}
+
/* Called by boot processor to activate the rest. */
void __init smp_init(void)
{
@@ -579,6 +583,8 @@ void __init smp_init(void)
cpu_up(cpu);
}
+ /* force cpus capped by nr_cpus option into steady state */
+ bring_capped_cpu_steady();
num_nodes = num_online_nodes();
The initial motivation is to step around percpu area required by cpu hotplug
framework. But it also provide the abstraction of archs.
What do you think about resolving maxcpus by the similar abstraction?
>
> Aside of that this does not solve the problem at all because smp_init()
> still does:
>
> for_each_present_cpu(cpu) {
> if (num_online_cpus() >= setup_max_cpus)
> break;
Yes, this logic should be removed, then maxcpus_allowed() can take effect. But
now, it may take a quite different way to resolve it.
Thanks for your kindly review.
Regards,
Pingfan
> if (!cpu_online(cpu))
> cpu_up(cpu);
> }
>
> So the remaining CPUs are not onlined at all.
>
> Thanks,
>
> tglx
prev parent reply other threads:[~2019-07-24 8:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 8:37 Pingfan Liu
2019-07-22 9:41 ` Thomas Gleixner
2019-07-24 8:39 ` Pingfan Liu [this message]
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=20190724083936.GA3965@dhcp-128-55.nay.redhat.com \
--to=kernelfans@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jkosina@suse.cz \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=mojha@codeaurora.org \
--cc=peterz@infradead.org \
--cc=riel@surriel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®