• Kan Liang's avatar
    perf/x86/uncore: Save the unit control address of all units · 0007f393
    Kan Liang authored
    The unit control address of some CXL units may be wrongly calculated
    under some configuration on a EMR machine.
    
    The current implementation only saves the unit control address of the
    units from the first die, and the first unit of the rest of dies. Perf
    assumed that the units from the other dies have the same offset as the
    first die. So the unit control address of the rest of the units can be
    calculated. However, the assumption is wrong, especially for the CXL
    units.
    
    Introduce an RB tree for each uncore type to save the unit control
    address and three kinds of ID information (unit ID, PMU ID, and die ID)
    for all units.
    The unit ID is a physical ID of a unit.
    The PMU ID is a logical ID assigned to a unit. The logical IDs start
    from 0 and must be contiguous. The physical ID and the logical ID are
    1:1 mapping. The units with the same physical ID in different dies share
    the same PMU.
    The die ID indicates which die a unit belongs to.
    
    The RB tree can be searched by two different keys (unit ID or PMU ID +
    die ID). During the RB tree setup, the unit ID is used as a key to look
    up the RB tree. The perf can create/assign a proper PMU ID to the unit.
    Later, after the RB tree is setup, PMU ID + die ID is used as a key to
    look up the RB tree to fill the cpumask of a PMU. It's used more
    frequently, so PMU ID + die ID is compared in the unit_less().
    The uncore_find_unit() has to be O(N). But the RB tree setup only occurs
    once during the driver load time. It should be acceptable.
    
    Compared with the current implementation, more space is required to save
    the information of all units. The extra size should be acceptable.
    For example, on EMR, there are 221 units at most. For a 2-socket machine,
    the extra space is ~6KB at most.
    Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lore.kernel.org/r/20240614134631.1092359-2-kan.liang@linux.intel.com
    0007f393
uncore_discovery.h 5.2 KB