Hi Tony,
On 10/11/2024 12:17 PM, Tony Luck wrote:
On Wed, Oct 09, 2024 at 12:39:44PM -0500, Babu Moger wrote:
+/*
+ * Called when a new group is created. If `mbm_cntr_assign` mode is enabled,
+ * counters are automatically assigned. Each group requires two counters:
+ * one for the total event and one for the local event. Due to the limited
+ * number of counters, assignments may fail in some cases. However, it is
+ * not necessary to fail the group creation. Users have the option to
+ * modify the assignments after the group has been created.
+ */
+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);
+
+ if (!ret && is_mbm_local_enabled())
+ ret = rdtgroup_assign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);
This overwrites the value from allocating the counter for total event.
Total event and local events have two different indexes.
Can you please elaborate?
+
+ return ret;
But none of the callers check the return. Indeed it is ok (and
expected) that counter allocation can fail.
Just make this a "void" function and delete the "ret" local variable.
Comment below.
+}
+
+/*
+ * Called when a group is deleted. Counters are unassigned if it was in
+ * assigned state.
+ */
+static int rdtgroup_unassign_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_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_TOTAL_EVENT_ID);
+
+ if (!ret && is_mbm_local_enabled())
+ ret = rdtgroup_unassign_cntr_event(r, rdtgrp, NULL, QOS_L3_MBM_LOCAL_EVENT_ID);
+
+ return ret;
Ditto. No caller checks. Make this a void function. Dig down the
call chain here. It looks like rdtgroup_unassign_cntr_event() can't
fail, so it should be a void function too. Ditto resctrl_arch_config_cntr()
It was started a void function. In this case all the call sequence
return 0. There is a possibility that other architectures can return
failure(in arch calls resctrl_arch_config_cntr()). Keeping that in mind
we added the check to handle the return values. Hope that helps.
Thanks
--
- Babu Moger