From patchwork Tue Oct 10 08:19:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 150534 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp38424vqb; Tue, 10 Oct 2023 01:20:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGt96QuwTdNFXUWQYGDsAJV5SZxfrbHPIglbBl5GwwZCYL/ePZKfkufjJvMmhZjNMh9KdRU X-Received: by 2002:a81:4fc9:0:b0:599:da80:e1eb with SMTP id d192-20020a814fc9000000b00599da80e1ebmr19485106ywb.24.1696926000976; Tue, 10 Oct 2023 01:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696926000; cv=none; d=google.com; s=arc-20160816; b=ZFI724RDtBBRo3XUAFw1wXmKy80L6X7RGwqVk08ln+FGAVXg9oSghSVOziL3gToEI0 iIyZ7OOiO0ZK33K82LbmuZ2A4iOFxKjsII9X6JLjYNbyf+9+3tAHOmJDNAEOvc5GcGb7 Gc/KqmmdCelghscb6CAC6bLQDqsFGZDGO378agAiKp9FR7uzGV/+q/UptYcR6YufceXi oTE2XZYqv5H4La95cAR55ZbIBE3V+o5QRgnWD8Ur/0nI+uia7ih98PpDOLJUJVjxr+6d x8M8MyF2P6gOmiy0gWo5Ns674HtrGU9jPj3LYMxjDg/bLiiF3GcGSTcrMo/qn/mAVeaV Czzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=krtUQmSlb1m09HhIcJ/jP6C/QflQUzkrmaItwHGMfRw=; fh=NEJx2ZqiDOqPZcWwbDHdCbELSU4VIPzWVs2F1klVwqQ=; b=RDZ1OGLiLibXltA5UT+LW1bEcadnhC+BAg3I9pBFGqU+32lP9nC/J/vIPcs+wR6iRr iV4dc0FUmaTRWR8U2hOegVYWmJuJVj25IURTelz3sqhVMNejm14M4I2Qs/44H91pP/25 Z3K3bTD64xr8zDVnQL/ae04iw1tyKzFNvx8H6P7+qZKnspDhntT5e12Yrj+yz7rEDP2w n37K0+9Yps7AAWl5fgWamQIGR3aP8lQrHAZDjFJEsikvz/dK4na4yYJrdO9/QrV9CU/K 8x/BRpnUbjbpJnOv4Dz8hUzR4kzFDa3HFq6hu1JOnMHVQqfp6bHZBVYsecetB5DJ0qWH +odw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3sXeHpwl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id m16-20020a63fd50000000b0059d479f3da1si130065pgj.852.2023.10.10.01.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 01:20:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3sXeHpwl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 395908029659; Tue, 10 Oct 2023 01:19:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442729AbjJJITg (ORCPT + 20 others); Tue, 10 Oct 2023 04:19:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379439AbjJJITc (ORCPT ); Tue, 10 Oct 2023 04:19:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4693A4; Tue, 10 Oct 2023 01:19:31 -0700 (PDT) Date: Tue, 10 Oct 2023 08:19:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696925970; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=krtUQmSlb1m09HhIcJ/jP6C/QflQUzkrmaItwHGMfRw=; b=3sXeHpwlc19ZTlBI0oUOX1Bnchba2FKam4Y4CufzIZAwn91tXUtH2YRKq05x2pQubiLp4j giT/fVegzriMsKAUYsuucpcUkJV2hQKPPxOCpY3i/3J6E1RYVAt9Tkwu1MPKyeaCJ43vB3 2BB1oUQL+00hJvWY1kOn4Uq/y1i7hsEAG7AIUykwpGjDDukL2fwjBsk44sbVObOHI436Pb PKC4NNfUxJyE9XZ09v5Sr0fwBBMH+pBNxU0SUABy1HviL7D7R32jIZBEVjSMb18oO6GjQc EmzB7D3pVVBNAQSJUUuZrmen6A9InUcqeil4ev6CYlmY7cpsHFPi/7Ieh6ZMpQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696925970; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=krtUQmSlb1m09HhIcJ/jP6C/QflQUzkrmaItwHGMfRw=; b=jdmnkk8ZRGYQyG/pdN4qz8w93+ChYACpLYnI8nP2FTVsbv5rF7s5FLDN4dkecMVst0WONS YPLBBZ8I7bPWwoBw== From: "tip-bot2 for Sandipan Das" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/amd/uncore: Use rdmsr if rdpmc is unavailable Cc: Sandipan Das , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3Ce9d994e32a3fcb39fa59fcf43ab4260d11aba097=2E1696425?= =?utf-8?q?185=2Egit=2Esandipan=2Edas=40amd=2Ecom=3E?= References: =?utf-8?q?=3Ce9d994e32a3fcb39fa59fcf43ab4260d11aba097=2E16964251?= =?utf-8?q?85=2Egit=2Esandipan=2Edas=40amd=2Ecom=3E?= MIME-Version: 1.0 Message-ID: <169692596934.3135.13596342947023817018.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 10 Oct 2023 01:19:50 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778925665640404371 X-GMAIL-MSGID: 1779355878381322851 The following commit has been merged into the perf/core branch of tip: Commit-ID: 7ef0343855dc23a979a53b3143540f93f3e5bef8 Gitweb: https://git.kernel.org/tip/7ef0343855dc23a979a53b3143540f93f3e5bef8 Author: Sandipan Das AuthorDate: Thu, 05 Oct 2023 10:53:13 +05:30 Committer: Peter Zijlstra CommitterDate: Mon, 09 Oct 2023 16:12:24 +02:00 perf/x86/amd/uncore: Use rdmsr if rdpmc is unavailable Not all uncore PMUs may support the use of the RDPMC instruction for reading counters. In such cases, read the count from the corresponding PERF_CTR register using the RDMSR instruction. Signed-off-by: Sandipan Das Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/e9d994e32a3fcb39fa59fcf43ab4260d11aba097.1696425185.git.sandipan.das@amd.com --- arch/x86/events/amd/uncore.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index ff1d09c..2fe6239 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -96,7 +96,16 @@ static void amd_uncore_read(struct perf_event *event) */ prev = local64_read(&hwc->prev_count); - rdpmcl(hwc->event_base_rdpmc, new); + + /* + * Some uncore PMUs do not have RDPMC assignments. In such cases, + * read counts directly from the corresponding PERF_CTR. + */ + if (hwc->event_base_rdpmc < 0) + rdmsrl(hwc->event_base, new); + else + rdpmcl(hwc->event_base_rdpmc, new); + local64_set(&hwc->prev_count, new); delta = (new << COUNTER_SHIFT) - (prev << COUNTER_SHIFT); delta >>= COUNTER_SHIFT; @@ -164,6 +173,9 @@ out: hwc->event_base_rdpmc = pmu->rdpmc_base + hwc->idx; hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED; + if (pmu->rdpmc_base < 0) + hwc->event_base_rdpmc = -1; + if (flags & PERF_EF_START) event->pmu->start(event, PERF_EF_RELOAD);