From: Reinette Chatre <reinette.chatre@intel.com>
To: "Luck, Tony" <tony.luck@intel.com>,
"Moger, Babu" <bmoger@amd.com>, "Babu Moger" <babu.moger@amd.com>,
"Dave.Martin@arm.com" <Dave.Martin@arm.com>,
"james.morse@arm.com" <james.morse@arm.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Cc: "x86@kernel.org" <x86@kernel.org>,
"hpa@zytor.com" <hpa@zytor.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"peternewman@google.com" <peternewman@google.com>,
"Eranian, Stephane" <eranian@google.com>,
"gautham.shenoy@amd.com" <gautham.shenoy@amd.com>
Subject: Re: [PATCH v4] x86/resctrl: Fix miscount of bandwidth event when reactivating previously Unavailable RMID
Date: Mon, 13 Oct 2025 11:16:41 -0700 [thread overview]
Message-ID: <2056950f-02a8-41cc-9dd0-c16b81afd8e3@intel.com> (raw)
In-Reply-To: <SJ1PR11MB608387EF18E2BEAE9F719899FCEAA@SJ1PR11MB6083.namprd11.prod.outlook.com>
Hi Tony,
On 10/13/25 8:35 AM, Luck, Tony wrote:
>>> The behavior of the counter is different on Intel where there are enough
>>> counters backing the RMID and the "Unavailable" bit is not set when counter
>>> starts counting but instead the counter returns "0". For example, when
>
> Note that the h/w counter doesn't really return "0" (except for the first time
> after CPU reset).
Correct.
In this example both the hardware counter and the event returned zero. The
main point was that it does not return "Unavailable".
The goal with the example related to this issue was to demonstrate no impact on Intel
when resetting arch_mbm_state::prev_msr on receipt of "Unavailable". Do you see things
differently?
>
>>> running equivalent of "step 1" on an Intel system it looks like:
>>>
>>> # cd /sys/fs/resctrl
>>> # mkdir mon_groups/test1
>
> While making the directory mon_add_all_files() does this:
>
> if (!do_sum && resctrl_is_mbm_event(mevt->evtid))
> mon_event_read(&rr, r, d, prgrp, &d->hdr.cpu_mask, mevt->evtid, true);
>
> Which in __mon_event_count() does:
>
> if (rr->first) {
> if (rr->is_mbm_cntr)
> resctrl_arch_reset_cntr(rr->r, rr->d, closid, rmid, cntr_id, rr->evtid);
> else
> resctrl_arch_reset_rmid(rr->r, rr->d, closid, rmid, rr->evtid);
> m = get_mbm_state(rr->d, closid, rmid, rr->evtid);
> if (m)
> memset(m, 0, sizeof(struct mbm_state));
> return 0;
> }
>
> If you dig into resctrl_arch_reset_rmid() you will see that it reads the h/w counter and
> then that becomes the start point for subsequent values reported when a user reads
> from the resctrl event file.
I believe resctrl_arch_reset_rmid() already addresses the issue since resctrl_arch_reset_rmid()
always resets the architectural state before attempting to read the RMID. If __rmid_read_phys()
encounters "Unavailable"/-EINVAL then it is fine since arch_mbm_state::prev_msr will already be
zero and thus ready for a subsequent resctrl_arch_rmid_read(), whether hardware counter is ready
or not.
Reinette
next prev parent reply other threads:[~2025-10-13 18:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 17:08 Babu Moger
2025-10-10 21:20 ` Reinette Chatre
2025-10-10 23:37 ` Moger, Babu
2025-10-13 15:35 ` Luck, Tony
2025-10-13 18:16 ` Reinette Chatre [this message]
2025-10-13 19:36 ` [tip: x86/urgent] x86/resctrl: Fix miscount of bandwidth event when reactivating previously unavailable RMID tip-bot2 for Babu Moger
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=2056950f-02a8-41cc-9dd0-c16b81afd8e3@intel.com \
--to=reinette.chatre@intel.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=bmoger@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=eranian@google.com \
--cc=gautham.shenoy@amd.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=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--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®