Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8118673imu; Tue, 4 Dec 2018 03:19:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/VLCe4sYtV7Cz91aPT1FsGW/YmetR5rcvZpujmsG+O6T+XBO9kv7KVEguMUZ1j1plLXLeMO X-Received: by 2002:a63:1766:: with SMTP id 38mr15949030pgx.299.1543922361332; Tue, 04 Dec 2018 03:19:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543922361; cv=none; d=google.com; s=arc-20160816; b=VSe2Q9y/AjglTDkSK3WYSniO7UbMv60mtz9X5nAQiO68IMJi7/qTCKp++Q+u2mN0Yl yjP6cOQ/x1d3OBVxQHM64HZnyEImYmH3GZ9MpTp4Xe4j3IXaoQkNdrbSh+Nmo8PGBK1Q KBnzrYmsd1CUM4KhV0CZ8odO8fj6uBNkRJ4uRGfEF9jZhBFSq/iaNnfpsxDvSgbOZUtC 3CN7bmpi1XwQBPvwShEBp+BQHyqCeCqaj+4fCXPK1F1lQ0taIHEF6FE1GJurNFO+v+JN 8dhp20/BUpRm9v32YyUszY+a/nfkjTg+ipETm1sf1Bl2QGi49RZmXWHL64G3b1rFfz+g R/zA== 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=WMWPR6rAfDal/ongkcV+SyJwkPVokeCz6CfSEEFMliM=; b=rSku41dc7c46Pds3g9xG2+9JYLbXlS7EbLDGYtYOlnG9UVzoQDsarwbQaau/AqASR7 IG2y6A6nrequAVTxhcDbntQd3UGaadzXoT+HsKQiquweI7cGgJnhb+x4JUd9C5Opzhco Rr/p/WLVeddpPxLs4boHGkPTKNhg3LMcK6KRxvWJ3zqbbeYJz1Coc77/G+gSPZd3MQaH b1r0IN8tcVyHe+FX9J2Kp9OLMRFOFkQiG8qr0eu0zlPc/H5MbaL8iiaKhf7ekf6p6mnq w9w91jlOkI0wng+EK0Vk4QBgsUIom1Cbbvpo/B4O0eWrRNCARG73TSzWbWBC2DesVY6X zGFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rE3oufYZ; 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 a124si17828063pfb.263.2018.12.04.03.19.06; Tue, 04 Dec 2018 03:19:21 -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=rE3oufYZ; 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 S1728031AbeLDLEn (ORCPT + 99 others); Tue, 4 Dec 2018 06:04:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:51904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728021AbeLDLEl (ORCPT ); Tue, 4 Dec 2018 06:04:41 -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 939B1214DE; Tue, 4 Dec 2018 11:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921480; bh=aCqfoQCmjqEVVva0g0UsUHNejmRvsBMIAL4O8d0axPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rE3oufYZ1j2cb+MtAIWLB7oIcRa1D1Z0/YU6Xoy73QoSBun2LXE+dWBb5mBc+xQTD T6p6GB3Gu6RlIQ8+eOAZIicDAjYse09yiEzqF8qCjmvBCjhIUog19UFLi5N0zYJQlL k8NoAzG0PO5EYvgtI7W2JDxNmsUH5DM+uSfE/EZ4= 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.14 087/146] sched/smt: Make sched_smt_present track topology Date: Tue, 4 Dec 2018 11:49:33 +0100 Message-Id: <20181204103730.330415318@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103726.750894136@linuxfoundation.org> References: <20181204103726.750894136@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.14-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 @@ -5617,15 +5617,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); @@ -5669,6 +5664,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;