On Fri, Jun 14, 2019 at 07:47:01PM +0200, Borislav Petkov wrote: > On Fri, Jun 14, 2019 at 09:55:28AM -0700, Fenghua Yu wrote: > > When this function is called, X86_FEATURE_CQM_LLC must be supported and > > one of X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_LOCAL, and > > X86_FEATURE_CQM_MBM_TOTAL must be supported. Otherwise, > > get_rdt_mon_resource() is returned before calling rdt_get_mon_l3_config(). > > > > So CPUID.f.0 and CPUID.f.1 must be readable and return meaningful > > data without testing the features. > > How's that? > > static void __init get_cqm_info(struct rdt_resource *r) > { > u32 eax, ebx, ecx, edx; > > /* > * At this point, CQM LLC and one of occupancy, MBM total, and > * MBM local monitoring features must be supported. > */ > cpuid_count(0xf, 1, &eax, &ebx, &ecx, &edx); > > if (rdt_mon_features & QOS_L3_OCCUP_EVENT_ID) > r->num_rmid = ecx + 1; > else > /* > * Fallback maximum range (zero-based) of RMID within > * this physical processor of all types, in subleaf 0, > * EBX. > */ > r->num_rmid = cpuid_ebx(0xf) + 1; > > if (rdt_mon_features & (QOS_L3_MBM_TOTAL_EVENT_ID | > QOS_L3_MBM_LOCAL_EVENT_ID)) > r->mon_scale = ebx; > else > r->mon_scale = -1; > }
This is much better and cleaner! I will copy your code to patch 0001 in the next version. Thanks. -Fenghua