Re: [PATCH v2 2/2] x86/Documentation: Add documentation about cluster

From: Dave Hansen
Date: Thu Apr 13 2023 - 13:57:15 EST


On 4/13/23 10:29, K Prateek Nayak wrote:
> + - cluster_id:
> +
> + A per-CPU variable containing:
> +
> + - On Intel, the common upper bits of APIC ID of the list of CPUs sharing
> + the L2 Cache with lower bits set to 0.
> +
> + - On AMD and Hygon, with Topology Extension, the common upper bits of the
> + Extended APIC ID of the list of CPUs sharing the L2 Cache, left shifted
> + to remove trailing 0s.

I think this is too much detail for Documentation. We have the code if
anyone cares _this_ much.

Also, I'm perplexed by the "left shifted" comment. I don't see a lot of
left shifting in the patch. Am I just missing it?

Further, this makes it sound like all Intel CPUs have the cluster_id
populated. I'm also not sure that folks reading this will have any
worldly idea what "Topology Extension" is.

Why don't we just say that some CPUs don't have this info? That way we
don't need to spell out AMD vs. Intel or expect our users to go figuring
out of their CPU has "Topology Extension" or leaf 3 or wherever this
info is on Intel.

How about:

A per-CPU variable containing:

- Some upper bits extracted from the APIC ID. CPUs which have the
same value in these bits share an L2 and have the same cluster_id.

CPUs for which L2 cache information is unavailable will show 65535
as the cluster_id.