Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2939988rdg; Mon, 16 Oct 2023 22:24:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfwuvif/eBnDl62j/seVQRFndnKmoJa56dD3Dox7OCm3uW+COMJmR8sVoskpey5Yka78FB X-Received: by 2002:a17:902:f688:b0:1c9:e830:160c with SMTP id l8-20020a170902f68800b001c9e830160cmr1412995plg.16.1697520242301; Mon, 16 Oct 2023 22:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697520242; cv=none; d=google.com; s=arc-20160816; b=dTqK+v5DQJ1/i++WflnK0GMPxXljixbMDkYWgdhbO7imhsgX6URlaEpSsRC6gqZGT1 VDLMP9ksMAFJBBbgXfkKqW4a2Rm2GJLuRd/Az8N0U2QSgRujgzfnHe1tbjLFuKxoqt/G B4r9EH7sFLJ18EqO/QoDL1PNH83Sfc4Ww4Vb3zGckRgTW176+BNHty3CiwBygR0UuUcf T7yrBwAuDmNY+P12K90nVWBmuBKpk0W0zjA5EmPK5JklY/urujWFi9Blw8CeldKmv7LP mPljvA04HfO3JuQFggxSzXYVE8EI/xQByzk6St6OB4I43AIsS4SxSsRzwvv04437tr/M aDog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=spTyTS16cFev3mjdrq9Il74hdsFYfpHugSm8zajRqdU=; fh=b707ZlehUqHbBbDb3qCjPEW7g+Wmx1If0BLFmHa/lXg=; b=o6JYwJDA4Wij1wc59TtZuX0MHuwLgIZJWVwQlxTnNQawtkV5ShY7Tk+CfIp2p0zJyV OevLbxlr+L51pmfiljRr6lPPrnygjB8G0LWL7d7pdV6JCW0EHoa0JZIE2EPdNLXD4r5Q B+C99RNcmLCm+BWZTLfdJaGFeHIyVWsBgzxF1KGbygOPyFGawwGpCnLzKDjbIm/GKm92 4nJcJ+MK26J8auKHpvIwyJSUqKaaUv4vu+ffKfB8O1A4rajTTPdmI2zULQLIWha614Vj R7tSjGRVwXZRSYmIIyThH+dA3nQsv/oljLNnlTsCgSy2kPitltTp2oG/0WFc1i9ckRaz Eilw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id h13-20020a170902680d00b001b973681493si933755plk.16.2023.10.16.22.24.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 22:24:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C69AD80B7AE9; Mon, 16 Oct 2023 22:23:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234420AbjJQFXk (ORCPT + 99 others); Tue, 17 Oct 2023 01:23:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234391AbjJQFXg (ORCPT ); Tue, 17 Oct 2023 01:23:36 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E1B70B6 for ; Mon, 16 Oct 2023 22:23:34 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1A283FEC; Mon, 16 Oct 2023 22:24:15 -0700 (PDT) Received: from u200865.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 507A03F5A1; Mon, 16 Oct 2023 22:23:34 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, maz@kernel.org, anshuman.khandual@arm.com, krisman@suse.de, broonie@kernel.org, james.morse@arm.com, ionela.voinescu@arm.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [PATCH v2 2/3] arm64: cpufeature: Change DBM to display enabled cores Date: Tue, 17 Oct 2023 00:23:21 -0500 Message-ID: <20231017052322.1211099-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231017052322.1211099-1-jeremy.linton@arm.com> References: <20231017052322.1211099-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 16 Oct 2023 22:23:59 -0700 (PDT) Now that we have the ability to display the list of cores with a feature when its selectivly enabled, lets convert DBM to use that as well. Signed-off-by: Jeremy Linton --- arch/arm64/kernel/cpufeature.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 2dd695fc3472..b7b67bac0e60 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1848,6 +1848,8 @@ static int __init parse_kpti(char *str) early_param("kpti", parse_kpti); #ifdef CONFIG_ARM64_HW_AFDBM +static struct cpumask dbm_cpus __read_mostly; + static inline void __cpu_enable_hw_dbm(void) { u64 tcr = read_sysreg(tcr_el1) | TCR_HD; @@ -1883,35 +1885,22 @@ static bool cpu_can_use_dbm(const struct arm64_cpu_capabilities *cap) static void cpu_enable_hw_dbm(struct arm64_cpu_capabilities const *cap) { - if (cpu_can_use_dbm(cap)) + if (cpu_can_use_dbm(cap)) { __cpu_enable_hw_dbm(); + cpumask_set_cpu(smp_processor_id(), &dbm_cpus); + } } static bool has_hw_dbm(const struct arm64_cpu_capabilities *cap, int __unused) { - static bool detected = false; /* * DBM is a non-conflicting feature. i.e, the kernel can safely * run a mix of CPUs with and without the feature. So, we * unconditionally enable the capability to allow any late CPU * to use the feature. We only enable the control bits on the - * CPU, if it actually supports. - * - * We have to make sure we print the "feature" detection only - * when at least one CPU actually uses it. So check if this CPU - * can actually use it and print the message exactly once. - * - * This is safe as all CPUs (including secondary CPUs - due to the - * LOCAL_CPU scope - and the hotplugged CPUs - via verification) - * goes through the "matches" check exactly once. Also if a CPU - * matches the criteria, it is guaranteed that the CPU will turn - * the DBM on, as the capability is unconditionally enabled. + * CPU, if it is supported. */ - if (!detected && cpu_can_use_dbm(cap)) { - detected = true; - pr_info("detected: Hardware dirty bit management\n"); - } return true; } @@ -2448,18 +2437,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = { }, #ifdef CONFIG_ARM64_HW_AFDBM { - /* - * Since we turn this on always, we don't want the user to - * think that the feature is available when it may not be. - * So hide the description. - * - * .desc = "Hardware pagetable Dirty Bit Management", - * - */ + .desc = "Hardware dirty bit management", .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, .capability = ARM64_HW_DBM, .matches = has_hw_dbm, .cpu_enable = cpu_enable_hw_dbm, + .cpus = &dbm_cpus, ARM64_CPUID_FIELDS(ID_AA64MMFR1_EL1, HAFDBS, DBM) }, #endif -- 2.41.0