From patchwork Tue Oct 17 05:23:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 153900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3910660vqb; Mon, 16 Oct 2023 22:24:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIZzu2SBREf9Ajpe2i0Gy95vDrENYLBsKy5V7uX8YoKrma01BIOzraA6GAJEJNoCAu6ROJ X-Received: by 2002:a05:6a00:1ca1:b0:6b3:c72d:b01 with SMTP id y33-20020a056a001ca100b006b3c72d0b01mr1285705pfw.1.1697520240361; Mon, 16 Oct 2023 22:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697520240; cv=none; d=google.com; s=arc-20160816; b=S07tL6WMWjjWLuDVrIFXHYkG7ogdQWgkXoSsAvRcX8PpyNVXSDqP75OYp4w6fCT/uO 1togJlMmKgoHQL/yqQSFRoy2cL4X2u+ZGNu9MlXrrgAdCqNLGuPpDiD7o/tpZLmcgt7v /JYNWmtP+bSvWtefQ51AaIRPhgSw/Rv4Ci7+dqe+aXQHd+Igb5a1oaeUHM/LYlenv2kE gsHsy3f5LkRSwHh5ApHfR+96VppAlY3NDT4ROxGoA7Grxc9MBL7C+15pv/Ej34z4qyE8 c03Q109PJBrippfq9con0bwT+cvsbJ+Xst5o2HrOgr1tvYAM3B4Xv0D1vocDRodu7IUv vArQ== 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 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id r3-20020aa79ec3000000b006be0b790ebfsi832605pfq.255.2023.10.16.22.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 22:24:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 478F380A236F; Mon, 16 Oct 2023 22:23:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234284AbjJQFXl (ORCPT + 19 others); Tue, 17 Oct 2023 01:23:41 -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 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 16 Oct 2023 22:23:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779978983473848502 X-GMAIL-MSGID: 1779978983473848502 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