Re: [PATCH v6 05/24] x86/resctrl: Track the closid with the rmid

Reinette Chatre
2023-10-03T21:11:50Z

Hi James,

On 9/14/2023 10:21 AM, James Morse wrote:

> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index cfb3f632a4b2..42b9a694fe2f 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -24,7 +24,21 @@
>
> #include "internal.h"
>
> +/**
> + * struct rmid_entry - dirty tracking for all RMID.
> + * @closid: The CLOSID for this entry.
> + * @rmid: The RMID for this entry.
> + * @busy: The number of domains with cached data using this RMID.
> + * @list: Member of the rmid_free_lru list when busy == 0.
> + *
> + * Some architectures's resctrl_arch_rmid_read() needs the CLOSID value
> + * in order to access the correct monitor. @closid provides the value to
> + * list walkers like __check_limbo(). On x86 this is ignored.

I do not think this is correct. At this point in the series
__check_limbo() uses @rmid as index, at end of series it uses the
(@closid, @rmid) index. Never does the list walker use @closid.

Perhaps something like below that matches your later similar comments:

Depending on the architecture the correct monitor is accessed
using both @closid and @rmid, or @rmid only.

...

> @@ -685,11 +706,11 @@ void mbm_handle_overflow(struct work_struct *work)
> d = container_of(work, struct rdt_domain, mbm_over.work);
>
> list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
> - mbm_update(r, d, prgrp->mon.rmid);
> + mbm_update(r, d, prgrp->closid, prgrp->mon.rmid);
>
> head = &prgrp->mon.crdtgrp_list;
> list_for_each_entry(crgrp, head, mon.crdtgrp_list)
> - mbm_update(r, d, crgrp->mon.rmid);
> + mbm_update(r, d, crgrp->closid, crgrp->mon.rmid);
>
> if (is_mba_sc(NULL))
> update_mba_bw(prgrp, d);
> @@ -732,10 +753,11 @@ static int dom_data_init(struct rdt_resource *r)
> }
>
> /*
> - * RMID 0 is special and is always allocated. It's used for all
> - * tasks that are not monitored.
> + * RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and
> + * are always allocated. These are used for rdtgroup_default control
> + * group, which will be setup later. See rdtgroup_setup_root().
> */

This comment will not be accurate after Babu's changes are merged (the function will
be rdtgroup_setup_default()). To avoid that conflict you could perhaps change
last two sentences to something like below that will be accurate no matter the
order of merging between your and Babu's work:

These are used for rdtgroup_default control group, which will be
setup later in rdtgroup_init().

> - entry = __rmid_entry(0);
> + entry = __rmid_entry(RESCTRL_RESERVED_CLOSID, RESCTRL_RESERVED_RMID);
> list_del(&entry->list);
>
> return 0;

My feedback only relates to the comments. The rest of the patch looks good to
me. I could give a review tag with expectation that comments be addressed in next
version but since some review feedback fell through the cracks in this version I
feel that I need to confirm first before providing review tag.

Reinette