Re: [RFC PATCH 5/8] x86/umwait.c: Add sysfs interface to show tsc_khz

From: Thomas Gleixner
Date: Tue Jun 19 2018 - 05:09:10 EST


On Fri, 15 Jun 2018, Fenghua Yu wrote:

> +static ssize_t tsc_khz_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + return sprintf(buf, "%d\n", tsc_khz);
> +}
> +
> static DEVICE_ATTR_RW(umwait_disable_c0_2);
> +static DEVICE_ATTR_RO(tsc_khz);

The right place to expose that information is the VDSO and a helper
function which allows to convert from nsec to TSC.

> static struct attribute *umwait_attrs[] = {
> &dev_attr_umwait_disable_c0_2.attr,
> @@ -92,6 +100,15 @@ static int __init umwait_init(void)
> if (ret)
> return ret;
>
> + /* Only add the tsc_khz interface when the value is known. */

Why so? The only reason why you don't want to expose TSC frequency is when
it's not constant frequency.

> + if (boot_cpu_has(X86_FEATURE_TSC_KNOWN_FREQ)) {

Thanks,

tglx