@@ -338,14 +338,20 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d,
338338 u64 * val , void * ignored )
339339{
340340 struct rdt_hw_mon_domain * hw_dom = resctrl_to_arch_mon_dom (d );
341- int cpu = cpumask_any (& d -> hdr .cpu_mask );
342341 struct arch_mbm_state * am ;
343342 u64 msr_val ;
344343 u32 prmid ;
344+ int cpu ;
345345 int ret ;
346346
347347 resctrl_arch_rmid_read_context_check ();
348348
349+ if (cpumask_empty (& d -> hdr .cpu_mask )) {
350+ pr_warn_once ("Domain %d has no CPUs\n" , d -> hdr .id );
351+ return - EINVAL ;
352+ }
353+
354+ cpu = cpumask_any (& d -> hdr .cpu_mask );
349355 prmid = logical_rmid_to_physical_rmid (cpu , rmid );
350356 ret = __rmid_read_phys (prmid , eventid , & msr_val );
351357
@@ -382,9 +388,9 @@ void __check_limbo(struct rdt_mon_domain *d, bool force_free)
382388 struct rdt_resource * r = & rdt_resources_all [RDT_RESOURCE_L3 ].r_resctrl ;
383389 u32 idx_limit = resctrl_arch_system_num_rmid_idx ();
384390 struct rmid_entry * entry ;
391+ bool rmid_dirty = true;
385392 u32 idx , cur_idx = 1 ;
386393 void * arch_mon_ctx ;
387- bool rmid_dirty ;
388394 u64 val = 0 ;
389395
390396 arch_mon_ctx = resctrl_arch_mon_ctx_alloc (r , QOS_L3_OCCUP_EVENT_ID );
@@ -406,22 +412,27 @@ void __check_limbo(struct rdt_mon_domain *d, bool force_free)
406412 break ;
407413
408414 entry = __rmid_entry (idx );
409- if (resctrl_arch_rmid_read (r , d , entry -> closid , entry -> rmid ,
410- QOS_L3_OCCUP_EVENT_ID , & val ,
411- arch_mon_ctx )) {
412- rmid_dirty = true;
413- } else {
414- rmid_dirty = (val >= resctrl_rmid_realloc_threshold );
415-
416- /*
417- * x86's CLOSID and RMID are independent numbers, so the entry's
418- * CLOSID is an empty CLOSID (X86_RESCTRL_EMPTY_CLOSID). On Arm the
419- * RMID (PMG) extends the CLOSID (PARTID) space with bits that aren't
420- * used to select the configuration. It is thus necessary to track both
421- * CLOSID and RMID because there may be dependencies between them
422- * on some architectures.
423- */
424- trace_mon_llc_occupancy_limbo (entry -> closid , entry -> rmid , d -> hdr .id , val );
415+ if (!force_free ) {
416+ if (resctrl_arch_rmid_read (r , d , entry -> closid ,
417+ entry -> rmid , QOS_L3_OCCUP_EVENT_ID ,
418+ & val , arch_mon_ctx )) {
419+ rmid_dirty = true;
420+ } else {
421+ rmid_dirty = (val >= resctrl_rmid_realloc_threshold );
422+
423+ /*
424+ * x86's CLOSID and RMID are independent numbers,
425+ * so the entry's CLOSID is an empty CLOSID
426+ * (X86_RESCTRL_EMPTY_CLOSID). On Arm the RMID
427+ * (PMG) extends the CLOSID (PARTID) space with
428+ * bits that aren't used to select the configuration.
429+ * It is thus necessary to track both CLOSID and
430+ * RMID because there may be dependencies between
431+ * them on some architectures.
432+ */
433+ trace_mon_llc_occupancy_limbo (entry -> closid , entry -> rmid ,
434+ d -> hdr .id , val );
435+ }
425436 }
426437
427438 if (force_free || !rmid_dirty ) {
0 commit comments