Re: [PATCH v8 8/9] x86/resctrl: Introduce erdt_cpu_has() and erdt_support()

From: Chen Yu

Date: Tue Oct 06 2026 - 04:42:49 EST


[Resending, as the previous one does not seem to have reached the LKML.]

Hi Reinette,

On Mon, Sep 28, 2026 at 02:49:36PM -0700, Reinette Chatre wrote:
> Hi Chenyu,
>
> On 9/17/26 9:51 PM, Chen Yu wrote:
> > Introduce erdt_cpu_has() to verify if a specific RDT feature is backed by an
> > ERDT table. erdt_cpu_has() is derived from rdt_cpu_has(), which not only
>
> "is derived from" - needs imperative
>

OK, will fix this.

> > considers firmware (ERDT table and its sub-tables) support for a feature, but
>
> "rdt_cpu_has(), which not only considers firmware (ERDT table ..." reads as though
> rdt_cpu_has() considers ERDT, but it does not?
>

It does not. I intended to say that erdt_cpu_has() not only... but also...
Let me fix this description.

> > diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h
> > index 9a32ed418c33..bcfcc8ac1fe6 100644
> > --- a/arch/x86/include/asm/resctrl.h
> > +++ b/arch/x86/include/asm/resctrl.h
> > @@ -49,6 +49,7 @@ DECLARE_STATIC_KEY_FALSE(rdt_enable_key);
> > DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
> > DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key);
> >
> > +bool erdt_cpu_has(int flag);
> > unsigned int erdt_get_scale(void);
>
> Same comment as earlier in response to the erdt_get_scale() prototype
> addition.
>

OK, will move them to include/linux/resctrl.h

> > +bool erdt_cpu_has(int flag)
> > +{
> > + struct rdt_options *o;
> > + bool ret;
> > +
> > + ret = erdt_support(flag);
> > +
> > + if (!ret)
> > + return ret;
> > +
> > + for (o = rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) {
> > + if (flag == o->flag) {
> > + if (o->force_off)
> > + ret = false;
> > + if (o->force_on)
> > + ret = true;
> > + break;
> > + }
> > + }
> > +
> > + return ret;
> > +}
> > +
>
> erdt_cpu_has() is practically identical to rdt_cpu_has() just above it. how about
> something like:
>
> static bool apply_rdt_options(int flag, bool ret)
> {
> struct rdt_options *o;
>
> for (o = rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) {
> ...
> }
>
> bool rdt_cpu_has(int flag)
> {
> return apply_rdt_options(flag, boot_cpu_has(flag));
> }
>
> bool erdt_cpu_has(int flag)
> {
> return apply_rdt_options(flag, erdt_support(flag));
> }
>

Yes, this will remove the duplicated code, I'll change it in next
version.

thanks,
Chenyu