Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1070147yba; Thu, 4 Apr 2019 03:43:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5b24tZeKRH2GbBsh7YCvQYcCNSF4N9FedPENGHBXhbXbWE+G+Mwh//SZQsXAKdIP6lMrW X-Received: by 2002:a63:618d:: with SMTP id v135mr5136701pgb.2.1554374594139; Thu, 04 Apr 2019 03:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554374594; cv=none; d=google.com; s=arc-20160816; b=wkXPf2T6jsxDypOCz18IWe+puVunwHIHrc6uwa/gQBHKh1zWB3zE2c1Ofjz4U7m+3K MNCKGkwoMJcPauNKISn4Ex5PErWgjRj3QChinkc2TlLuBErHXK7FENqhX1DHJVO4HDcF GYZvck2lUv8OGEIniyqyTlZ3wV0QxDvTBf3lW2c5ERDT+5jY0w5HffynKrDy2lo2ucp/ DDDkxy27Jfg922WuYwp0QK12dB1Q+uCnad+5PWKNui1XfrnA5OzGMSvSJZlBFbyeEWy6 3lPe+fGxBDamnA9zCyopWaMzm3bVHyr1XqB+BIgA/OQz9LHT3oRMA1aAajas3sO3t6To jNgA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nsTo96coKmKa5UgIsKKF5GH6MF7mANjIOVfTeg2GcnM=; b=zyhoGi8jp8T0VDTAajA0wm3QKusBlJWWoOI3F0SLE4XOQLhMV4Xj6KkNe8/N5shtzf L9aGu/gjZY9pAt9cyFOH2ua+quafiIA4NqRQG5aNlbRK47yC3AVmDEvO0zn5A1I4CdUD XW6SoJxpcKJsZBu75ip37tkRbr+nyRZAVC+SHkl7xNjcSBVs9B21oI75BI1oMsqFIHiq D/uo7+Q1wFNVulvkTsjfb5O5SD+Md/gOiX5K+UFYRkpolU3sBwV5O+YrIlTE9x4rO8tT VUCabBbpcPXTTOnSP+q1WvvDniPzsFNA6cRHMWZx0L8+jnHLy6OkLfLb3PLIWlktRWgq Y2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yqfeFbn3; 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 i8si15433584pgs.568.2019.04.04.03.42.59; Thu, 04 Apr 2019 03:43:14 -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=yqfeFbn3; 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 S1729491AbfDDKmS (ORCPT + 99 others); Thu, 4 Apr 2019 06:42:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:42606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729118AbfDDKmR (ORCPT ); Thu, 4 Apr 2019 06:42:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB6D92171F; Thu, 4 Apr 2019 10:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554374536; bh=IPTfPhu5Qe4Z1M2EE/TqDpjLZTkK3m6gCyCwZA7hiMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yqfeFbn3VuptIcLDPney2t8nUJc4pMPDjW++cwh5rQ+7+MbzvPocq2LfVh/STd45i +Vlnk+kGXwGHWnXalbA3rD/d30DFrG4cD5iVbmcUfnDyDsU6lDutqpuRzbOUOT6it5 YM6gx6Le1LY58hoas6y90DDLYYU2uZ2mpAZ+iOz4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Syuuichirou Ishii , "Tarumizu, Kohei" , Hidetoshi Seto , "Peter Zijlstra (Intel)" , Masayoshi Mizuma , Joe Lawrence , Linus Torvalds , Masayoshi Mizuma , Mike Galbraith , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 132/187] sched/debug: Initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK Date: Thu, 4 Apr 2019 10:47:49 +0200 Message-Id: <20190404084609.425410063@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 6383aa6a60ca..141ea9ff210e 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