All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Babu Moger" <babu.moger@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v4 2/3] fs/resctrl: Assign counters to existing groups when enabling mbm_event
Date: Fri, 09 Oct 2026 23:55:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-166189@kernel.org> (raw)
In-Reply-To: <3d966ae2e051ef54e1aedb1a2839c812ab880bcb.1791589412.git.babu.moger@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] x86/resctrl: MBM counter leak and hardware misconfiguration for pseudo-locked groups
--

commit b647b3c26df799d4d9b84cff6fe64eee2efa36ad
Author: Babu Moger <babu.moger@amd.com>
fs/resctrl: Assign counters to existing groups when enabling mbm_event

When switching to mbm_event counter assignment mode, existing monitoring
groups are not automatically assigned counters, leaving them unassigned.
This commit walks every existing group and assigns available counters to
match the auto-assignment behavior that occurs for new groups.

Closes: https://sashiko.dev/#/patchset/8cb66e18e32e4087a9712c1e68ee6da614efe244.1784322818.git.babu.moger%40amd.com

> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index a932a1fea8182..84d422da1bace 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c

[ ... ]

> @@ -1272,6 +1275,22 @@ void rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp)
>  					   &mon_event_all[QOS_L3_MBM_LOCAL_EVENT_ID]);
>  }
>  
> +/*
> + * resctrl_assign_cntrs_allrdtgrp() - Assign counters to the MBM events of
> + *				      every existing group.
> + */
> +static void resctrl_assign_cntrs_allrdtgrp(void)
> +{
> +	struct rdtgroup *prgrp, *crgrp;
> +
> +	list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
> +		rdtgroup_assign_cntrs(prgrp);

[Severity: High]
Does this code inadvertently leak hardware counters to pseudo-locked groups?

When a user creates a control group and transitions it to pseudo-locked mode,
its rmid and closid are explicitly freed. If 'mbm_event' assignment mode is
then enabled globally, this traversal loop captures those pseudo-locked groups
because they are retained in rdt_all_groups.

Since rdtgroup_assign_cntrs() lacks a check for
rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED, the counter allocation proceeds.

Could this cause rdtgroup_alloc_assign_cntr() to program the hardware using
the stale, freed rmid and closid of the pseudo-locked group? This appears to
permanently leak scarce hardware counters and potentially corrupt the hardware
monitoring state of other active groups that have been re-allocated those IDs.

> +
> +		list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list)
> +			rdtgroup_assign_cntrs(crgrp);
> +	}
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791589412.git.babu.moger@amd.com?part=2

  reply	other threads:[~2026-10-09 23:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 23:44 [PATCH v4 0/3] x86,fs/resctrl: Keep default MBM mode at boot and fix ABMC programming Babu Moger
2026-10-09 23:44 ` [PATCH v4 1/3] x86/resctrl: Fix ABMC counter programming Babu Moger
2026-10-12 18:40   ` Reinette Chatre
2026-10-13  1:00     ` Moger, Babu
2026-10-09 23:44 ` [PATCH v4 2/3] fs/resctrl: Assign counters to existing groups when enabling mbm_event Babu Moger
2026-10-09 23:55   ` sashiko-bot [this message]
2026-10-12 18:44   ` Reinette Chatre
2026-10-13  1:02     ` Moger, Babu
2026-10-13  2:16       ` Reinette Chatre
2026-10-13 13:33         ` Babu Moger
2026-10-13 15:57   ` Ben Horgan
2026-10-13 16:51     ` Babu Moger
2026-10-13 18:22       ` Reinette Chatre
2026-10-13 18:52         ` Babu Moger
2026-10-13 20:25           ` Reinette Chatre
2026-10-13 23:05             ` Moger, Babu
2026-10-13 23:23               ` Reinette Chatre
2026-10-09 23:44 ` [PATCH v4 3/3] x86,fs/resctrl: Keep mbm_assign_mode in default mode at boot Babu Moger
2026-10-12 18:47   ` Reinette Chatre
2026-10-13  1:09     ` 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=sashiko-outbox-166189@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=babu.moger@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.