From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09A81C433EF for ; Fri, 1 Oct 2021 16:01:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E187061AD2 for ; Fri, 1 Oct 2021 16:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355156AbhJAQDL (ORCPT ); Fri, 1 Oct 2021 12:03:11 -0400 Received: from foss.arm.com ([217.140.110.172]:46208 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355148AbhJAQDK (ORCPT ); Fri, 1 Oct 2021 12:03:10 -0400 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 C1434101E; Fri, 1 Oct 2021 09:01:25 -0700 (PDT) Received: from [10.1.196.28] (eglon.cambridge.arm.com [10.1.196.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F311C3F766; Fri, 1 Oct 2021 09:01:23 -0700 (PDT) Subject: Re: [PATCH v1 13/20] x86/recstrl: Allow per-rmid arch private storage to be reset To: "tan.shaopeng@fujitsu.com" , "'x86@kernel.org'" , "'linux-kernel@vger.kernel.org'" Cc: 'Fenghua Yu' , 'Reinette Chatre' , 'Thomas Gleixner' , 'Ingo Molnar' , 'Borislav Petkov' , 'H Peter Anvin' , 'Babu Moger' , "'shameerali.kolothum.thodi@huawei.com'" , 'Jamie Iles' , 'D Scott Phillips OS' , "'lcherian@marvell.com'" , "'bobo.shaobowang@huawei.com'" References: <20210729223610.29373-14-james.morse@arm.com> From: James Morse Message-ID: Date: Fri, 1 Oct 2021 17:01:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-2022-jp Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Shaopeng Tan, On 24/09/2021 07:34, tan.shaopeng@fujitsu.com wrote: >> To abstract the rmid counters into a helper that returns the number of bytes >> counted, architecture specific per-rmid state is needed. >> >> It needs to be possible to reset this hidden state, as the values may outlive the >> life of an rmid, or the mount time of the filesystem. >> >> mon_event_read() is called with first = true when an rmid is first allocated in >> mkdir_mondata_subdir(). Add resctrl_arch_reset_rmid() and call it from >> __mon_event_count()'s rr->first check. >> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c >> b/arch/x86/kernel/cpu/resctrl/monitor.c >> index af60e154f0ed..3b8b29470a5c 100644 >> --- a/arch/x86/kernel/cpu/resctrl/monitor.c >> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c >> @@ -137,7 +137,34 @@ static inline struct rmid_entry *__rmid_entry(u32 rmid) >> return entry; >> } >> >> -static u64 __rmid_read(u32 rmid, u32 eventid) >> +static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_domain >> *hw_dom, >> + u32 rmid, >> + enum resctrl_event_id >> eventid) >> +{ >> + switch (eventid) { >> + case QOS_L3_OCCUP_EVENT_ID: >> + return NULL; >> + case QOS_L3_MBM_TOTAL_EVENT_ID: >> + return &hw_dom->arch_mbm_total[rmid]; >> + case QOS_L3_MBM_LOCAL_EVENT_ID: >> + return &hw_dom->arch_mbm_local[rmid]; >> + } >> + > > Since it is unexpected to come here, > it might be better to add WARN_ON. Sure. (it'll be the 'once' version to avoid spamming the console) I'm relying on the compiler generating a warning a built-time here if a new enum entry is ever added, but it can't hurt to warning if someone passes something totally crazy to it. > In addition, I have tested these patches on Intel(R) Xeon(R) Gold 6254 CPU with > resctrl selftest. It is no problem. Good to know, thanks! Thanks, James