Re: [PATCH 1/6] thermal/intel: Introduce Intel TCC library

Zhang Rui
2022-12-09T13:57:37Z

> > > +
> > > + err = rdmsr_safe_on_cpu(cpu, msr, &eax, &edx);
> > > + if (err)
> > > + return err;
> > > +
> > > + if (eax & 0x80000000) {
> > > + *temp = tjmax - ((eax >> 16) & 0x7f);
> > > + return 0;
> > > + }
> > > + return -EINVAL;
> > > +}
> > > +EXPORT_SYMBOL_NS_GPL(intel_tcc_get_temp, INTEL_TCC);
>
> And one more thing, but rather for the future.
>
> Reading from these MSRs can be costly, especially when done on a
> remote CPU, so would it make sense to cache the retrieved values in
> case they are read relatively often?like the coretemp driver already
> has similar code.

For now, this API is called from sysfs attribute callback so it is okay
to add a unified rate_limit here, say 1 second like coretemp driver.

But for the future, I'm not sure. This really depends on the
expectation of the caller.

BTW, this reminds me that I can improve the code a little bit, to avoid
reading MSR from remote CPU when possible.

thanks,
rui