From: "Moger, Babu" <babu.moger@amd.com>
To: Peter Newman <peternewman@google.com>,
reinette.chatre@intel.com, fenghua.yu@intel.com
Cc: bp@alien8.de, dave.hansen@linux.intel.com, eranian@google.com,
hpa@zytor.com, james.morse@arm.com, linux-kernel@vger.kernel.org,
mingo@redhat.com, quic_jiles@quicinc.com,
tan.shaopeng@fujitsu.com, tglx@linutronix.de, x86@kernel.org
Subject: Re: [PATCH v3 2/2] x86/resctrl: Avoid redundant counter read in __mon_event_count()
Date: Tue, 10 Jan 2023 10:01:56 -0600 [thread overview]
Message-ID: <364c2d8d-dc81-9ccc-51e8-92cd8db3c4ee@amd.com> (raw)
In-Reply-To: <20221220164132.443083-2-peternewman@google.com>
On 12/20/22 10:41, Peter Newman wrote:
> __mon_event_count() does the per-RMID, per-domain work for
> user-initiated event count reads and the initialization of new monitor
> groups.
>
> In the initialization case, after resctrl_arch_reset_rmid() calls
> __rmid_read() to record an initial count for a new monitor group, it
> immediately calls resctrl_arch_rmid_read(). This re-read of the hardware
> counter is unnecessary and the following computations are ignored by the
> caller during initialization.
>
> Following return from resctrl_arch_reset_rmid(), just clear the
> mbm_state and return. This involves moving the mbm_state lookup into the
> rr->first case, as it's not needed for regular event count reads: the
> QOS_L3_OCCUP_EVENT_ID case was redundant with the accumulating logic at
> the end of the function.
>
> Signed-off-by: Peter Newman <peternewman@google.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
> v3:
> - changelog clarifications suggested by Reinette
> v2:
> (patch introduced)
>
> v2: https://lore.kernel.org/lkml/20221214160856.2164207-2-peternewman@google.com/
> ---
> arch/x86/kernel/cpu/resctrl/monitor.c | 43 ++++++++++++---------------
> 1 file changed, 19 insertions(+), 24 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index 77538abeb72a..e708df478077 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -366,41 +366,36 @@ void free_rmid(u32 rmid)
> list_add_tail(&entry->list, &rmid_free_lru);
> }
>
> +static struct mbm_state *get_mbm_state(struct rdt_domain *d, u32 rmid,
> + enum resctrl_event_id evtid)
> +{
> + switch (evtid) {
> + case QOS_L3_MBM_TOTAL_EVENT_ID:
> + return &d->mbm_total[rmid];
> + case QOS_L3_MBM_LOCAL_EVENT_ID:
> + return &d->mbm_local[rmid];
> + default:
> + return NULL;
> + }
> +}
> +
> static int __mon_event_count(u32 rmid, struct rmid_read *rr)
> {
> struct mbm_state *m;
> u64 tval = 0;
>
> - if (rr->first)
> + if (rr->first) {
> resctrl_arch_reset_rmid(rr->r, rr->d, rmid, rr->evtid);
> + m = get_mbm_state(rr->d, rmid, rr->evtid);
> + if (m)
> + memset(m, 0, sizeof(struct mbm_state));
> + return 0;
> + }
>
> rr->err = resctrl_arch_rmid_read(rr->r, rr->d, rmid, rr->evtid, &tval);
> if (rr->err)
> return rr->err;
>
> - switch (rr->evtid) {
> - case QOS_L3_OCCUP_EVENT_ID:
> - rr->val += tval;
> - return 0;
> - case QOS_L3_MBM_TOTAL_EVENT_ID:
> - m = &rr->d->mbm_total[rmid];
> - break;
> - case QOS_L3_MBM_LOCAL_EVENT_ID:
> - m = &rr->d->mbm_local[rmid];
> - break;
> - default:
> - /*
> - * Code would never reach here because an invalid
> - * event id would fail in resctrl_arch_rmid_read().
> - */
> - return -EINVAL;
> - }
> -
> - if (rr->first) {
> - memset(m, 0, sizeof(struct mbm_state));
> - return 0;
> - }
> -
> rr->val += tval;
>
> return 0;
Tested the patches on AMD systems. Looks good.
Tested-by: Babu Moger <babu.moger@amd.com>
Thanks
Babu Moger
next prev parent reply other threads:[~2023-01-10 16:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 16:41 [PATCH v3 1/2] x86/resctrl: Fix event counts regression in reused RMIDs Peter Newman
2022-12-20 16:41 ` [PATCH v3 2/2] x86/resctrl: Avoid redundant counter read in __mon_event_count() Peter Newman
2023-01-10 16:01 ` Moger, Babu [this message]
2023-01-10 15:59 ` [PATCH v3 1/2] x86/resctrl: Fix event counts regression in reused RMIDs Moger, Babu
2023-01-10 19:04 ` [tip: x86/urgent] " tip-bot2 for Peter Newman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=364c2d8d-dc81-9ccc-51e8-92cd8db3c4ee@amd.com \
--to=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=eranian@google.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peternewman@google.com \
--cc=quic_jiles@quicinc.com \
--cc=reinette.chatre@intel.com \
--cc=tan.shaopeng@fujitsu.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®