Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6440278imu; Wed, 30 Jan 2019 14:58:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Ui8M4Yuxdk2Et9CyWOPOgC5E3v/b0JLXcpjn9ggI7+qSMySxi325BVIs7ak3n5Rxtwx49 X-Received: by 2002:a63:4b60:: with SMTP id k32mr29057220pgl.186.1548889139637; Wed, 30 Jan 2019 14:58:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548889139; cv=none; d=google.com; s=arc-20160816; b=e1a7o2n7cXlO3FZsQLGsY1Pw6gPxxJnSIiRGz4WFiLuMYC7OnZNdxITieRXAwJFThg HAC5NRiP7/d5fQFShOxMJimD5hSAxKqJoFBenqkrMDLkXJb71Wl5PoGspyhQwJ4fpeAo USzdjMX4UbtEbNnxfoN15ogGeHwuFy4GZt7GwBnZfsjhXfa4Z6CTONAHKBqqKWTLpyHe /K0EQrnoaY9istVv7vWNpkzOojdipv0kz8Ep5a+jH1l5yfcBHHT5sVYr3CU5NwZozkTs /nwS2BJgO+Xe0qPiNvIwnY+0sMtIMBmY10s5rVU9ggjiAq+Y+AihDlVo9IHLr3Liskre q26g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=IAxl67UUajweenS+RqqsqKt9ooBaZ0TFo8mDUHMa8SM=; b=B4Hgj2V04wZgVC3wQ/3B2ditD0JD5LqlRDIukVroPXtPnpcS/4PEShZ3rlSWLpdh6X vLqjo8pRu9fB/wgBquu1mjbRyG7ux+BIanL0tAgxjRW5mDzkQCUsUGqW2lUmpuz1w4h6 vmbb9IZVZuDWL6HdMRt49BrLBArK6Wfwiz/DcN5YWcH/GKHQj4dbLoLQFrm+GXIxkPjY 5VrfUWATBmEKqWqAB79/4skd3pcmA7fRY7XX8yObXyYF15cgH2CUK+U5h9ubxk92ywPG Mga7ZZTh/IiXeW7MPUuvlZNRt4CFfmwcRNA4yE2fNYviokikdEJZbQr0QS/ZHWoLQICS roEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=E5UwMToC; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si2765858plt.290.2019.01.30.14.58.11; Wed, 30 Jan 2019 14:58:59 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=E5UwMToC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731554AbfA3UOF (ORCPT + 99 others); Wed, 30 Jan 2019 15:14:05 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:36622 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728446AbfA3UOE (ORCPT ); Wed, 30 Jan 2019 15:14:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IAxl67UUajweenS+RqqsqKt9ooBaZ0TFo8mDUHMa8SM=; b=E5UwMToCrvwAsoT5YCJOivoCt 1F8eElxTBRyfGgHpohsq3ue3VBcfsGt2KHE0lJX5CheWRkFRgoKsCJ+5w4HtJv4dPONwDkZw+N6mA tDSW2NlMKeXT/5HMcrYUeGFEUNxgwOtnrD6uuD8EJZEgSwskzy8Z+UoqXTu98yTrftFqbwIzkNPyG c14NHTPEiCMpRTN+pFBzgNw3XH445szbDQsBikv2qGkLyZ7LyUNMg0nP50dze+x4c31GOfuy2wtwn luPYydoX5+BN5Pl7Rszp6eSvDQD6JdLTJtYSdBTG0wfN+6vts727bO8yrmJGjx0aDAS+8L5+4pNot CjMcRTfIQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gowFF-0007WB-Uo; Wed, 30 Jan 2019 20:14:02 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 52DEB20179289; Wed, 30 Jan 2019 21:14:00 +0100 (CET) Date: Wed, 30 Jan 2019 21:14:00 +0100 From: Peter Zijlstra To: Masayoshi Mizuma Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Hidetoshi Seto , Joe Lawrence Subject: Re: [PATCH] sched/debug: initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK Message-ID: <20190130201400.GH2278@hirez.programming.kicks-ass.net> References: <20190129151245.5073-1-msys.mizuma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190129151245.5073-1-msys.mizuma@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. --- 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); }