From: Joe Lawrence <joe.lawrence@redhat.com>
To: Masayoshi Mizuma <msys.mizuma@gmail.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Subject: Re: [PATCH] sched/debug: initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK
Date: Fri, 1 Feb 2019 17:33:19 -0500 [thread overview]
Message-ID: <26907f7f-7da8-b476-02b5-3d25dca05d6a@redhat.com> (raw)
In-Reply-To: <20190131134457.caj7vaestug4q2l3@gabell>
On 1/31/19 8:44 AM, Masayoshi Mizuma wrote:
> On Wed, Jan 30, 2019 at 09:14:00PM +0100, Peter Zijlstra wrote:
>> On Tue, Jan 29, 2019 at 10:12:45AM -0500, Masayoshi Mizuma wrote:
>>> From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
>>>
>>> register_sched_domain_sysctl() copies the cpu_possible_mask into
>>> sd_sysctl_cpus, but only if sd_sysctl_cpus hasn't already been
>>> allocated (ie, CONFIG_CPUMASK_OFFSTACK is set). However, when
>>> CONFIG_CPUMASK_OFFSTACK is not set, sd_sysctl_cpus is left uninitialized
>>> (all zeroes) and the kernel may fail to initialize sched_domain sysctl
>>> entries for all possible cpus.
>>>
>>> This is visible to the user if the kernel is booted with maxcpus=n, or
>>> if ACPI tables have been modified to leave cpus offline, and then
>>> checking for missing /proc/sys/kernel/sched_domain/cpu* entries.
>>>
>>> Fix this by separating the allocataion and initialization, and adding
>>> a flag to initialize the possible cpu entries while system booting only.
>>>
>>> Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
>>> Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
>>> Tested-by: Syuuichirou Ishii <ishii.shuuichir@jp.fujitsu.com>
>>> Tested-by: Tarumizu, Kohei <tarumizu.kohei@jp.fujitsu.com>
>>> ---
>>> kernel/sched/debug.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>>
>>> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
>>> index de3de997e245..9c6637f3e21d 100644
>>> --- a/kernel/sched/debug.c
>>> +++ b/kernel/sched/debug.c
>>> @@ -310,6 +310,7 @@ static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
>>>
>>> static cpumask_var_t sd_sysctl_cpus;
>>> static struct ctl_table_header *sd_sysctl_header;
>>> +static int register_sched_domain_sysctl_on_boot = 1;
>>>
>>> void register_sched_domain_sysctl(void)
>>> {
>>> @@ -344,9 +345,12 @@ void register_sched_domain_sysctl(void)
>>> if (!cpumask_available(sd_sysctl_cpus)) {
>>> if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
>>> return;
>>> + }
>>>
>>> + if (register_sched_domain_sysctl_on_boot) {
>>> /* init to possible to not have holes in @cpu_entries */
>>> cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
>>> + register_sched_domain_sysctl_on_boot = 0;
>>> }
>>>
>>> for_each_cpu(i, sd_sysctl_cpus) {
>>
>> I change it like the below. By keeping the initial value 0 it can go
>> into .bss instead of .data.
>
> Great, thanks!
> Should I re-post the patch as v2?
>
> - Masa
>
Peter's revision tests fine on my aarch64 box and would get my ACK,
however it ends up getting re-posted :)
Thanks,
-- Joe
>>
>> --- a/kernel/sched/debug.c
>> +++ b/kernel/sched/debug.c
>> @@ -315,6 +315,7 @@ void register_sched_domain_sysctl(void)
>> {
>> static struct ctl_table *cpu_entries;
>> static struct ctl_table **cpu_idx;
>> + static bool init_done = false;
>> char buf[32];
>> int i;
>>
>> @@ -344,7 +345,10 @@ void register_sched_domain_sysctl(void)
>> if (!cpumask_available(sd_sysctl_cpus)) {
>> if (!alloc_cpumask_var(&sd_sysctl_cpus, GFP_KERNEL))
>> return;
>> + }
>>
>> + if (!init_done) {
>> + init_done = true;
>> /* init to possible to not have holes in @cpu_entries */
>> cpumask_copy(sd_sysctl_cpus, cpu_possible_mask);
>> }
-- Joe
next prev parent reply other threads:[~2019-02-01 22:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 15:12 Masayoshi Mizuma
2019-01-29 16:16 ` Joe Lawrence
2019-01-30 20:14 ` Peter Zijlstra
2019-01-31 13:44 ` Masayoshi Mizuma
2019-02-01 22:33 ` Joe Lawrence [this message]
2019-02-04 9:02 ` [tip:sched/core] sched/debug: Initialize " tip-bot for Hidetoshi Seto
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=26907f7f-7da8-b476-02b5-3d25dca05d6a@redhat.com \
--to=joe.lawrence@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=msys.mizuma@gmail.com \
--cc=peterz@infradead.org \
--cc=seto.hidetoshi@jp.fujitsu.com \
/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®