Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp999720ima; Fri, 1 Feb 2019 14:34:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IbtsFycIEipBdYzLgVy7mKZGgK0B6KDWG7NWhv5FtckYABRxRBtnHBQAm0CgjFy/jTEpeGd X-Received: by 2002:a63:f412:: with SMTP id g18mr4097558pgi.262.1549060442521; Fri, 01 Feb 2019 14:34:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549060442; cv=none; d=google.com; s=arc-20160816; b=gQBEcCuQZ9fWfISBOEmrmRPgIoMhN6dRDUVmP/GdqT9S4cNCg+G/V8JQjqslwfjwWW 490C5N5u0vQy12FT3OI3AJHZ8Pn/7O/ERbmEb7/cIohh+lUKDzRh7/bV49q2+r5wly5L GeurhavXwJ41mDVtiixSOfW4lqYgpIVSA5J8GyTzz13wAMb8Auyw9LLfDugap9qFVmA2 aJdZK1IAUOAZjCS3fTjDQ/aXBtdvlV8ZhiHHJ49p/n1aYH/PPVt9Zd7nC1tj2H2WNWI4 VypwVcUpmfZ70CRpgiodRTIBd0iEaocCXpRtENQqxmfLb8z4FvbeOa8h7sbJ5QLwbtxh KFsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=pBVGcr+MklW0Q7BZ06T5PlDdG27LTUgcBZ8GEyAT3ws=; b=NH4ufXBpfMwlE66zkQkrXzs2lXdukmXTl3DXoO0A1SCjrjph7i6CRwd8QJdFyAX4eU jo4cxSg7dxc7Ok7CoQidrvQAms3lrsKuTbDOdZbhlSMNSfMiFyEqNsUsYflCQ0e/FDIA pvi9OVGK4IIiZ5Vt9i02rbJlEbwfP9zLP9Lo4AgyQG8oNjRa7kDL/ce+tzVIoP8ZdLmc CL1EfbquAOjrp8pUKPc4lSSmECO2ar4YjHLoUd75tlkuuXLTd2t7hAeODB5sl2xpLNRy VlKkyMWwYEMJQGEcWR1PWAnm+apQxNOASZopskajAeteJEavRo1/bYl/TPz5b5m4JCTC Sszg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si2518125plp.208.2019.02.01.14.33.47; Fri, 01 Feb 2019 14:34:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbfBAWdW (ORCPT + 99 others); Fri, 1 Feb 2019 17:33:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33186 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726483AbfBAWdW (ORCPT ); Fri, 1 Feb 2019 17:33:22 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 548118DA2D; Fri, 1 Feb 2019 22:33:21 +0000 (UTC) Received: from [10.18.17.208] (dhcp-17-208.bos.redhat.com [10.18.17.208]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 996DC60123; Fri, 1 Feb 2019 22:33:20 +0000 (UTC) Subject: Re: [PATCH] sched/debug: initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK To: Masayoshi Mizuma , Peter Zijlstra Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Hidetoshi Seto References: <20190129151245.5073-1-msys.mizuma@gmail.com> <20190130201400.GH2278@hirez.programming.kicks-ass.net> <20190131134457.caj7vaestug4q2l3@gabell> From: Joe Lawrence Message-ID: <26907f7f-7da8-b476-02b5-3d25dca05d6a@redhat.com> Date: Fri, 1 Feb 2019 17:33:19 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190131134457.caj7vaestug4q2l3@gabell> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 01 Feb 2019 22:33:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >>> >>> 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 >>> Reviewed-by: Masayoshi Mizuma >>> Tested-by: Syuuichirou Ishii >>> Tested-by: Tarumizu, Kohei >>> --- >>> 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