Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp704888ybg; Tue, 28 Jul 2020 17:12:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFnDI0FDF9b/wItu2MpIYaPYhY4OxqxR+p6r6naEoOlAa2oVpj43t433YvQFz8QsWZuU1L X-Received: by 2002:aa7:d693:: with SMTP id d19mr29624215edr.317.1595981541537; Tue, 28 Jul 2020 17:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595981541; cv=none; d=google.com; s=arc-20160816; b=wUosvSQeMKAUsgUvkP2s7Y++dSFZuiMzOKcpf3PTfSxupBzJ3FOKxY0YAKb7uQiXtI fefVHc2Ik501g9WaAll68aNO+s+U9zSUwNtjandtZ3Lmh6qEGuxM6dyST+zmRFtfr6Vd N3+UTgx66ukw/+TolyPQFRY2+vMT3ELbc2DK0mmr/oPpExJIsQrLNvIo/wA2fFknpECJ KnYCjcgfh9wIYkgaK3t34xvBoWDTFvEkxno00xTJG9ltdz9UZym0rUQ5efRTFdOPCvgH bt6oEr1e/maRQtnaG8nTz2GkkjojGjabO4mP09hcSunII1SRXtZEjX6VduO857RXK1Ta iaUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:dkim-signature; bh=afOSpCcIkE9zWH372UUS4XxZhj2dLHR6YIsW46csYng=; b=vHdKxDmzUSgw+UKusbt03hYzLYwYXy0+7PWQnv9nffXlslhPlrhfW+vECW+N5A9hFJ nkNT8yMRh6F6sa4FLaYecwmhbREMsC6I+dMN58iSteLLCcvgp/SmRUTDkzLaAQ0SQiG1 v/TLPRelhswr5NOY0VmgbmvXdpcHPmzyW350hkc3I+BfwoB489ayljIDdRjP9rOE2gcS 47webjP7NBPSRhcXhcftA758CCbnOk9BpeS6z1JsUWoNE4u/jZYaQzUOMMLJHzxxFMo+ YugsY2U6SEb1hq51URm2SG3tUYVNEqWmhtnIeOs9bcJumZXi9ANnfXZlpFNF12i9WISO MKeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=iroqxxMo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nf1si34465ejb.527.2020.07.28.17.11.59; Tue, 28 Jul 2020 17:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=iroqxxMo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730610AbgG2ALj (ORCPT + 99 others); Tue, 28 Jul 2020 20:11:39 -0400 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:34595 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730568AbgG2ALh (ORCPT ); Tue, 28 Jul 2020 20:11:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1595981496; x=1627517496; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=afOSpCcIkE9zWH372UUS4XxZhj2dLHR6YIsW46csYng=; b=iroqxxMoOZyWKXOUSTZfZZxsDHW1HnapXs7k3uj8ggjgKdXqCypTMnGx +EsP6ss6BKcPHOdYOLnzZwdJCVdUks6OS0xOaymCstZ2o+Se2+lRfCZih C5PpCJQVsqapkzakZxkGdJ/D0TAtAi6EJig4YN8+NU164vsmU0EEzhJTK k=; IronPort-SDR: NhD4CF+q2Ar27nLK4skVboa7VqMcUHbJ9D2OkOm0p/l7gxaROjSTStX1efuCw2SV4ZzE1PGP+v XcQCcLsb5rGw== X-IronPort-AV: E=Sophos;i="5.75,408,1589241600"; d="scan'208";a="55578786" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1e-c7c08562.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 29 Jul 2020 00:11:29 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-c7c08562.us-east-1.amazon.com (Postfix) with ESMTPS id 2AE60240D95; Wed, 29 Jul 2020 00:11:25 +0000 (UTC) Received: from EX13D01UWA001.ant.amazon.com (10.43.160.60) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 29 Jul 2020 00:11:25 +0000 Received: from EX13MTAUWA001.ant.amazon.com (10.43.160.58) by EX13d01UWA001.ant.amazon.com (10.43.160.60) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 29 Jul 2020 00:11:24 +0000 Received: from localhost (10.143.192.232) by mail-relay.amazon.com (10.43.160.118) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 29 Jul 2020 00:11:23 +0000 From: Balbir Singh To: , CC: , , , , , , , , , Balbir Singh Subject: [PATCH v2 1/5] Add a per-cpu view of SMT state Date: Wed, 29 Jul 2020 10:10:59 +1000 Message-ID: <20200729001103.6450-2-sblbir@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200729001103.6450-1-sblbir@amazon.com> References: <20200729001103.6450-1-sblbir@amazon.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A new field smt_active in cpuinfo_x86 identifies if the current core/cpu is in SMT mode or not. This can be very helpful if the system has some of its cores with threads offlined and can be used for cases where action is taken based on the state of SMT. The follow up patches use this feature. Suggested-by: Thomas Gleixner Signed-off-by: Balbir Singh --- arch/x86/include/asm/processor.h | 2 ++ arch/x86/kernel/smpboot.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 03b7c4ca425a..23ea45dd6f14 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -136,6 +136,8 @@ struct cpuinfo_x86 { u16 logical_die_id; /* Index into per_cpu list: */ u16 cpu_index; + /* Is SMT active on this core? */ + bool smt_active; u32 microcode; /* Address space bits used by the cache internally */ u8 x86_cache_bits; diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index ffbd9a3d78d8..0b12f24ebfbb 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -645,6 +645,9 @@ void set_cpu_sibling_map(int cpu) threads = cpumask_weight(topology_sibling_cpumask(cpu)); if (threads > __max_smt_threads) __max_smt_threads = threads; + + for_each_cpu(i, topology_sibling_cpumask(cpu)) + cpu_data(i).smt_active = threads > 1; } /* maps the cpu to the sched domain representing multi-core */ @@ -1557,10 +1560,16 @@ static void remove_siblinginfo(int cpu) for_each_cpu(sibling, topology_die_cpumask(cpu)) cpumask_clear_cpu(cpu, topology_die_cpumask(sibling)); - for_each_cpu(sibling, topology_sibling_cpumask(cpu)) + + for_each_cpu(sibling, topology_sibling_cpumask(cpu)) { cpumask_clear_cpu(cpu, topology_sibling_cpumask(sibling)); + if (cpumask_weight(topology_sibling_cpumask(sibling)) == 1) + cpu_data(sibling).smt_active = false; + } + for_each_cpu(sibling, cpu_llc_shared_mask(cpu)) cpumask_clear_cpu(cpu, cpu_llc_shared_mask(sibling)); + cpumask_clear(cpu_llc_shared_mask(cpu)); cpumask_clear(topology_sibling_cpumask(cpu)); cpumask_clear(topology_core_cpumask(cpu)); -- 2.17.1