Skip to content
  1. Jul 22, 2022
  2. Jul 15, 2022
    • Phil Auld's avatar
      drivers/base: fix userspace break from using bin_attributes for cpumap and cpulist · 7ee951ac
      Phil Auld authored
      Using bin_attributes with a 0 size causes fstat and friends to return that
      0 size. This breaks userspace code that retrieves the size before reading
      the file. Rather than reverting 75bd50fa ("drivers/base/node.c: use
      bin_attribute to break the size limitation of cpumap ABI") let's put in a
      size value at compile time.
      
      For cpulist the maximum size is on the order of
      	NR_CPUS * (ceil(log10(NR_CPUS)) + 1)/2
      
      which for 8192 is 20480 (8192 * 5)/2. In order to get near that you'd need
      a system with every other CPU on one node. For example: (0,2,4,8, ... ).
      To simplify the math and support larger NR_CPUS in the future we are using
      (NR_CPUS * 7)/2. We also set it to a min of PAGE_SIZE to retain the older
      behavior for smaller NR_CPUS.
      
      The cpumap file the size works out to be NR_CPUS/4 + NR_CPUS/32 - 1
      (or NR_CPUS * 9/32 - 1) including the ","s.
      
      Add a set of macros for these values to cpumask.h so they can be used in
      multiple places. Apply these to the handful of such files in
      drivers/base/topology.c as well as node.c.
      
      As an example, on an 80 cpu 4-node system (NR_CPUS == 8192):
      
      before:
      
      -r--r--r--. 1 root root 0 Jul 12 14:08 system/node/node0/cpulist
      -r--r--r--. 1 root root 0 Jul 11 17:25 system/node/node0/cpumap
      
      after:
      
      -r--r--r--. 1 root root 28672 Jul 13 11:32 system/node/node0/cpulist
      -r--r--r--. 1 root root  4096 Jul 13 11:31 system/node/node0/cpumap
      
      CONFIG_NR_CPUS = 16384
      -r--r--r--. 1 root root 57344 Jul 13 14:03 system/node/node0/cpulist
      -r--r--r--. 1 root root  4607 Jul 13 14:02 system/node/node0/cpumap
      
      The actual number of cpus doesn't matter for the reported size since they
      are based on NR_CPUS.
      
      Fixes: 75bd50fa ("drivers/base/node.c: use bin_attribute to break the size limitation of cpumap ABI")
      Fixes: bb9ec13d
      
       ("topology: use bin_attribute to break the size limitation of cpumap ABI")
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Yury Norov <yury.norov@gmail.com>
      Cc: stable@vger.kernel.org
      Acked-by: Yury Norov <yury.norov@gmail.com> (for include/linux/cpumask.h)
      Signed-off-by: default avatarPhil Auld <pauld@redhat.com>
      Link: https://lore.kernel.org/r/20220715134924.3466194-1-pauld@redhat.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ee951ac
  3. Jul 14, 2022
  4. Jul 12, 2022
  5. Jul 08, 2022
    • Greg Kroah-Hartman's avatar
      Merge tag 'arch-cache-topo-5.20' of... · 2c8f7ef4
      Greg Kroah-Hartman authored
      Merge tag 'arch-cache-topo-5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into driver-core-next
      
      Sudeep writes:
      
      cacheinfo and arch_topology updates for v5.20
      
      These are updates to fix some discrepancies we have in the CPU topology
      parsing from the device tree /cpu-map node and the divergence from the
      behaviour on a ACPI enabled platform. The expectation is that both DT
      and ACPI enabled systems must present consistent view of the CPU topology.
      
      The current assignment of generated cluster count as the physical package
      identifier for each CPU is wrong. The device tree bindings for CPU
      topology supports sockets to infer the socket or physical package
      identifier for a given CPU. It is now being made use of you address the
      issue. These updates also assigns the cluster identifier as parsed from
      the device tree cluster nodes within /cpu-map without support for
      nesting of the clusters as there are no such reported/known platforms.
      
      In order to be on par with ACPI PPTT physical package/socket support,
      these updates also include support for socket nodes in /cpu-map.
      
      The only exception is that the last level cache id information can be
      inferred from the same ACPI PPTT while we need to parse CPU cache nodes
      in the device tree. The cacheinfo changes here is to enable the re-use
      of the cacheinfo to detect the cache attributes for all the CPU quite
      early even before the scondardaries are booted so that the information
      can be used to build the schedular domains especially the last level
      cache(LLC).
      
      * tag 'arch-cache-topo-5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: (21 commits)
        ACPI: Remove the unused find_acpi_cpu_cache_topology()
        arch_topology: Warn that topology for nested clusters is not supported
        arch_topology: Add support for parsing sockets in /cpu-map
        arch_topology: Set cluster identifier in each core/thread from /cpu-map
        arch_topology: Limit span of cpu_clustergroup_mask()
        arch_topology: Don't set cluster identifier as physical package identifier
        arch_topology: Avoid parsing through all the CPUs once a outlier CPU is found
        arch_topology: Check for non-negative value rather than -1 for IDs validity
        arch_topology: Set thread sibling cpumask only within the cluster
        arch_topology: Drop LLC identifier stash from the CPU topology
        arm64: topology: Remove redundant setting of llc_id in CPU topology
        arch_topology: Use the last level cache information from the cacheinfo
        arch_topology: Add support to parse and detect cache attributes
        cacheinfo: Align checks in cache_shared_cpu_map_{setup,remove} for readability
        cacheinfo: Use cache identifiers to check if the caches are shared if available
        cacheinfo: Allow early detection and population of cache attributes
        cacheinfo: Add support to check if last level cache(LLC) is valid or shared
        cacheinfo: Move cache_leaves_are_shared out of CONFIG_OF
        cacheinfo: Add helper to access any cache index for a given CPU
        cacheinfo: Use of_cpu_device_node_get instead cpu_dev->of_node
        ...
      2c8f7ef4
  6. Jul 06, 2022
  7. Jul 04, 2022
  8. Jul 01, 2022
  9. Jun 27, 2022