Re: [RFC PATCH 1/3] x86/resctrl: Get max rmid and occupancy scale directly from CPUID instead of cpuinfo_x86

From: Borislav Petkov
Date: Fri Jun 14 2019 - 13:51:59 EST


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;
}

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.