Intel Cache Monitoring Technology: scaling value

Thibaut SAUTEREAU thibaut.sautereau at telecom-sudparis.eu
Thu Apr 6 07:46:22 EDT 2017


Hello guys,

I have a question regarding LLC occupancy recorded by Intel Cache Monitoring
Technology, on Linux.

I use perf_event_open(2) and read(2) to gather CMT values and I multiply by
a "scaling value" read from '/sys/devices/intel_cqm/events/llc_occupancy.scale'
in order to obtain a result in bytes (that's for instance what libvirt does).
But that file gives me a "scaling value" of 32768. When looking at the
corresponding code in the Linux kernel ('arch/x86/events/intel/cqm.c', around
line 1716), I understand that the returned value should be the processor's
cache line size:

	cqm_l3_scale = boot_cpu_data.x86_cache_occ_scale;

	[...]

	get_online_cpus();
        for_each_online_cpu(cpu) {
                struct cpuinfo_x86 *c = &cpu_data(cpu);

                if (c->x86_cache_max_rmid < cqm_max_rmid)
                        cqm_max_rmid = c->x86_cache_max_rmid;

                if (c->x86_cache_occ_scale != cqm_l3_scale) {
                        pr_err("Multiple LLC scale values, disabling\n");
                        ret = -EINVAL;
                        goto out;
                }
        }

	[...]

	snprintf(scale, sizeof(scale), "%u", cqm_l3_scale);
        str = kstrdup(scale, GFP_KERNEL);
        if (!str) {
                ret = -ENOMEM;
                goto out;
        }

        event_attr_intel_cqm_llc_scale.event_str = str;

I understand that 'event_attr_intel_cqm_llc_scale.event_str' is the value I
should read from the file, i.e. the CPU's cache line size, which is 64 in
most cases and in mine.

Am I missing something? Thanks for any help!

Regards,

Thibaut S.



More information about the Kernelnewbies mailing list