Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp645030rwe; Fri, 26 Aug 2022 11:26:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR4LdUn2Ye23nDRFtAzPEnOImffXr05/wQhJklRzHexWwtwAG4/v+K+1ehK1r3px1I/wJ7J3 X-Received: by 2002:a17:907:2c68:b0:730:9272:8c7f with SMTP id ib8-20020a1709072c6800b0073092728c7fmr6381849ejc.528.1661538371516; Fri, 26 Aug 2022 11:26:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661538371; cv=pass; d=google.com; s=arc-20160816; b=JVPkvJFGISAZAh2yaiPNbmoWs5mV8ME3sp8XuEWmU3fIajJet94U8HWMcRrOvr/TN/ ImCsybUuFab5uF8a62V/0mk9u1jxi9ZKzWiVTIFeZs9I0gaXXzXHhV+uo6sQTJZ7jbUc DmwkX1NadbyMz8dkRGL9w5vyHxJS9s68oFqjFKv1PwKjnzVgxWO5A6CNd/CKjvUrUCP7 Ty3r6/eDWjBD3NAZLtirurlMHaU9myBT8XkQfvQ0noU6uMNXo/U1OH6QHxUUqAwRxXaU opt3Zy6SH5OkhTXKG7cU+XTazRPwlwstqHynRQz4Kcgmm3lMJLxRkzqJlf2tI6plTKJl TyiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject:reply-to :user-agent:date:message-id:dkim-signature; bh=31gYkKJzvf6IqGk2ywbZsey6RvPtajAQB7O33UghUkg=; b=GTnFJxiAkDue+24LU5SuC3+s4XApaZkpIAq5B6xQDtTcR5avfjqQvmkrgQ1BVTPZCX FCcK/b9o3o/KWgmEw6c5ooEQaFOT0iiDtHL9L4S3OUSYDJULqfX58IZW803HIau7c10U H4yUrsRBzGe2xl8rGR600boXEmb4E6+LXZyZBNS0rqNzjEWNrPx9gkAlr0eCe7z7aUP5 el4W3tek1/F0/0xPh4LhRQLsE1JE8U2WsM2ZdgHbBrgdl/UWF3K5UDlbIfMz8mLE5wi5 F4NyutpQyWnLbcNe/KzC9HpB6fybmDIGPIMhVWG4bnRfUrmG8uOSpDukHibz177OoYtK aR0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=VrnRNOGg; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170906854b00b0073d7d0aaa16si1772353ejy.226.2022.08.26.11.25.46; Fri, 26 Aug 2022 11:26:11 -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=VrnRNOGg; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=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 S1344601AbiHZSR7 (ORCPT + 99 others); Fri, 26 Aug 2022 14:17:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343808AbiHZSRz (ORCPT ); Fri, 26 Aug 2022 14:17:55 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55236DF0A3; Fri, 26 Aug 2022 11:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JL1eU8efEG27J4xqNrbPLeopYTjzpNVrKSpqtkd+0tK8Nqu+723YKPerkYf6cQyjLaZppLv/nBZj8Fk0p6w6O+yA1ttnu+JviKSXKv2Do67kavnobji9A1Jw36NGrDGbT09mFsWXNBZ2rul7bm9hY02LJtbmtjMB4IAcAq3vtQM3hN9rL06ntwYaLiG7Z4PFwh8ZNu3VyZVPZmfdhbZgF/8wYH5cMItSSbjpvl0sF5K+qvBz9GeghdO5SOxEd0xcfz36OSgLysO3GmuCY0+vP8hLmLCcK/0bOayIjLQ1TlyxiI1WEX1p4a2OIKcjwM29YeNONsv0JqPmBp+yPmEjWg== 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=31gYkKJzvf6IqGk2ywbZsey6RvPtajAQB7O33UghUkg=; b=nPh5MNw5XErggtRaKlkafgBAUVMkBgRiheoBdtGTmVatEOGXC2Ad5HmK0d0mxJUCNyiGQTMBJBBDHeFyKQxx1F4i9Eb/ScCgVuDlf6+aj6kfzSnSPi5T2q3ccSAX6AJ4UuH+rujzfrXVZWYhB3cocGA4BNrQyD6CRwwAaHVhsN4VYnbwrO4FONanX3m0cYpS5wWSr7tVtcJr05YI7yOuKQRz9soxS9DB1KvRsEx3TZ/9OcfY8fzkMrL53265qyKXAXCeVDy4tCAJhTBHaRpL9dj3JfA6RtwC/iir3+Yqv8CKkkK6ZJ29pn0aS8hmNB2ifJeW3fvt9jFmTL/oM8Q0Yw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=31gYkKJzvf6IqGk2ywbZsey6RvPtajAQB7O33UghUkg=; b=VrnRNOGg1j5A3uTlAG+vTZc5Lss4CB9wVNaYbs3Lo0KNPZx4JF9ytKFuzKZF3wgSVbEj58rVUHYKNaDuijjLc5XVBmuzlAa1bx4GRr4tO/BIySOmaLHbNmRM2IixjnOlKc3TRI6zXS0R8UO4bMjHXLhnewFvxLhCMbZ1Z8KQfb0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from MW3PR12MB4553.namprd12.prod.outlook.com (2603:10b6:303:2c::19) by DM5PR12MB1449.namprd12.prod.outlook.com (2603:10b6:4:10::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.14; Fri, 26 Aug 2022 18:17:51 +0000 Received: from MW3PR12MB4553.namprd12.prod.outlook.com ([fe80::88f:a211:8c98:a973]) by MW3PR12MB4553.namprd12.prod.outlook.com ([fe80::88f:a211:8c98:a973%7]) with mapi id 15.20.5566.016; Fri, 26 Aug 2022 18:17:51 +0000 Message-ID: Date: Fri, 26 Aug 2022 13:17:48 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Reply-To: babu.moger@amd.com Subject: Re: [PATCH v3 09/10] x86/resctrl: Add sysfs interface to write the event configuration Content-Language: en-US To: Reinette Chatre , fenghua.yu@intel.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de Cc: eranian@google.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, corbet@lwn.net, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, bagasdotme@gmail.com References: <166117559756.6695.16047463526634290701.stgit@bmoger-ubuntu> <166117586910.6695.3670808098195387542.stgit@bmoger-ubuntu> From: "Moger, Babu" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: CH0PR03CA0428.namprd03.prod.outlook.com (2603:10b6:610:10e::23) To MW3PR12MB4553.namprd12.prod.outlook.com (2603:10b6:303:2c::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c2d2dc32-d9dd-456f-53ee-08da878f49ce X-MS-TrafficTypeDiagnostic: DM5PR12MB1449:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jKcf/CegTeVy4G7ULKIVfEOsOZQGz3IYYWrMXmsYvQw1m9lGMbkKSdADU/tBibwtdzPkjGwJr5pSaiFyO4Qc2Yazgg4L31L+hxIxtVcGvYD9UAU5lWLi2+1+5tpqXV1Se+jpkXv2bGlS0ixpbB/oLwPLKjllfn0Du3Zvd9lhQhaVXPxpqK0hqDOiY5KFwppgyAfmnYY6uXMJmxFxCpzlpzp2rID0CED/50uWAFzZ2yJNyvYvG54mYxzAYNO5xLIrmu7fMtIzLgbS5red9QfJ0ATUa4OQirK8f1h3X2KlahAO4RCq8/feHCV52vS+6vxH9RMxFzU2d5t1aAectTYPKIfUHuiz2d/RK1bi5qjLppD7wE06zb+Qoagx+MA927mFR+6rblUj97RxC5VeIpoKEbnyCjZqv3M5e6wOHWzjXcj90B0Wc2xrY5sTbB9mQ4IANZZuD9tVK9ENNcGVfsjRzRDVbeIbkzJ6Y9yoquQchUcxc1L33IMXuMEtmUYWGWUnkd81wZVrHBPnDC0+qqpgtsDGZtXBjhwi5PuKZZY7K6jt3JOE0bTlixEHrsmYSICjGlmBLSRMkPEBIc0xo1EDV02sAgeJmOODg8x1nBydNDBmNFpzff5shVe4yPANCFBTo4RMCwcsfcdaHEEfGEWfIBfHBY+94mfYP4Qf2o4qUJ6PH7Je91sktIhmRsdmCyf9k2o1s/8cWJB5ojnDPfza2OK9jS6umCNERci/G3tm5bKlghYPScR8v95yj9677o2dgVO85SJVl5+zlakpW+/thdmskx3rez5J6IrBYeEC7Js= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR12MB4553.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(346002)(136003)(366004)(376002)(39860400002)(396003)(2616005)(86362001)(53546011)(186003)(6506007)(5660300002)(8936002)(26005)(31696002)(36756003)(7416002)(478600001)(41300700001)(31686004)(6512007)(6486002)(6666004)(83380400001)(66946007)(4326008)(8676002)(3450700001)(2906002)(66556008)(66476007)(38100700002)(316002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WlJOamZ5NjBGTUlRNEozR1hlZ3ZWSWxBRFNTWlRKOGgxWXhlNk51QVJMLzls?= =?utf-8?B?aVFkQWpld2dEUk5Walp3K2s2WUZlNDZzWDFwdklCYkx1NDBqUnRaclNHVE9H?= =?utf-8?B?d2J6azkwYlE0SDQ1Tm5UUVBDWHFmaTdMRFhWQWxRTHdOek1mL3h3RkVkOVh5?= =?utf-8?B?S3ZzS0hyNzQ0aGNPNG5mK0dlajY1U0RoWUlweE96VHp4TVE4ZkFRZ1E5dkNH?= =?utf-8?B?cytWYkRDb3k2c2lrUWFBckxSSEJSNjQzOWVSNVNOS0h0aDdab1pybS9XTEVp?= =?utf-8?B?YVdjS3ZWWGNFQWxEWWxNMWJpOEF3bTJySjhSYXluOE1IMDM5ZnRtSmptOVhC?= =?utf-8?B?dUJkNmhhSWpqSXZpa09ndmM2Y2ZlTTdGMj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ce X-MS-Exchange-CrossTenant-AuthSource: MW3PR12MB4553.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2022 18:17:51.6240 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +LENF3U9C5N0zXiOYK1+s1pgk5Jkz9xunHp8w0hE3LqeNI7cKBo0tY1oT0cXNc2w X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1449 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 8/24/22 16:16, Reinette Chatre wrote: > Hi Babu, > > On 8/22/2022 6:44 AM, Babu Moger wrote: >> Add the sysfs interface to write the event configuration for the >> MBM configurable events. The event configuration can be changed by >> writing to the sysfs file for that specific event. >> >> 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 types of events and mbm_local_bytes configuration is set to >> 0x15 to count all the local memory events. >> >> For example: >> To change the mbm_total_bytes to count all the reads, run the command. >> $echo 0x33 > /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_config >> >> To change the mbm_local_bytes to count all the slow memory reads, run >> the command. >> $echo 0x30 > /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_config >> >> Signed-off-by: Babu Moger >> Reviewed-by: Ingo Molnar >> --- >> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 109 ++++++++++++++++++++++++++++++++ >> 1 file changed, 109 insertions(+) >> >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index e1847d49fa15..83c8780726ff 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -323,9 +323,118 @@ int rdtgroup_mondata_config_show(struct seq_file *m, void *arg) >> return ret; >> } >> >> +/* >> + * This is called via IPI to read the CQM/MBM counters >> + * in a domain. >> + */ >> +void mon_event_config_write(void *info) >> +{ >> + union mon_data_bits *md = info; >> + u32 evtid = md->u.evtid; >> + u32 msr_index; >> + >> + switch (evtid) { >> + case QOS_L3_MBM_TOTAL_EVENT_ID: >> + msr_index = 0; >> + break; >> + case QOS_L3_MBM_LOCAL_EVENT_ID: >> + msr_index = 1; >> + break; >> + default: >> + return; /* Not expected to come here */ > Please no inline comments. Ok sure. > >> + } >> + >> + wrmsr(MSR_IA32_EVT_CFG_BASE + msr_index, md->u.mon_config, 0); >> +} >> + >> +ssize_t rdtgroup_mondata_config_write(struct kernfs_open_file *of, >> + char *buf, size_t nbytes, loff_t off) >> +{ >> + struct rdt_hw_resource *hw_res; >> + struct rdtgroup *rdtgrp; >> + struct rdt_resource *r; >> + unsigned int mon_config; >> + cpumask_var_t cpu_mask; >> + union mon_data_bits md; >> + struct rdt_domain *d; >> + u32 resid, domid; >> + int ret = 0, cpu; >> + >> + ret = kstrtouint(buf, 0, &mon_config); >> + if (ret) >> + return ret; >> + >> + rdt_last_cmd_clear(); >> + >> + /* mon_config cannot be more than the supported set of events */ >> + if (mon_config > GENMASK(6, 0)) { > Could this "GENMASK()" be given a name and be moved closer to where > the bits are defined in internal.h? This will be easier to read and if any > new bits are added it would hopefully be noticed more easily to get > an update also. Ok. Sure.. > >> + rdt_last_cmd_puts("Invalid event configuration\n"); >> + return -EINVAL; >> + } >> + >> + cpus_read_lock(); >> + rdtgrp = rdtgroup_kn_lock_live(of->kn); >> + if (!rdtgrp) { >> + return -ENOENT; >> + goto e_unlock; >> + } >> + >> + if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL)) { >> + ret = -ENOMEM; >> + goto e_unlock; >> + } >> + >> + >> + md.priv = of->kn->priv; >> + resid = md.u.rid; >> + domid = md.u.domid; >> + >> + hw_res = &rdt_resources_all[resid]; >> + r = &hw_res->r_resctrl; >> + d = rdt_find_domain(r, domid, NULL); >> + if (IS_ERR_OR_NULL(d)) { >> + ret = -ENOENT; >> + goto e_cpumask; >> + } >> + >> + md.u.mon_config = mon_config & 0xFF; > Same question as previous patch. I do not see this internal > value used in the code, is storing it necessary? Storing is not necessary.  As I commented before we need mon_config  as part of mon_data_bits structure because, it need to be passed to mon_event_config_read and rdtgroup_mondata_config_write. In these functions we need evtid and also config value (mon_config). > >> + >> + /* Pick all the CPUs in the domain instance */ >> + for_each_cpu(cpu, &d->cpu_mask) >> + cpumask_set_cpu(cpu, cpu_mask); >> + >> + cpu = get_cpu(); >> + /* Update MSR_IA32_EVT_CFG_BASE MSR on this cpu if it's in cpu_mask */ > Please always use caps for CPU. Sure > >> + if (cpumask_test_cpu(cpu, cpu_mask)) >> + mon_event_config_write(&md); >> + >> + /* Update MSR_IA32_EVT_CFG_BASE MSR on all other cpus in cpu_mask */ >> + smp_call_function_many(cpu_mask, mon_event_config_write, &md, 1); >> + put_cpu(); > I do not think we need to propagate this pattern more in the resctrl code. > How about on_each_cpu_mask()? Yea. We can do that. It probably better to replace all the current smp_call_function_many in resctrl code. > >> + >> + /* >> + * When an Event Configuration is changed, the bandwidth counters >> + * for all RMIDs and Events will be cleared, and the U-bit for every >> + * RMID will be set on the next read to any BwEvent for every RMID. >> + * Clear the mbm_local and mbm_total counts for all the RMIDs. >> + */ >> + memset(d->mbm_local, 0, sizeof(struct mbm_state) * r->num_rmid); >> + memset(d->mbm_total, 0, sizeof(struct mbm_state) * r->num_rmid); > Could you please check if this is sufficient? Note how "mon_event_read()" > is called with "first = true" right after the mon sysfs files are created to > clear the state _and_ initialize the state to set the "prev" MSRs correctly. I see that it is set m->prev_bw_msr = m->prev_msr = tval; With above code we are setting m->prev_bw_msr = m->prev_msr = 0; I cannot think of any problems this could cause. Please let me know if you see a problem. Thanks Babu Moger > > >> + >> +e_cpumask: >> + free_cpumask_var(cpu_mask); >> + >> +e_unlock: >> + rdtgroup_kn_unlock(of->kn); >> + cpus_read_unlock(); >> + >> + return ret ?: nbytes; >> +} >> + >> static const struct kernfs_ops kf_mondata_config_ops = { >> .atomic_write_len = PAGE_SIZE, >> .seq_show = rdtgroup_mondata_config_show, >> + .write = rdtgroup_mondata_config_write, >> }; >> >> static bool is_cpu_list(struct kernfs_open_file *of) >> >> > Reinette -- Thanks Babu Moger