From patchwork Mon Oct 17 22:26:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 3785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1670541wrs; Mon, 17 Oct 2022 15:32:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7/fjWtvcNZxj2kBlDIu2HFwYLS9ugCdJ2usTo+9sUTz6A3MVqV3NqOZxzjhGBbJ2j9x0XO X-Received: by 2002:a63:8b44:0:b0:45f:952f:c426 with SMTP id j65-20020a638b44000000b0045f952fc426mr12310723pge.623.1666045939071; Mon, 17 Oct 2022 15:32:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666045939; cv=pass; d=google.com; s=arc-20160816; b=XfjdD6fu+7ZRx612bfQyQkjsllUhlv+3dE4SMNizStonCmkaFdpPC8SXrjxbY5uRmU g2lE+Zr8Kb5AJj4Yj1Tu7YqZqnz1s0rf/6Gki4XjotggJ9uEDdzrKCHMf35RpOt2+5zn M7vjOsrrBfHigES93S95Spm6UpJRVn7ov1K5tISZ6lmC7JCxMAVTwwLzuzM1NXY5kKSz U9DKllmQb2WcbWzmpYgfKku/KLRr1erSxhUdenYRN27bY2rong01hUl0Y8edjKPLpsgo 6hTeiFvPkP/ZJHKiKoj+NWjkuwIGecxrmQK0WBLcMbindZV0wC6UxxZIgPvH/ZykVvmd dl/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=vBc5uQI4L44w2VOYUdGsR67oMZjdqOaBhzJv42OYO9w=; b=X0++9xPLS3cYujKHlf09Sg8TLnRXeZBz7ARJzJMg/KnQAUkJuHhQG2WniLeaOuWqOd GanLjeOcZHfmC/L61FeeKJOGGubIWr99EKIBYwGoTLiG2HPS+Su5eMlQUT0bJBgxWhEi m8Ulcip4YgpAkpLgRableAInjctt2sLrxMHuD613JN6ERrnBp+p8q8pq4EzQqvkc/gh5 ORKZg6iJgdKQEVILEnL90ALiMe8UJqBAtlTJ9O4en+RzyO5xU6C2vqZQqM9oN+ZuB3Fh sEveVxB+SGgLHMCI0zetct4xvY8nrnD1kbAQrzxUujCNEHce7sZwEywNs5wdW+ZgCvto 52LA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=YP9VHvNt; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a654c08000000b0043c9d3b9c83si13204380pgq.140.2022.10.17.15.32.04; Mon, 17 Oct 2022 15:32:19 -0700 (PDT) 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=@amd.com header.s=selector1 header.b=YP9VHvNt; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbiJQW1q (ORCPT + 99 others); Mon, 17 Oct 2022 18:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbiJQW1n (ORCPT ); Mon, 17 Oct 2022 18:27:43 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2075.outbound.protection.outlook.com [40.107.220.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEBA981699; Mon, 17 Oct 2022 15:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rd5YHmRFR4IMoToEJ3yqEv9CxLHx363QHd03U7MUcnE0qoSaLC24u7CHEjlIzWi2z3ckMj66DWIZahh4mpi2udeCIRo3m+7J7G12iGDKG7CH1hPkXsGVAKD5j2uWveV6hWvqmnbl4JLqKGlxPwQSkqFLKvcJJ22L8DBMRJ5xmsEM431X3qDT85RHm5uRCE2VjXT9O+OhQ50GP6reYu1wD5De7wZ3evShhU1D3sF4NIlP6hSFt0H7ygEaGXYaobecv6GWhS1Ju9Iw3K1xeLzE2D9iM1VucFHqvdq/pxHGJ5HL4seAbRMtS5OsOiafn/Q/UIurWzrzkh19IXQBTiGwOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vBc5uQI4L44w2VOYUdGsR67oMZjdqOaBhzJv42OYO9w=; b=Q9yqeVtMVIpD/jY+IvdkT/KrW9w+onDQfy5qZqy9i+PHNOiFWt9K54Hp8zHbV3rGPL1V9+q4SUlWSk9oF99SEJxgGXz4XCV9JIpfDlXue4Y0LjVlE02m38CL6I5Loccs4HaCq33npJ0EfDLzh9zrtT71ghK0JD7z5tlKuS04EY7EYtENk613+k6xMrfcNGOFvFvolaXGkgwQDkaHXxA+XR+LOXFBZ84byUqMkOaCUBK70QUsx+cnrtAj9mlACVNVDP5bzN/eP9GiJvDyiEE+bfiGMBh40IRl0dOJf82bir+L4YjA58y+kQU7ioVB1+m8Y6Cjb9UrlAQOlJj96xr2qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=alien8.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vBc5uQI4L44w2VOYUdGsR67oMZjdqOaBhzJv42OYO9w=; b=YP9VHvNtgnG36Hb6rVVx63MXCqaH+eOlumVo93XFu1A7mpfvZ/d+9hYbSXryScTTUNVrAKWFHuZdpEV+6YchmFem7VT6kSaFbo2JXRwIwrrqSVIcG2bXDAm/uyxVI+AGeZqEmmhD228UmISAFIqjbklzOywhEM+YCosHLypeqko= Received: from BN0PR02CA0046.namprd02.prod.outlook.com (2603:10b6:408:e5::21) by MN2PR12MB4440.namprd12.prod.outlook.com (2603:10b6:208:26e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Mon, 17 Oct 2022 22:27:06 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e5:cafe::b5) by BN0PR02CA0046.outlook.office365.com (2603:10b6:408:e5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31 via Frontend Transport; Mon, 17 Oct 2022 22:27:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Mon, 17 Oct 2022 22:27:05 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 17 Oct 2022 17:26:59 -0500 Subject: [PATCH v7 07/12] x86/resctrl: Add sysfs interface to read mbm_total_bytes event configuration From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , Date: Mon, 17 Oct 2022 17:26:53 -0500 Message-ID: <166604561380.5345.17668177010598977321.stgit@bmoger-ubuntu> In-Reply-To: <166604543832.5345.9696970469830919982.stgit@bmoger-ubuntu> References: <166604543832.5345.9696970469830919982.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT010:EE_|MN2PR12MB4440:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ff6a9f2-6240-43b5-d03a-08dab08eb884 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tgZHywpcPFrj6OeJpntb7TGgciC+2eDlRlRhi86pzFFzLgh9oBlKV62aZ4aOWui/mmThvg1d9vqnsSDLt632ipQ8B46a3Ky7RN667+CxyprV/1odg+TrAphRvMDAWB1rI75ba5dJHD5DgUa2Vw4iys2+SGEpWFqx2rO5SbxcMcsuTs+/p7a008sZKjPx+pGp0tY9F7ayyxNmOnZVE7F8Wqn4hGMZhk6VEKHbY0uWaRBVvBUn0Kz1lK5wpuiyRPafcV1eLWBbzOs+50t09Nd+M20V8UmR/KKkp5Pmgt9W8mcbWtqD8NO2t+dqvD0ULJC9B2NrOYMgAafCWJBhisD6r0uHY9e1mpBapAKAMHEIIo17HjcYH0uNCJkdJmL9qbEF03O/8puZgo/jUDmIJ9F3EfStanaMUNZrKeXnl3qSqAYE4tEEqTmoAM3bueJnQYevVtR6OEcEwFkRG09NZm4I845qWyBPWWZJ8f1drEvllgRQPJRZ2K4o+ZKu3C6ZAEJ5HKQq6MhcN13HKfQ8Q763mjogIqvgXB3PYNByPW785QYg2m1bDmUc4qqXJJlDvOo+3G3WbXBEguPWvxE4PuSMcnxGkCe+dlCW4hWWStd76qY/m9dUlsVrTX9ZcbuBOoj58yTbY2u5f6SEZEnWVM+14ylBnXjA8+DqRDxoiSA/xGe5jypXHB78FLzs1vhfbmj7t1fX/rLjrGNJG6Zq79KgK5ZLz5EvwhN4OZ9vekjx19BVw6cAw0LsEIvb93bqvMjTXLBGzteagKevbGBvFtgDn+2VJKEAjQW1amjLc0jO6yTpRm53uZ8uHaCPXGJ+y+mMDCZe/CvqFvyNdOTMtmgf0g== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(7916004)(346002)(376002)(396003)(39860400002)(136003)(451199015)(36840700001)(46966006)(40470700004)(356005)(426003)(47076005)(336012)(186003)(2906002)(16526019)(83380400001)(82740400003)(33716001)(40480700001)(40460700003)(82310400005)(36860700001)(103116003)(86362001)(81166007)(16576012)(54906003)(110136005)(44832011)(41300700001)(8936002)(316002)(7416002)(5660300002)(478600001)(26005)(9686003)(70206006)(8676002)(70586007)(4326008)(6666004)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2022 22:27:05.3434 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ff6a9f2-6240-43b5-d03a-08dab08eb884 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4440 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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?1746975786604941254?= X-GMAIL-MSGID: =?utf-8?q?1746975786604941254?= The current event configuration can be viewed by the user by reading the configuration file /sys/fs/resctrl/info/L3_MON/mbm_total_config. The event configuration settings are domain specific and will affect all the CPUs in the domain. Following are the types of events supported: ==== =========================================================== Bits Description ==== =========================================================== 6 Dirty Victims from the QOS domain to all types of memory 5 Reads to slow memory in the non-local NUMA domain 4 Reads to slow memory in the local NUMA domain 3 Non-temporal writes to non-local NUMA domain 2 Non-temporal writes to local NUMA domain 1 Reads to memory in the non-local NUMA domain 0 Reads to memory in the local NUMA domain ==== =========================================================== By default, the mbm_total_bytes configuration is set to 0x7f to count all the event types. For example: $cat /sys/fs/resctrl/info/L3_MON/mbm_total_config 0=0x7f;1=0x7f;2=0x7f;3=0x7f In this case, the event mbm_total_bytes is currently configured with 0x7f on domains 0 to 3. Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/core.c | 3 + arch/x86/kernel/cpu/resctrl/internal.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 76 ++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 46813b1c50c2..758c5d7553a4 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -826,6 +826,9 @@ static __init bool get_rdt_mon_resources(void) if (!rdt_mon_features) return false; + if (mon_configurable) + mbm_config_rftype_init(); + return !rdt_get_mon_l3_config(r, mon_configurable); } diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index b458f768f30c..326a1b582f38 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -15,6 +15,7 @@ #define MSR_IA32_MBA_THRTL_BASE 0xd50 #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_EVT_CFG_BASE 0xc0000400 #define MSR_IA32_QM_CTR 0x0c8e #define MSR_IA32_QM_EVTSEL 0x0c8d @@ -541,5 +542,6 @@ bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d); void __check_limbo(struct rdt_domain *d, bool force_free); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void __init thread_throttle_mode_init(void); +void __init mbm_config_rftype_init(void); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 5f0ef1bf4c78..0982845594d0 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1423,6 +1423,67 @@ static int rdtgroup_size_show(struct kernfs_open_file *of, return ret; } +struct mon_config_info { + u32 evtid; + u32 mon_config; +}; + +static void mon_event_config_read(void *info) +{ + struct mon_config_info *mon_info = info; + u32 h, msr_index; + + switch (mon_info->evtid) { + case QOS_L3_MBM_TOTAL_EVENT_ID: + msr_index = 0; + break; + case QOS_L3_MBM_LOCAL_EVENT_ID: + msr_index = 1; + break; + default: + /* Not expected to come here */ + return; + } + + rdmsr(MSR_IA32_EVT_CFG_BASE + msr_index, mon_info->mon_config, h); +} + +static void mondata_config_read(struct rdt_domain *d, struct mon_config_info *mon_info) +{ + smp_call_function_any(&d->cpu_mask, mon_event_config_read, mon_info, 1); +} + +static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32 evtid) +{ + struct mon_config_info mon_info = {0}; + struct rdt_domain *dom; + bool sep = false; + + list_for_each_entry(dom, &r->domains, list) { + if (sep) + seq_puts(s, ";"); + + mon_info.evtid = evtid; + mondata_config_read(dom, &mon_info); + + seq_printf(s, "%d=0x%02x", dom->id, mon_info.mon_config); + sep = true; + } + seq_puts(s, "\n"); + + return 0; +} + +static int mbm_total_config_show(struct kernfs_open_file *of, + struct seq_file *seq, void *v) +{ + struct rdt_resource *r = of->kn->parent->priv; + + mbm_config_show(seq, r, QOS_L3_MBM_TOTAL_EVENT_ID); + + return 0; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { { @@ -1521,6 +1582,12 @@ static struct rftype res_common_files[] = { .seq_show = max_threshold_occ_show, .fflags = RF_MON_INFO | RFTYPE_RES_CACHE, }, + { + .name = "mbm_total_config", + .mode = 0644, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = mbm_total_config_show, + }, { .name = "cpus", .mode = 0644, @@ -1627,6 +1694,15 @@ void __init thread_throttle_mode_init(void) rft->fflags = RF_CTRL_INFO | RFTYPE_RES_MB; } +void __init mbm_config_rftype_init(void) +{ + struct rftype *rft; + + rft = rdtgroup_get_rftype_by_name("mbm_total_config"); + if (rft) + rft->fflags = RF_MON_INFO | RFTYPE_RES_CACHE; +} + /** * rdtgroup_kn_mode_restrict - Restrict user access to named resctrl file * @r: The resource group with which the file is associated.