From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 061AAC4360F for ; Thu, 4 Apr 2019 10:42:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8FB4214AF for ; Thu, 4 Apr 2019 10:42:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554374534; bh=vni2/i4c8GhakK2w2EUjsFfFtDtf4e+bZfULiLKCx4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cPdkvZgs5OjKiwTpawhZG3WGkHaZeorNZPlyizbjX2u7k1kNOJV0c9LPJFt5NMBYL jg4uOZqRedZ85Dlw0crg736lPC7+NHIKAoj9d259M6gc1LqWEkMnxSska8FxdwaNt7 5KIYkD1lLXmNPZlxbdlzfeqZCYzy399lk9NOfW8s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728935AbfDDKmO (ORCPT ); Thu, 4 Apr 2019 06:42:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:42528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbfDDKmO (ORCPT ); Thu, 4 Apr 2019 06:42:14 -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 4D7DD20855; Thu, 4 Apr 2019 10:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554374533; bh=vni2/i4c8GhakK2w2EUjsFfFtDtf4e+bZfULiLKCx4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GzcJi+q6trFS7Mq2dIXK7QE4utVyUV2noHZnmDzsv+2zlH/CyAY0ppCIdlNOHKLA/ FBb4iCZlhzlw9x+m5beJ+rD7SB4/JZ4+8Q5vTGyKaXRc+uDmJP5QUpUaTs3jzflkrF qafb+ihQyxHjgQClzdA7zvXIqqFRuly8tP1MdTX0= 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.14 086/121] sched/debug: Initialize sd_sysctl_cpus if !CONFIG_CPUMASK_OFFSTACK Date: Thu, 4 Apr 2019 10:47:54 +0200 Message-Id: <20190404084549.907798535@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084545.245659903@linuxfoundation.org> References: <20190404084545.245659903@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: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.14-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 2f93e4a2d9f6..187c04a34ba1 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -339,6 +339,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; @@ -368,7 +369,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