Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8099988imu; Tue, 4 Dec 2018 03:01:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/XToUgsx0CW0U1bDWxraKROc4ewIcJ2xUdylX8X4QsOCBL4oU1hoXT914bdBf9HFIrJoGGs X-Received: by 2002:a17:902:1745:: with SMTP id i63mr19113722pli.145.1543921269713; Tue, 04 Dec 2018 03:01:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921269; cv=none; d=google.com; s=arc-20160816; b=anNl9pPsjCXNNzW7/Jbh1Oak+p7QuJfeB6pcI4NO705j9rXjTYs/4bMcwpJ5j29RWG 2nxUyhrBB+1083v+BUsEWyC2c9pUzkgAN3rEa4PLMnpzUh0IwhXgme5+jqfNs4nYO2mC kPxc1P+yj/WycV7cvmP5YSJy2GQbs1TpP0z5ip3E3NXOqfCEffG8HjZjkx0zqWBXC1bV o4VDgvfORYAfB4dV4nDTQl5+YMFQ8tIPVu8tB7iP8NB0TT+Fwua+f8nDdT90wvV7ofXL Fzm6pT8laVNvRdXp4ImRtW4RMo7bDpYL7vBZ6tDKeTYOusv2ESqhQbxefUrKhO8YYy4q rG+g== 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=BUFWAzYwHGfGSBR2+OeGhoGrkWi/WZuIhWceX46j8Rg=; b=dB0DxCqJqmGn0VTWpGg+FDYZXEaZdcZLEram1kIB8eI12suU2ZE5KbF93oE+0f16e/ tuS2n49K8NhXHDgMo1AIAJ9+C5ZfxZ/A9nZLLOC5gYp4TP4tckGnuZjrm2fzr/et7/Om twqobr/sJh+pP7Lhh1Zr1zOMqsr3xjqyTQPw7m+f2NLQZdhBtvTJvFJ+wz8LutdENyoq /z5avKHimBbJbuWF+LW0QLQglOYbbDEnmjI/onjugAGkFuUGsaDdDT0nm01Ro0w71gzx B3FeU4Tx96pSQ5Zr72QjPELHzezkUjXP7YJau80qouCtzhkCEwko4JKMeUsV3SD+ym5f 2SQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Skn8P+pi; 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 e6si15014760pgk.201.2018.12.04.03.00.53; Tue, 04 Dec 2018 03:01:09 -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=pass header.i=@kernel.org header.s=default header.b=Skn8P+pi; 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 S1726890AbeLDK6I (ORCPT + 99 others); Tue, 4 Dec 2018 05:58:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:42250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726881AbeLDK6G (ORCPT ); Tue, 4 Dec 2018 05:58:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 8EF9520878; Tue, 4 Dec 2018 10:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921085; bh=X+k8CePXtJQcEHkQMp+gcHYllhsjrpYmimqMgmUPlNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Skn8P+pi+gh7QrpK6FCDY+yulNn1YoryTd8d7dpY2JMHh4ebo98zL8KbBwu65K9r3 0gzlnU6Gif8tEXAE5wPI8aedQSTFWWaKD6qkfOtor7QiolSiebcVHHBpdnsSbE8qUt 7fns0pvhkhKJ9V8/FxqACngS1z4hMf3Ldl/TaH4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Thomas Gleixner , Ingo Molnar , Andy Lutomirski , Linus Torvalds , Jiri Kosina , Tom Lendacky , Josh Poimboeuf , Andrea Arcangeli , David Woodhouse , Tim Chen , Andi Kleen , Dave Hansen , Casey Schaufler , Asit Mallick , Arjan van de Ven , Jon Masters , Waiman Long , Dave Stewart , Kees Cook Subject: [PATCH 4.19 040/139] sched/smt: Make sched_smt_present track topology Date: Tue, 4 Dec 2018 11:48:41 +0100 Message-Id: <20181204103651.627721480@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@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. ------------------ From: Peter Zijlstra (Intel) peterz@infradead.org commit c5511d03ec090980732e929c318a7a6374b5550e upstream Currently the 'sched_smt_present' static key is enabled when at CPU bringup SMT topology is observed, but it is never disabled. However there is demand to also disable the key when the topology changes such that there is no SMT present anymore. Implement this by making the key count the number of cores that have SMT enabled. In particular, the SMT topology bits are set before interrrupts are enabled and similarly, are cleared after interrupts are disabled for the last time and the CPU dies. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Jiri Kosina Cc: Tom Lendacky Cc: Josh Poimboeuf Cc: Andrea Arcangeli Cc: David Woodhouse Cc: Tim Chen Cc: Andi Kleen Cc: Dave Hansen Cc: Casey Schaufler Cc: Asit Mallick Cc: Arjan van de Ven Cc: Jon Masters Cc: Waiman Long Cc: Greg KH Cc: Dave Stewart Cc: Kees Cook Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20181125185004.246110444@linutronix.de Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5741,15 +5741,10 @@ int sched_cpu_activate(unsigned int cpu) #ifdef CONFIG_SCHED_SMT /* - * The sched_smt_present static key needs to be evaluated on every - * hotplug event because at boot time SMT might be disabled when - * the number of booted CPUs is limited. - * - * If then later a sibling gets hotplugged, then the key would stay - * off and SMT scheduling would never be functional. + * When going up, increment the number of cores with SMT present. */ - if (cpumask_weight(cpu_smt_mask(cpu)) > 1) - static_branch_enable_cpuslocked(&sched_smt_present); + if (cpumask_weight(cpu_smt_mask(cpu)) == 2) + static_branch_inc_cpuslocked(&sched_smt_present); #endif set_cpu_active(cpu, true); @@ -5793,6 +5788,14 @@ int sched_cpu_deactivate(unsigned int cp */ synchronize_rcu_mult(call_rcu, call_rcu_sched); +#ifdef CONFIG_SCHED_SMT + /* + * When going down, decrement the number of cores with SMT present. + */ + if (cpumask_weight(cpu_smt_mask(cpu)) == 2) + static_branch_dec_cpuslocked(&sched_smt_present); +#endif + if (!sched_smp_initialized) return 0;