Messages in this thread | | | Date | Tue, 21 Mar 2023 12:57:03 +0200 (EET) | From | Ilpo Järvinen <> | Subject | Re: [PATCH v3 02/19] x86/resctrl: Access per-rmid structures by index |
| |
On Mon, 20 Mar 2023, James Morse wrote:
> Because of the differences between Intel RDT/AMD QoS and Arm's MPAM > monitors, RMID values on arm64 are not unique unless the CLOSID is > also included. Bitmaps like rmid_busy_llc need to be sized by the > number of unique entries for this resource. > > Add helpers to encode/decode the CLOSID and RMID to an index. The > domain's rmid_busy__llc and the rmid_ptrs[] array are then sized by > index, as are the domain mbm_local and mbm_total arrays. > On x86, the index is always just the RMID, so all these structures > remain the same size. > > The index gives resctrl a unique value it can use to store monitor > values, and allows MPAM to decode the closid when reading the hardware > counters. > > Tested-by: Shaopeng Tan <tan.shaopeng@fujitsu.com> > Signed-off-by: James Morse <james.morse@arm.com> > --- > Changes since v1: > * Added X86_BAD_CLOSID macro to make it clear what this value means > * Added second WARN_ON() for closid checking, and made both _ONCE() > > Changes since v2: > * Added RESCTRL_RESERVED_CLOSID > * Removed a newline > * Repharsed some comments > * Renamed a variable 'ignore'd > * Moved X86_RESCTRL_BAD_CLOSID to a previous patch > ---
> diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h > index cbe986d23df6..3ca40be41a0a 100644
> @@ -732,19 +759,20 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms) > > static int dom_data_init(struct rdt_resource *r) > { > + u32 nr_idx = resctrl_arch_system_num_rmid_idx();
You've used idx_limit elsewhere so this name should be consistent with the others.
-- i.
> struct rmid_entry *entry = NULL; > - int i, nr_rmids; > + u32 idx; > + int i; > > - nr_rmids = r->num_rmid; > - rmid_ptrs = kcalloc(nr_rmids, sizeof(struct rmid_entry), GFP_KERNEL); > + rmid_ptrs = kcalloc(nr_idx, sizeof(struct rmid_entry), GFP_KERNEL); > if (!rmid_ptrs) > return -ENOMEM; > > - for (i = 0; i < nr_rmids; i++) { > + for (i = 0; i < nr_idx; i++) { > entry = &rmid_ptrs[i]; > INIT_LIST_HEAD(&entry->list); > > - entry->rmid = i; > + resctrl_arch_rmid_idx_decode(i, &entry->closid, &entry->rmid); > list_add_tail(&entry->list, &rmid_free_lru); > } > > @@ -753,7 +781,8 @@ static int dom_data_init(struct rdt_resource *r) > * default_rdtgroup control group, which will be setup later. See > * rdtgroup_setup_root(). > */ > - entry = __rmid_entry(0, 0); > + idx = resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, 0); > + entry = __rmid_entry(idx); > list_del(&entry->list); > > return 0;
| |