Hi Tony, On 10/11/24 16:33, Luck, Tony wrote: >>>> +static int rdtgroup_assign_cntrs(struct rdtgroup *rdtgrp) >>>> +{ >>>> + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; >>>> + int ret = 0; >>>> + >>>> + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) >>>> + return 0; >>>> + >>>> + if (is_mbm_total_enabled()) >>>> + ret = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID); > > Consider that this call fails. "ret" indicates failure to allocate. Look at this call if (is_mbm_total_enabled()) ret = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID); If this call fails, it will return immediately. Lets say ret = 1; (1 if for failure. 0 for success) > >>>> + >>>> + if (!ret && is_mbm_local_enabled()) >>>> + ret = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID); > > Now this call succeeds. The failure of the previous call is forgotten as "ret" is > overwritten with the success code. It will not make this call if the first call fails because of this check. if (!ret && is_mbm_local_enabled()) ret = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID); return ret; Here if (!1) evaluates to false. Did I miss something? > >>> >>> This overwrites the value from allocating the counter for total event. >> >> Total event and local events have two different indexes. >> Can you please elaborate? > > See comments above. If you want a return code you need > > int ret_local = 0, ret_total = 0; > > if (is_mbm_total_enabled()) > ret_total = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID); > if (!ret && is_mbm_local_enabled()) > ret_local = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID); > > > return some_function of ret_local and ret_total; > > Not sure if you want to say success only if both of these calls succeeded. Or maybe if either worked? > > But it all seems complicated since callers don't have to take any different action depending on whether allocation of a counter succeeds or fails. > > -Tony > > > -- Thanks Babu Moger