From patchwork Thu Nov 24 12:02:56 2022 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: 25489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3356484wrr; Thu, 24 Nov 2022 04:09:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4NwIcpXH656hPSBvLtSNIDrOAUwcFxF1buHJBq7JOv+eK8H1XRVdwHc25efKrQSrAqceiK X-Received: by 2002:a17:907:270e:b0:78d:3c82:a875 with SMTP id w14-20020a170907270e00b0078d3c82a875mr11865232ejk.465.1669291744337; Thu, 24 Nov 2022 04:09:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669291744; cv=none; d=google.com; s=arc-20160816; b=WamjMz/NJq9EEG3ScpOrBC08miq1H1Qvgu4Z7rJOE7dhFfoUW5sSaNP/JYABo13AIj a/76WIxPjNBNFyI5TPOe7YzgTbVmCQ9R4h/Nm2tJ+6OyUPAimObI+yWWhx/5LBFrHDGe Y6fQ9baUySNLSB3rEq1HJkLO0L7EVMMmz3RyEBLCESLWYUoguMmtMhZ2oU5UO7kbFNwM RAjUr5rodrYMzixLlxv61w52zm+7UEtO3QNLdfLFQbzd33wiP1gFUsBiJnu8KbpQM7Sk YRBrDSKrGxan+uhej4Nz9M2LLsEl/NN1f0tPXbbpGhBopZD6TIl49tw/ukuS25zLscws 4q3Q== 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=8ef96xZAPR2NhzOZjjgPf5exhDtysRveXtabXSfWMkk=; b=hgi/26/iEPtUZKNoWj9TzXpbX4yW9Y+MAjc6x+7bvkiX1PHinJEI7ikm3LALaQ9BrZ NVGfaECzFQv1gF8lP65WhHiHpllpM1sh9ngMZ0rowmcRL7+ZDp+BG24fc0EI7ttJa/PG XVOUMMRDa6zjp5L3CUFusNN83KMSK/AHEVjmutnxi/Q94BWxp00r+BLH7Tph3q7KmUK7 3soNBO8JeCkm+cquRp9+UE8J4bUhkMHgGX9Hf58pyt/dPqgSv1EDjMhGl2C6iOFrisnM KQR1bSanQPqnAv7FWJyUxKmk08HwFXXMbkAlIShANCPb97i51ZQnlA42G6/YhZ7KedX1 527w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UHrRhu40; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Ylaq+xJP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wz5-20020a170906fe4500b0078d3babe59bsi754214ejb.401.2022.11.24.04.08.39; Thu, 24 Nov 2022 04:09:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=UHrRhu40; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Ylaq+xJP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229995AbiKXMDY (ORCPT + 99 others); Thu, 24 Nov 2022 07:03:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbiKXMDB (ORCPT ); Thu, 24 Nov 2022 07:03:01 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9182A5ADE8; Thu, 24 Nov 2022 04:02:59 -0800 (PST) Date: Thu, 24 Nov 2022 12:02:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669291378; 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=8ef96xZAPR2NhzOZjjgPf5exhDtysRveXtabXSfWMkk=; b=UHrRhu40rWAAf5CrOQZQM831XdVhtrbeqdeX9tYXqPTwbg99HB35E6PRcxVG9XrQ34U+hI n3svGd8fyISr5aRhHLXp0gt3AHbUQDnUGskYhF/KgTNPscDxKUlmlo9MjFHFyJ0uB3RH43 eZwLJEC1prXvUeH6tyiWzOmNE7XpD1MBTxPM2viRSdUF/HWTW65CNuY9lAJ5weML0mdG7S MoxVXosbGS1FLjOyDhLA8GzpVbdSYP2N+zowHJr6ZZbPNqw7XpF/utbC/vOgcyh4olf7ZI D4xnzskkzVNJdmnooM3PgQ/McSqr5N9eOjxNHE+8vjxHuXPc1asCdATmTN1/IQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669291378; 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=8ef96xZAPR2NhzOZjjgPf5exhDtysRveXtabXSfWMkk=; b=Ylaq+xJPy9f8U5GNZVcE9maFkUfoJrDZz8L5y2hwNKwCYu6riFRM0VtoZZcModH9qNI5Sm VAGE0L/tU5RgtiCg== From: "tip-bot2 for Alexander Antonov" 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/intel/uncore: Generalize get_topology() for SKX PMUs Cc: Alexander Antonov , "Peter Zijlstra (Intel)" , Kan Liang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221117122833.3103580-6-alexander.antonov@linux.intel.com> References: <20221117122833.3103580-6-alexander.antonov@linux.intel.com> MIME-Version: 1.0 Message-ID: <166929137695.4906.15833482649561923555.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749746655512129150?= X-GMAIL-MSGID: =?utf-8?q?1750379260554107130?= The following commit has been merged into the perf/core branch of tip: Commit-ID: 07813e2a59c93f10716ffa33d608d2c0685cf85b Gitweb: https://git.kernel.org/tip/07813e2a59c93f10716ffa33d608d2c0685cf85b Author: Alexander Antonov AuthorDate: Thu, 17 Nov 2022 12:28:27 Committer: Peter Zijlstra CommitterDate: Thu, 24 Nov 2022 11:09:22 +01:00 perf/x86/intel/uncore: Generalize get_topology() for SKX PMUs Factor out a generic code from skx_iio_get_topology() to skx_pmu_get_topology() to avoid code duplication. This code will be used by get_topology() procedure for SKX UPI PMUs in the further patch. Signed-off-by: Alexander Antonov Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Kan Liang Link: https://lore.kernel.org/r/20221117122833.3103580-6-alexander.antonov@linux.intel.com --- arch/x86/events/intel/uncore_snbep.c | 38 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index e14b963..254ba0a 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3837,14 +3837,14 @@ static void pmu_free_topology(struct intel_uncore_type *type) } } -static int skx_iio_get_topology(struct intel_uncore_type *type) +static int skx_pmu_get_topology(struct intel_uncore_type *type, + int (*topology_cb)(struct intel_uncore_type*, int, int, u64)) { int die, ret = -EPERM; - u64 configuration; - int idx; + u64 cpu_bus_msr; for (die = 0; die < uncore_max_dies(); die++) { - ret = skx_msr_cpu_bus_read(die_to_cpu(die), &configuration); + ret = skx_msr_cpu_bus_read(die_to_cpu(die), &cpu_bus_msr); if (ret) break; @@ -3852,17 +3852,35 @@ static int skx_iio_get_topology(struct intel_uncore_type *type) if (ret < 0) break; - for (idx = 0; idx < type->num_boxes; idx++) { - type->topology[die][idx].pmu_idx = idx; - type->topology[die][idx].iio->segment = ret; - type->topology[die][idx].iio->pci_bus_no = - (configuration >> (idx * BUS_NUM_STRIDE)) & 0xff; - } + ret = topology_cb(type, ret, die, cpu_bus_msr); + if (ret) + break; } return ret; } +static int skx_iio_topology_cb(struct intel_uncore_type *type, int segment, + int die, u64 cpu_bus_msr) +{ + int idx; + struct intel_uncore_topology *t; + + for (idx = 0; idx < type->num_boxes; idx++) { + t = &type->topology[die][idx]; + t->pmu_idx = idx; + t->iio->segment = segment; + t->iio->pci_bus_no = (cpu_bus_msr >> (idx * BUS_NUM_STRIDE)) & 0xff; + } + + return 0; +} + +static int skx_iio_get_topology(struct intel_uncore_type *type) +{ + return skx_pmu_get_topology(type, skx_iio_topology_cb); +} + static struct attribute_group skx_iio_mapping_group = { .is_visible = skx_iio_mapping_visible, };