Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5644384img; Wed, 27 Mar 2019 12:19:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxccZbrzQmP/oEMLX+3yOsKmPqxlqa0WXsCpCYg/tRlf2bmB813M3vDDrFYcg5ktSr0FucR X-Received: by 2002:a63:115c:: with SMTP id 28mr9219905pgr.270.1553714369814; Wed, 27 Mar 2019 12:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714369; cv=none; d=google.com; s=arc-20160816; b=NmuloMa16wm9QqMeQua4UwrvE3P6Y0TJ2YRjmpoRD/PKJ1eJ9iAYYNM73wxDiMQFIG UFpKrRHmsDU1shktYE6yb3Dqd6rN/pPKGqmOD0N2KKDGsXPvFUljnPTZ0eFebUL8EdqD BKPvfSmg4OGWS1kmxNJGSwmacq0sKjPxXwSVZJsiee4T5bW11CDnIToJCh09DTXseWwv ulVfZiKq/eaRbQJpOkG6X0f93atB7phW6I8SCI3xHZ1+J7HYabn/LeVOH3FDwc634Xvy ljwHmi/VRc0Zso/XzgLY0uYsJLtACoA6o/o0u+ewpouloRUI5A8TU2iH4gOzuM9OVOj1 6kCQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qF3S2Re0H3Vl2qqlbp9X8FZvO6+X/xqU+kk+DLXJapU=; b=OUwKKPEBYanl3t44wptSqInO6Wf4bjCMkTmZfu7P3H5XD3K5ryL6EamKPD/Sy44Blw SkP49GMo+GgtHyar+qWLzXMUEWem550qPEcXgeQ1VuK7HXSxS9NJMGwndJrCX9Xd8o5F mb0obFiUxdzCLJ3vPaGauQpDrvbVKL/jIdGBMpEwX8NcIxwkjTAGU2V1tICnas89vRgX QLgMCfkWfOaADaFdizVmAiwGk1zmgS9JPA53s452JElSecq1Q/scOXSW52kaxG0uSJmM GsKw3cHR6mUQqCVEMlOys8ai9VVWDwPAVy6znG01iXQyHSC0gwyQGvCrpAbxbJLJDtwI 771A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dQJJDdoH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k16si449881pgb.587.2019.03.27.12.19.15; Wed, 27 Mar 2019 12:19:29 -0700 (PDT) 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=pass header.i=@kernel.org header.s=default header.b=dQJJDdoH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388283AbfC0SIB (ORCPT + 99 others); Wed, 27 Mar 2019 14:08:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733293AbfC0SHw (ORCPT ); Wed, 27 Mar 2019 14:07:52 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C0D232063F; Wed, 27 Mar 2019 18:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710071; bh=PB82dimxUV0AIAOicB9oJW7kARm/9ChLH+QTTPwdbCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dQJJDdoHeUYPvNLDdj/W0LF9lGl5ZxZlSK4soUN1Q1awVVKbWMT+3Z2c/QqwG5q9F yLdowINZX9DEzMQBd4IHhDiLpRpMd+dL40n6Jfj3YaX1dUU4u9idJEc7mPFDnXVmaI oiD6FojjJy+6u0e4/q1Zd52AvEFRVQm74LoQArBc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hidetoshi Seto , Peter Zijlstra , Linus Torvalds , Masayoshi Mizuma , Mike Galbraith , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 5.0 184/262] sched/debug: Initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK Date: Wed, 27 Mar 2019 14:00:39 -0400 Message-Id: <20190327180158.10245-184-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hidetoshi Seto [ Upstream commit 1ca4fa3ab604734e38e2a3000c9abf788512ffa7 ] 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 allocation and initialization, and adding a flag to initialize the possible CPU entries while system booting only. Tested-by: Syuuichirou Ishii Tested-by: Tarumizu, Kohei Signed-off-by: Hidetoshi Seto Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Masayoshi Mizuma Acked-by: Joe Lawrence Cc: Linus Torvalds Cc: Masayoshi Mizuma Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/20190129151245.5073-1-msys.mizuma@gmail.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- kernel/sched/debug.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index de3de997e245..8039d62ae36e 100644 --- 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); } -- 2.19.1