* Re: [RFC PATCH -V2] NUMA balancing: fix NUMA topology for systems with CPU-less nodes
@ 2022-02-08 20:36 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-02-08 20:36 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 32506 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220208122322.604285-1-ying.huang@intel.com>
References: <20220208122322.604285-1-ying.huang@intel.com>
TO: Huang Ying <ying.huang@intel.com>
Hi Huang,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tip/sched/core]
[also build test WARNING on linux/master linus/master v5.17-rc3 next-20220208]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git c8eaf6ac76f40f6c59fc7d056e2e08c4a57ea9c7
:::::: branch date: 7 hours ago
:::::: commit date: 7 hours ago
config: arm64-randconfig-s031-20220208 (https://download.01.org/0day-ci/archive/20220209/202202090432.GKrg4Fan-lkp(a)intel.com/config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/ed82092e509333870d756fc8e53d816885922fc4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
git checkout ed82092e509333870d756fc8e53d816885922fc4
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm64 SHELL=/bin/bash kernel/sched/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
kernel/sched/topology.c:461:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct perf_domain *pd @@ got struct perf_domain [noderef] __rcu *pd @@
kernel/sched/topology.c:461:19: sparse: expected struct perf_domain *pd
kernel/sched/topology.c:461:19: sparse: got struct perf_domain [noderef] __rcu *pd
kernel/sched/topology.c:623:49: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain *parent @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:623:49: sparse: expected struct sched_domain *parent
kernel/sched/topology.c:623:49: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:694:50: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain *parent @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:694:50: sparse: expected struct sched_domain *parent
kernel/sched/topology.c:694:50: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:701:55: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain [noderef] __rcu *[noderef] __rcu child @@ got struct sched_domain *[assigned] tmp @@
kernel/sched/topology.c:701:55: sparse: expected struct sched_domain [noderef] __rcu *[noderef] __rcu child
kernel/sched/topology.c:701:55: sparse: got struct sched_domain *[assigned] tmp
kernel/sched/topology.c:711:29: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] tmp @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:711:29: sparse: expected struct sched_domain *[assigned] tmp
kernel/sched/topology.c:711:29: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:716:20: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:716:20: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:716:20: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:737:13: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] tmp @@ got struct sched_domain [noderef] __rcu *sd @@
kernel/sched/topology.c:737:13: sparse: expected struct sched_domain *[assigned] tmp
kernel/sched/topology.c:737:13: sparse: got struct sched_domain [noderef] __rcu *sd
kernel/sched/topology.c:899:70: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:899:70: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:899:70: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:928:59: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:928:59: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:928:59: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:974:57: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:974:57: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:974:57: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:976:25: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *sibling @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:976:25: sparse: expected struct sched_domain *sibling
kernel/sched/topology.c:976:25: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:984:55: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:984:55: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:984:55: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:986:25: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *sibling @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:986:25: sparse: expected struct sched_domain *sibling
kernel/sched/topology.c:986:25: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1056:62: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct sched_domain *sd @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:1056:62: sparse: expected struct sched_domain *sd
kernel/sched/topology.c:1056:62: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1160:40: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain *child @@ got struct sched_domain [noderef] __rcu *child @@
kernel/sched/topology.c:1160:40: sparse: expected struct sched_domain *child
kernel/sched/topology.c:1160:40: sparse: got struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1569:43: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sched_domain [noderef] __rcu *child @@ got struct sched_domain *child @@
kernel/sched/topology.c:1569:43: sparse: expected struct sched_domain [noderef] __rcu *child
kernel/sched/topology.c:1569:43: sparse: got struct sched_domain *child
kernel/sched/topology.c:1707:21: sparse: sparse: incompatible types in comparison expression (different address spaces):
>> kernel/sched/topology.c:1707:21: sparse: int [noderef] __rcu *
>> kernel/sched/topology.c:1707:21: sparse: int *
kernel/sched/topology.c:1833:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/topology.c:1833:9: sparse: int [noderef] __rcu *
kernel/sched/topology.c:1833:9: sparse: int *
kernel/sched/topology.c:1888:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
>> kernel/sched/topology.c:1888:9: sparse: struct cpumask **[noderef] __rcu *
>> kernel/sched/topology.c:1888:9: sparse: struct cpumask ***
kernel/sched/topology.c:1946:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/topology.c:1946:9: sparse: int [noderef] __rcu *
kernel/sched/topology.c:1946:9: sparse: int *
kernel/sched/topology.c:1948:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/topology.c:1948:9: sparse: struct cpumask **[noderef] __rcu *
kernel/sched/topology.c:1948:9: sparse: struct cpumask ***
kernel/sched/topology.c:2032:17: sparse: sparse: incompatible types in comparison expression (different address spaces):
kernel/sched/topology.c:2032:17: sparse: struct cpumask **[noderef] __rcu *
kernel/sched/topology.c:2032:17: sparse: struct cpumask ***
kernel/sched/topology.c:2166:31: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain [noderef] __rcu *parent @@ got struct sched_domain *sd @@
kernel/sched/topology.c:2166:31: sparse: expected struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:2166:31: sparse: got struct sched_domain *sd
kernel/sched/topology.c:2269:57: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:2269:57: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/topology.c:2269:57: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:2286:57: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/topology.c:2286:57: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/topology.c:2286:57: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c: note: in included file:
kernel/sched/sched.h:1745:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/sched.h:1745:9: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/sched.h:1745:9: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/sched.h:1758:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/sched.h:1758:9: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/sched.h:1758:9: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/sched.h:1745:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/sched.h:1745:9: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/sched.h:1745:9: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/sched.h:1758:9: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct sched_domain *[assigned] sd @@ got struct sched_domain [noderef] __rcu *parent @@
kernel/sched/sched.h:1758:9: sparse: expected struct sched_domain *[assigned] sd
kernel/sched/sched.h:1758:9: sparse: got struct sched_domain [noderef] __rcu *parent
kernel/sched/topology.c:929:31: sparse: sparse: dereference of noderef expression
kernel/sched/topology.c:1590:19: sparse: sparse: dereference of noderef expression
vim +1707 kernel/sched/topology.c
f2cb13609d5397 Ingo Molnar 2017-02-01 1697
f2cb13609d5397 Ingo Molnar 2017-02-01 1698 bool find_numa_distance(int distance)
f2cb13609d5397 Ingo Molnar 2017-02-01 1699 {
ed82092e509333 Huang Ying 2022-02-08 1700 bool found = false;
ed82092e509333 Huang Ying 2022-02-08 1701 int i, *distances;
f2cb13609d5397 Ingo Molnar 2017-02-01 1702
f2cb13609d5397 Ingo Molnar 2017-02-01 1703 if (distance == node_distance(0, 0))
f2cb13609d5397 Ingo Molnar 2017-02-01 1704 return true;
f2cb13609d5397 Ingo Molnar 2017-02-01 1705
ed82092e509333 Huang Ying 2022-02-08 1706 rcu_read_lock();
ed82092e509333 Huang Ying 2022-02-08 @1707 distances = rcu_dereference(sched_domains_numa_distance);
ed82092e509333 Huang Ying 2022-02-08 1708 if (!distances)
ed82092e509333 Huang Ying 2022-02-08 1709 goto unlock;
f2cb13609d5397 Ingo Molnar 2017-02-01 1710 for (i = 0; i < sched_domains_numa_levels; i++) {
ed82092e509333 Huang Ying 2022-02-08 1711 if (distances[i] == distance) {
ed82092e509333 Huang Ying 2022-02-08 1712 found = true;
ed82092e509333 Huang Ying 2022-02-08 1713 break;
f2cb13609d5397 Ingo Molnar 2017-02-01 1714 }
ed82092e509333 Huang Ying 2022-02-08 1715 }
ed82092e509333 Huang Ying 2022-02-08 1716 unlock:
ed82092e509333 Huang Ying 2022-02-08 1717 rcu_read_unlock();
f2cb13609d5397 Ingo Molnar 2017-02-01 1718
ed82092e509333 Huang Ying 2022-02-08 1719 return found;
f2cb13609d5397 Ingo Molnar 2017-02-01 1720 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1721
ed82092e509333 Huang Ying 2022-02-08 1722 #define for_each_cpu_node_but(n, nbut) \
ed82092e509333 Huang Ying 2022-02-08 1723 for_each_node_state(n, N_CPU) \
ed82092e509333 Huang Ying 2022-02-08 1724 if (n == nbut) \
ed82092e509333 Huang Ying 2022-02-08 1725 continue; \
ed82092e509333 Huang Ying 2022-02-08 1726 else
ed82092e509333 Huang Ying 2022-02-08 1727
f2cb13609d5397 Ingo Molnar 2017-02-01 1728 /*
f2cb13609d5397 Ingo Molnar 2017-02-01 1729 * A system can have three types of NUMA topology:
f2cb13609d5397 Ingo Molnar 2017-02-01 1730 * NUMA_DIRECT: all nodes are directly connected, or not a NUMA system
f2cb13609d5397 Ingo Molnar 2017-02-01 1731 * NUMA_GLUELESS_MESH: some nodes reachable through intermediary nodes
f2cb13609d5397 Ingo Molnar 2017-02-01 1732 * NUMA_BACKPLANE: nodes can reach other nodes through a backplane
f2cb13609d5397 Ingo Molnar 2017-02-01 1733 *
f2cb13609d5397 Ingo Molnar 2017-02-01 1734 * The difference between a glueless mesh topology and a backplane
f2cb13609d5397 Ingo Molnar 2017-02-01 1735 * topology lies in whether communication between not directly
f2cb13609d5397 Ingo Molnar 2017-02-01 1736 * connected nodes goes through intermediary nodes (where programs
f2cb13609d5397 Ingo Molnar 2017-02-01 1737 * could run), or through backplane controllers. This affects
f2cb13609d5397 Ingo Molnar 2017-02-01 1738 * placement of programs.
f2cb13609d5397 Ingo Molnar 2017-02-01 1739 *
f2cb13609d5397 Ingo Molnar 2017-02-01 1740 * The type of topology can be discerned with the following tests:
f2cb13609d5397 Ingo Molnar 2017-02-01 1741 * - If the maximum distance between any nodes is 1 hop, the system
f2cb13609d5397 Ingo Molnar 2017-02-01 1742 * is directly connected.
f2cb13609d5397 Ingo Molnar 2017-02-01 1743 * - If for two nodes A and B, located N > 1 hops away from each other,
f2cb13609d5397 Ingo Molnar 2017-02-01 1744 * there is an intermediary node C, which is < N hops away from both
f2cb13609d5397 Ingo Molnar 2017-02-01 1745 * nodes A and B, the system is a glueless mesh.
f2cb13609d5397 Ingo Molnar 2017-02-01 1746 */
ed82092e509333 Huang Ying 2022-02-08 1747 static void init_numa_topology_type(int offline_node)
f2cb13609d5397 Ingo Molnar 2017-02-01 1748 {
f2cb13609d5397 Ingo Molnar 2017-02-01 1749 int a, b, c, n;
f2cb13609d5397 Ingo Molnar 2017-02-01 1750
f2cb13609d5397 Ingo Molnar 2017-02-01 1751 n = sched_max_numa_distance;
f2cb13609d5397 Ingo Molnar 2017-02-01 1752
e5e96fafd9028b Srikar Dronamraju 2018-08-10 1753 if (sched_domains_numa_levels <= 2) {
f2cb13609d5397 Ingo Molnar 2017-02-01 1754 sched_numa_topology_type = NUMA_DIRECT;
f2cb13609d5397 Ingo Molnar 2017-02-01 1755 return;
f2cb13609d5397 Ingo Molnar 2017-02-01 1756 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1757
ed82092e509333 Huang Ying 2022-02-08 1758 for_each_cpu_node_but(a, offline_node) {
ed82092e509333 Huang Ying 2022-02-08 1759 for_each_cpu_node_but(b, offline_node) {
f2cb13609d5397 Ingo Molnar 2017-02-01 1760 /* Find two nodes furthest removed from each other. */
f2cb13609d5397 Ingo Molnar 2017-02-01 1761 if (node_distance(a, b) < n)
f2cb13609d5397 Ingo Molnar 2017-02-01 1762 continue;
f2cb13609d5397 Ingo Molnar 2017-02-01 1763
f2cb13609d5397 Ingo Molnar 2017-02-01 1764 /* Is there an intermediary node between a and b? */
ed82092e509333 Huang Ying 2022-02-08 1765 for_each_cpu_node_but(c, offline_node) {
f2cb13609d5397 Ingo Molnar 2017-02-01 1766 if (node_distance(a, c) < n &&
f2cb13609d5397 Ingo Molnar 2017-02-01 1767 node_distance(b, c) < n) {
f2cb13609d5397 Ingo Molnar 2017-02-01 1768 sched_numa_topology_type =
f2cb13609d5397 Ingo Molnar 2017-02-01 1769 NUMA_GLUELESS_MESH;
f2cb13609d5397 Ingo Molnar 2017-02-01 1770 return;
f2cb13609d5397 Ingo Molnar 2017-02-01 1771 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1772 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1773
f2cb13609d5397 Ingo Molnar 2017-02-01 1774 sched_numa_topology_type = NUMA_BACKPLANE;
f2cb13609d5397 Ingo Molnar 2017-02-01 1775 return;
f2cb13609d5397 Ingo Molnar 2017-02-01 1776 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1777 }
ed82092e509333 Huang Ying 2022-02-08 1778
ed82092e509333 Huang Ying 2022-02-08 1779 pr_err("Failed to find a NUMA topology type, defaulting to DIRECT\n");
ed82092e509333 Huang Ying 2022-02-08 1780 sched_numa_topology_type = NUMA_DIRECT;
f2cb13609d5397 Ingo Molnar 2017-02-01 1781 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1782
620a6dc40754dc Valentin Schneider 2021-01-22 1783
620a6dc40754dc Valentin Schneider 2021-01-22 1784 #define NR_DISTANCE_VALUES (1 << DISTANCE_BITS)
620a6dc40754dc Valentin Schneider 2021-01-22 1785
ed82092e509333 Huang Ying 2022-02-08 1786 void sched_init_numa(int offline_node)
f2cb13609d5397 Ingo Molnar 2017-02-01 1787 {
f2cb13609d5397 Ingo Molnar 2017-02-01 1788 struct sched_domain_topology_level *tl;
620a6dc40754dc Valentin Schneider 2021-01-22 1789 unsigned long *distance_map;
620a6dc40754dc Valentin Schneider 2021-01-22 1790 int nr_levels = 0;
620a6dc40754dc Valentin Schneider 2021-01-22 1791 int i, j;
ed82092e509333 Huang Ying 2022-02-08 1792 int *distances;
ed82092e509333 Huang Ying 2022-02-08 1793 struct cpumask ***masks;
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1794
f2cb13609d5397 Ingo Molnar 2017-02-01 1795 /*
f2cb13609d5397 Ingo Molnar 2017-02-01 1796 * O(nr_nodes^2) deduplicating selection sort -- in order to find the
f2cb13609d5397 Ingo Molnar 2017-02-01 1797 * unique distances in the node_distance() table.
f2cb13609d5397 Ingo Molnar 2017-02-01 1798 */
620a6dc40754dc Valentin Schneider 2021-01-22 1799 distance_map = bitmap_alloc(NR_DISTANCE_VALUES, GFP_KERNEL);
620a6dc40754dc Valentin Schneider 2021-01-22 1800 if (!distance_map)
620a6dc40754dc Valentin Schneider 2021-01-22 1801 return;
620a6dc40754dc Valentin Schneider 2021-01-22 1802
620a6dc40754dc Valentin Schneider 2021-01-22 1803 bitmap_zero(distance_map, NR_DISTANCE_VALUES);
ed82092e509333 Huang Ying 2022-02-08 1804 for_each_cpu_node_but(i, offline_node) {
ed82092e509333 Huang Ying 2022-02-08 1805 for_each_cpu_node_but(j, offline_node) {
620a6dc40754dc Valentin Schneider 2021-01-22 1806 int distance = node_distance(i, j);
f2cb13609d5397 Ingo Molnar 2017-02-01 1807
620a6dc40754dc Valentin Schneider 2021-01-22 1808 if (distance < LOCAL_DISTANCE || distance >= NR_DISTANCE_VALUES) {
620a6dc40754dc Valentin Schneider 2021-01-22 1809 sched_numa_warn("Invalid distance value range");
ed82092e509333 Huang Ying 2022-02-08 1810 bitmap_free(distance_map);
620a6dc40754dc Valentin Schneider 2021-01-22 1811 return;
620a6dc40754dc Valentin Schneider 2021-01-22 1812 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1813
620a6dc40754dc Valentin Schneider 2021-01-22 1814 bitmap_set(distance_map, distance, 1);
620a6dc40754dc Valentin Schneider 2021-01-22 1815 }
620a6dc40754dc Valentin Schneider 2021-01-22 1816 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1817 /*
620a6dc40754dc Valentin Schneider 2021-01-22 1818 * We can now figure out how many unique distance values there are and
620a6dc40754dc Valentin Schneider 2021-01-22 1819 * allocate memory accordingly.
f2cb13609d5397 Ingo Molnar 2017-02-01 1820 */
620a6dc40754dc Valentin Schneider 2021-01-22 1821 nr_levels = bitmap_weight(distance_map, NR_DISTANCE_VALUES);
f2cb13609d5397 Ingo Molnar 2017-02-01 1822
ed82092e509333 Huang Ying 2022-02-08 1823 distances = kcalloc(nr_levels, sizeof(int), GFP_KERNEL);
ed82092e509333 Huang Ying 2022-02-08 1824 if (!distances) {
620a6dc40754dc Valentin Schneider 2021-01-22 1825 bitmap_free(distance_map);
620a6dc40754dc Valentin Schneider 2021-01-22 1826 return;
f2cb13609d5397 Ingo Molnar 2017-02-01 1827 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1828
620a6dc40754dc Valentin Schneider 2021-01-22 1829 for (i = 0, j = 0; i < nr_levels; i++, j++) {
620a6dc40754dc Valentin Schneider 2021-01-22 1830 j = find_next_bit(distance_map, NR_DISTANCE_VALUES, j);
ed82092e509333 Huang Ying 2022-02-08 1831 distances[i] = j;
f2cb13609d5397 Ingo Molnar 2017-02-01 1832 }
ed82092e509333 Huang Ying 2022-02-08 1833 rcu_assign_pointer(sched_domains_numa_distance, distances);
f2cb13609d5397 Ingo Molnar 2017-02-01 1834
620a6dc40754dc Valentin Schneider 2021-01-22 1835 bitmap_free(distance_map);
620a6dc40754dc Valentin Schneider 2021-01-22 1836
f2cb13609d5397 Ingo Molnar 2017-02-01 1837 /*
620a6dc40754dc Valentin Schneider 2021-01-22 1838 * 'nr_levels' contains the number of unique distances
f2cb13609d5397 Ingo Molnar 2017-02-01 1839 *
f2cb13609d5397 Ingo Molnar 2017-02-01 1840 * The sched_domains_numa_distance[] array includes the actual distance
f2cb13609d5397 Ingo Molnar 2017-02-01 1841 * numbers.
f2cb13609d5397 Ingo Molnar 2017-02-01 1842 */
f2cb13609d5397 Ingo Molnar 2017-02-01 1843
f2cb13609d5397 Ingo Molnar 2017-02-01 1844 /*
f2cb13609d5397 Ingo Molnar 2017-02-01 1845 * Here, we should temporarily reset sched_domains_numa_levels to 0.
f2cb13609d5397 Ingo Molnar 2017-02-01 1846 * If it fails to allocate memory for array sched_domains_numa_masks[][],
620a6dc40754dc Valentin Schneider 2021-01-22 1847 * the array will contain less then 'nr_levels' members. This could be
f2cb13609d5397 Ingo Molnar 2017-02-01 1848 * dangerous when we use it to iterate array sched_domains_numa_masks[][]
f2cb13609d5397 Ingo Molnar 2017-02-01 1849 * in other functions.
f2cb13609d5397 Ingo Molnar 2017-02-01 1850 *
620a6dc40754dc Valentin Schneider 2021-01-22 1851 * We reset it to 'nr_levels'@the end of this function.
f2cb13609d5397 Ingo Molnar 2017-02-01 1852 */
f2cb13609d5397 Ingo Molnar 2017-02-01 1853 sched_domains_numa_levels = 0;
f2cb13609d5397 Ingo Molnar 2017-02-01 1854
ed82092e509333 Huang Ying 2022-02-08 1855 masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL);
ed82092e509333 Huang Ying 2022-02-08 1856 if (!masks)
f2cb13609d5397 Ingo Molnar 2017-02-01 1857 return;
f2cb13609d5397 Ingo Molnar 2017-02-01 1858
f2cb13609d5397 Ingo Molnar 2017-02-01 1859 /*
f2cb13609d5397 Ingo Molnar 2017-02-01 1860 * Now for each level, construct a mask per node which contains all
f2cb13609d5397 Ingo Molnar 2017-02-01 1861 * CPUs of nodes that are that many hops away from us.
f2cb13609d5397 Ingo Molnar 2017-02-01 1862 */
620a6dc40754dc Valentin Schneider 2021-01-22 1863 for (i = 0; i < nr_levels; i++) {
ed82092e509333 Huang Ying 2022-02-08 1864 masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL);
ed82092e509333 Huang Ying 2022-02-08 1865 if (!masks[i])
f2cb13609d5397 Ingo Molnar 2017-02-01 1866 return;
f2cb13609d5397 Ingo Molnar 2017-02-01 1867
ed82092e509333 Huang Ying 2022-02-08 1868 for_each_cpu_node_but(j, offline_node) {
f2cb13609d5397 Ingo Molnar 2017-02-01 1869 struct cpumask *mask = kzalloc(cpumask_size(), GFP_KERNEL);
620a6dc40754dc Valentin Schneider 2021-01-22 1870 int k;
620a6dc40754dc Valentin Schneider 2021-01-22 1871
f2cb13609d5397 Ingo Molnar 2017-02-01 1872 if (!mask)
f2cb13609d5397 Ingo Molnar 2017-02-01 1873 return;
f2cb13609d5397 Ingo Molnar 2017-02-01 1874
ed82092e509333 Huang Ying 2022-02-08 1875 masks[i][j] = mask;
0083242c93759d Valentin Schneider 2021-08-18 1876
ed82092e509333 Huang Ying 2022-02-08 1877 for_each_cpu_node_but(k, offline_node) {
620a6dc40754dc Valentin Schneider 2021-01-22 1878 if (sched_debug() && (node_distance(j, k) != node_distance(k, j)))
620a6dc40754dc Valentin Schneider 2021-01-22 1879 sched_numa_warn("Node-distance not symmetric");
620a6dc40754dc Valentin Schneider 2021-01-22 1880
f2cb13609d5397 Ingo Molnar 2017-02-01 1881 if (node_distance(j, k) > sched_domains_numa_distance[i])
f2cb13609d5397 Ingo Molnar 2017-02-01 1882 continue;
f2cb13609d5397 Ingo Molnar 2017-02-01 1883
f2cb13609d5397 Ingo Molnar 2017-02-01 1884 cpumask_or(mask, mask, cpumask_of_node(k));
f2cb13609d5397 Ingo Molnar 2017-02-01 1885 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1886 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1887 }
ed82092e509333 Huang Ying 2022-02-08 @1888 rcu_assign_pointer(sched_domains_numa_masks, masks);
f2cb13609d5397 Ingo Molnar 2017-02-01 1889
f2cb13609d5397 Ingo Molnar 2017-02-01 1890 /* Compute default topology size */
f2cb13609d5397 Ingo Molnar 2017-02-01 1891 for (i = 0; sched_domain_topology[i].mask; i++);
f2cb13609d5397 Ingo Molnar 2017-02-01 1892
71e5f6644fb2f3 Dietmar Eggemann 2021-02-01 1893 tl = kzalloc((i + nr_levels + 1) *
f2cb13609d5397 Ingo Molnar 2017-02-01 1894 sizeof(struct sched_domain_topology_level), GFP_KERNEL);
f2cb13609d5397 Ingo Molnar 2017-02-01 1895 if (!tl)
f2cb13609d5397 Ingo Molnar 2017-02-01 1896 return;
f2cb13609d5397 Ingo Molnar 2017-02-01 1897
f2cb13609d5397 Ingo Molnar 2017-02-01 1898 /*
f2cb13609d5397 Ingo Molnar 2017-02-01 1899 * Copy the default topology bits..
f2cb13609d5397 Ingo Molnar 2017-02-01 1900 */
f2cb13609d5397 Ingo Molnar 2017-02-01 1901 for (i = 0; sched_domain_topology[i].mask; i++)
f2cb13609d5397 Ingo Molnar 2017-02-01 1902 tl[i] = sched_domain_topology[i];
f2cb13609d5397 Ingo Molnar 2017-02-01 1903
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1904 /*
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1905 * Add the NUMA identity distance, aka single NODE.
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1906 */
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1907 tl[i++] = (struct sched_domain_topology_level){
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1908 .mask = sd_numa_mask,
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1909 .numa_level = 0,
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1910 SD_INIT_NAME(NODE)
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1911 };
051f3ca02e4643 Suravee Suthikulpanit 2017-09-07 1912
f2cb13609d5397 Ingo Molnar 2017-02-01 1913 /*
f2cb13609d5397 Ingo Molnar 2017-02-01 1914 * .. and append 'j' levels of NUMA goodness.
f2cb13609d5397 Ingo Molnar 2017-02-01 1915 */
620a6dc40754dc Valentin Schneider 2021-01-22 1916 for (j = 1; j < nr_levels; i++, j++) {
f2cb13609d5397 Ingo Molnar 2017-02-01 1917 tl[i] = (struct sched_domain_topology_level){
f2cb13609d5397 Ingo Molnar 2017-02-01 1918 .mask = sd_numa_mask,
f2cb13609d5397 Ingo Molnar 2017-02-01 1919 .sd_flags = cpu_numa_flags,
f2cb13609d5397 Ingo Molnar 2017-02-01 1920 .flags = SDTL_OVERLAP,
f2cb13609d5397 Ingo Molnar 2017-02-01 1921 .numa_level = j,
f2cb13609d5397 Ingo Molnar 2017-02-01 1922 SD_INIT_NAME(NUMA)
f2cb13609d5397 Ingo Molnar 2017-02-01 1923 };
f2cb13609d5397 Ingo Molnar 2017-02-01 1924 }
f2cb13609d5397 Ingo Molnar 2017-02-01 1925
ed82092e509333 Huang Ying 2022-02-08 1926 sched_domain_topology_saved = sched_domain_topology;
f2cb13609d5397 Ingo Molnar 2017-02-01 1927 sched_domain_topology = tl;
f2cb13609d5397 Ingo Molnar 2017-02-01 1928
620a6dc40754dc Valentin Schneider 2021-01-22 1929 sched_domains_numa_levels = nr_levels;
620a6dc40754dc Valentin Schneider 2021-01-22 1930 sched_max_numa_distance = sched_domains_numa_distance[nr_levels - 1];
f2cb13609d5397 Ingo Molnar 2017-02-01 1931
ed82092e509333 Huang Ying 2022-02-08 1932 init_numa_topology_type(offline_node);
0083242c93759d Valentin Schneider 2021-08-18 1933 }
0083242c93759d Valentin Schneider 2021-08-18 1934
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [RFC PATCH -V2] NUMA balancing: fix NUMA topology for systems with CPU-less nodes
2022-02-08 12:23 Huang Ying
@ 2022-02-10 7:55 ` Dan Carpenter
2022-02-08 17:23 ` kernel test robot
1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-02-09 16:00 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 13866 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220208122322.604285-1-ying.huang@intel.com>
References: <20220208122322.604285-1-ying.huang@intel.com>
TO: Huang Ying <ying.huang@intel.com>
Hi Huang,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on tip/sched/core]
[also build test WARNING on linux/master linus/master v5.17-rc3 next-20220209]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git c8eaf6ac76f40f6c59fc7d056e2e08c4a57ea9c7
:::::: branch date: 27 hours ago
:::::: commit date: 27 hours ago
config: arm64-randconfig-m031-20220209 (https://download.01.org/0day-ci/archive/20220209/202202092339.FFRMVjDx-lkp(a)intel.com/config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
kernel/sched/topology.c:1866 sched_init_numa() warn: possible memory leak of 'masks'
vim +/masks +1866 kernel/sched/topology.c
620a6dc40754dc2 Valentin Schneider 2021-01-22 1785
ed82092e5093338 Huang Ying 2022-02-08 1786 void sched_init_numa(int offline_node)
f2cb13609d5397c Ingo Molnar 2017-02-01 1787 {
f2cb13609d5397c Ingo Molnar 2017-02-01 1788 struct sched_domain_topology_level *tl;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1789 unsigned long *distance_map;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1790 int nr_levels = 0;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1791 int i, j;
ed82092e5093338 Huang Ying 2022-02-08 1792 int *distances;
ed82092e5093338 Huang Ying 2022-02-08 1793 struct cpumask ***masks;
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1794
f2cb13609d5397c Ingo Molnar 2017-02-01 1795 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1796 * O(nr_nodes^2) deduplicating selection sort -- in order to find the
f2cb13609d5397c Ingo Molnar 2017-02-01 1797 * unique distances in the node_distance() table.
f2cb13609d5397c Ingo Molnar 2017-02-01 1798 */
620a6dc40754dc2 Valentin Schneider 2021-01-22 1799 distance_map = bitmap_alloc(NR_DISTANCE_VALUES, GFP_KERNEL);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1800 if (!distance_map)
620a6dc40754dc2 Valentin Schneider 2021-01-22 1801 return;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1802
620a6dc40754dc2 Valentin Schneider 2021-01-22 1803 bitmap_zero(distance_map, NR_DISTANCE_VALUES);
ed82092e5093338 Huang Ying 2022-02-08 1804 for_each_cpu_node_but(i, offline_node) {
ed82092e5093338 Huang Ying 2022-02-08 1805 for_each_cpu_node_but(j, offline_node) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1806 int distance = node_distance(i, j);
f2cb13609d5397c Ingo Molnar 2017-02-01 1807
620a6dc40754dc2 Valentin Schneider 2021-01-22 1808 if (distance < LOCAL_DISTANCE || distance >= NR_DISTANCE_VALUES) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1809 sched_numa_warn("Invalid distance value range");
ed82092e5093338 Huang Ying 2022-02-08 1810 bitmap_free(distance_map);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1811 return;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1812 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1813
620a6dc40754dc2 Valentin Schneider 2021-01-22 1814 bitmap_set(distance_map, distance, 1);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1815 }
620a6dc40754dc2 Valentin Schneider 2021-01-22 1816 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1817 /*
620a6dc40754dc2 Valentin Schneider 2021-01-22 1818 * We can now figure out how many unique distance values there are and
620a6dc40754dc2 Valentin Schneider 2021-01-22 1819 * allocate memory accordingly.
f2cb13609d5397c Ingo Molnar 2017-02-01 1820 */
620a6dc40754dc2 Valentin Schneider 2021-01-22 1821 nr_levels = bitmap_weight(distance_map, NR_DISTANCE_VALUES);
f2cb13609d5397c Ingo Molnar 2017-02-01 1822
ed82092e5093338 Huang Ying 2022-02-08 1823 distances = kcalloc(nr_levels, sizeof(int), GFP_KERNEL);
ed82092e5093338 Huang Ying 2022-02-08 1824 if (!distances) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1825 bitmap_free(distance_map);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1826 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1827 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1828
620a6dc40754dc2 Valentin Schneider 2021-01-22 1829 for (i = 0, j = 0; i < nr_levels; i++, j++) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1830 j = find_next_bit(distance_map, NR_DISTANCE_VALUES, j);
ed82092e5093338 Huang Ying 2022-02-08 1831 distances[i] = j;
f2cb13609d5397c Ingo Molnar 2017-02-01 1832 }
ed82092e5093338 Huang Ying 2022-02-08 1833 rcu_assign_pointer(sched_domains_numa_distance, distances);
f2cb13609d5397c Ingo Molnar 2017-02-01 1834
620a6dc40754dc2 Valentin Schneider 2021-01-22 1835 bitmap_free(distance_map);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1836
f2cb13609d5397c Ingo Molnar 2017-02-01 1837 /*
620a6dc40754dc2 Valentin Schneider 2021-01-22 1838 * 'nr_levels' contains the number of unique distances
f2cb13609d5397c Ingo Molnar 2017-02-01 1839 *
f2cb13609d5397c Ingo Molnar 2017-02-01 1840 * The sched_domains_numa_distance[] array includes the actual distance
f2cb13609d5397c Ingo Molnar 2017-02-01 1841 * numbers.
f2cb13609d5397c Ingo Molnar 2017-02-01 1842 */
f2cb13609d5397c Ingo Molnar 2017-02-01 1843
f2cb13609d5397c Ingo Molnar 2017-02-01 1844 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1845 * Here, we should temporarily reset sched_domains_numa_levels to 0.
f2cb13609d5397c Ingo Molnar 2017-02-01 1846 * If it fails to allocate memory for array sched_domains_numa_masks[][],
620a6dc40754dc2 Valentin Schneider 2021-01-22 1847 * the array will contain less then 'nr_levels' members. This could be
f2cb13609d5397c Ingo Molnar 2017-02-01 1848 * dangerous when we use it to iterate array sched_domains_numa_masks[][]
f2cb13609d5397c Ingo Molnar 2017-02-01 1849 * in other functions.
f2cb13609d5397c Ingo Molnar 2017-02-01 1850 *
620a6dc40754dc2 Valentin Schneider 2021-01-22 1851 * We reset it to 'nr_levels'@the end of this function.
f2cb13609d5397c Ingo Molnar 2017-02-01 1852 */
f2cb13609d5397c Ingo Molnar 2017-02-01 1853 sched_domains_numa_levels = 0;
f2cb13609d5397c Ingo Molnar 2017-02-01 1854
ed82092e5093338 Huang Ying 2022-02-08 1855 masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL);
ed82092e5093338 Huang Ying 2022-02-08 1856 if (!masks)
f2cb13609d5397c Ingo Molnar 2017-02-01 1857 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1858
f2cb13609d5397c Ingo Molnar 2017-02-01 1859 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1860 * Now for each level, construct a mask per node which contains all
f2cb13609d5397c Ingo Molnar 2017-02-01 1861 * CPUs of nodes that are that many hops away from us.
f2cb13609d5397c Ingo Molnar 2017-02-01 1862 */
620a6dc40754dc2 Valentin Schneider 2021-01-22 1863 for (i = 0; i < nr_levels; i++) {
ed82092e5093338 Huang Ying 2022-02-08 1864 masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL);
ed82092e5093338 Huang Ying 2022-02-08 1865 if (!masks[i])
f2cb13609d5397c Ingo Molnar 2017-02-01 @1866 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1867
ed82092e5093338 Huang Ying 2022-02-08 1868 for_each_cpu_node_but(j, offline_node) {
f2cb13609d5397c Ingo Molnar 2017-02-01 1869 struct cpumask *mask = kzalloc(cpumask_size(), GFP_KERNEL);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1870 int k;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1871
f2cb13609d5397c Ingo Molnar 2017-02-01 1872 if (!mask)
f2cb13609d5397c Ingo Molnar 2017-02-01 1873 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1874
ed82092e5093338 Huang Ying 2022-02-08 1875 masks[i][j] = mask;
0083242c93759dd Valentin Schneider 2021-08-18 1876
ed82092e5093338 Huang Ying 2022-02-08 1877 for_each_cpu_node_but(k, offline_node) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1878 if (sched_debug() && (node_distance(j, k) != node_distance(k, j)))
620a6dc40754dc2 Valentin Schneider 2021-01-22 1879 sched_numa_warn("Node-distance not symmetric");
620a6dc40754dc2 Valentin Schneider 2021-01-22 1880
f2cb13609d5397c Ingo Molnar 2017-02-01 1881 if (node_distance(j, k) > sched_domains_numa_distance[i])
f2cb13609d5397c Ingo Molnar 2017-02-01 1882 continue;
f2cb13609d5397c Ingo Molnar 2017-02-01 1883
f2cb13609d5397c Ingo Molnar 2017-02-01 1884 cpumask_or(mask, mask, cpumask_of_node(k));
f2cb13609d5397c Ingo Molnar 2017-02-01 1885 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1886 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1887 }
ed82092e5093338 Huang Ying 2022-02-08 1888 rcu_assign_pointer(sched_domains_numa_masks, masks);
f2cb13609d5397c Ingo Molnar 2017-02-01 1889
f2cb13609d5397c Ingo Molnar 2017-02-01 1890 /* Compute default topology size */
f2cb13609d5397c Ingo Molnar 2017-02-01 1891 for (i = 0; sched_domain_topology[i].mask; i++);
f2cb13609d5397c Ingo Molnar 2017-02-01 1892
71e5f6644fb2f33 Dietmar Eggemann 2021-02-01 1893 tl = kzalloc((i + nr_levels + 1) *
f2cb13609d5397c Ingo Molnar 2017-02-01 1894 sizeof(struct sched_domain_topology_level), GFP_KERNEL);
f2cb13609d5397c Ingo Molnar 2017-02-01 1895 if (!tl)
f2cb13609d5397c Ingo Molnar 2017-02-01 1896 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1897
f2cb13609d5397c Ingo Molnar 2017-02-01 1898 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1899 * Copy the default topology bits..
f2cb13609d5397c Ingo Molnar 2017-02-01 1900 */
f2cb13609d5397c Ingo Molnar 2017-02-01 1901 for (i = 0; sched_domain_topology[i].mask; i++)
f2cb13609d5397c Ingo Molnar 2017-02-01 1902 tl[i] = sched_domain_topology[i];
f2cb13609d5397c Ingo Molnar 2017-02-01 1903
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1904 /*
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1905 * Add the NUMA identity distance, aka single NODE.
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1906 */
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1907 tl[i++] = (struct sched_domain_topology_level){
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1908 .mask = sd_numa_mask,
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1909 .numa_level = 0,
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1910 SD_INIT_NAME(NODE)
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1911 };
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1912
f2cb13609d5397c Ingo Molnar 2017-02-01 1913 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1914 * .. and append 'j' levels of NUMA goodness.
f2cb13609d5397c Ingo Molnar 2017-02-01 1915 */
620a6dc40754dc2 Valentin Schneider 2021-01-22 1916 for (j = 1; j < nr_levels; i++, j++) {
f2cb13609d5397c Ingo Molnar 2017-02-01 1917 tl[i] = (struct sched_domain_topology_level){
f2cb13609d5397c Ingo Molnar 2017-02-01 1918 .mask = sd_numa_mask,
f2cb13609d5397c Ingo Molnar 2017-02-01 1919 .sd_flags = cpu_numa_flags,
f2cb13609d5397c Ingo Molnar 2017-02-01 1920 .flags = SDTL_OVERLAP,
f2cb13609d5397c Ingo Molnar 2017-02-01 1921 .numa_level = j,
f2cb13609d5397c Ingo Molnar 2017-02-01 1922 SD_INIT_NAME(NUMA)
f2cb13609d5397c Ingo Molnar 2017-02-01 1923 };
f2cb13609d5397c Ingo Molnar 2017-02-01 1924 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1925
ed82092e5093338 Huang Ying 2022-02-08 1926 sched_domain_topology_saved = sched_domain_topology;
f2cb13609d5397c Ingo Molnar 2017-02-01 1927 sched_domain_topology = tl;
f2cb13609d5397c Ingo Molnar 2017-02-01 1928
620a6dc40754dc2 Valentin Schneider 2021-01-22 1929 sched_domains_numa_levels = nr_levels;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1930 sched_max_numa_distance = sched_domains_numa_distance[nr_levels - 1];
f2cb13609d5397c Ingo Molnar 2017-02-01 1931
ed82092e5093338 Huang Ying 2022-02-08 1932 init_numa_topology_type(offline_node);
0083242c93759dd Valentin Schneider 2021-08-18 1933 }
0083242c93759dd Valentin Schneider 2021-08-18 1934
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [RFC PATCH -V2] NUMA balancing: fix NUMA topology for systems with CPU-less nodes
@ 2022-02-10 7:55 ` Dan Carpenter
0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2022-02-10 7:55 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 13176 bytes --]
Hi Huang,
url: https://github.com/0day-ci/linux/commits/Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git c8eaf6ac76f40f6c59fc7d056e2e08c4a57ea9c7
config: arm64-randconfig-m031-20220209 (https://download.01.org/0day-ci/archive/20220209/202202092339.FFRMVjDx-lkp(a)intel.com/config)
compiler: aarch64-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
kernel/sched/topology.c:1866 sched_init_numa() warn: possible memory leak of 'masks'
vim +/masks +1866 kernel/sched/topology.c
ed82092e5093338 Huang Ying 2022-02-08 1786 void sched_init_numa(int offline_node)
f2cb13609d5397c Ingo Molnar 2017-02-01 1787 {
f2cb13609d5397c Ingo Molnar 2017-02-01 1788 struct sched_domain_topology_level *tl;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1789 unsigned long *distance_map;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1790 int nr_levels = 0;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1791 int i, j;
ed82092e5093338 Huang Ying 2022-02-08 1792 int *distances;
ed82092e5093338 Huang Ying 2022-02-08 1793 struct cpumask ***masks;
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1794
f2cb13609d5397c Ingo Molnar 2017-02-01 1795 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1796 * O(nr_nodes^2) deduplicating selection sort -- in order to find the
f2cb13609d5397c Ingo Molnar 2017-02-01 1797 * unique distances in the node_distance() table.
f2cb13609d5397c Ingo Molnar 2017-02-01 1798 */
620a6dc40754dc2 Valentin Schneider 2021-01-22 1799 distance_map = bitmap_alloc(NR_DISTANCE_VALUES, GFP_KERNEL);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1800 if (!distance_map)
620a6dc40754dc2 Valentin Schneider 2021-01-22 1801 return;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1802
620a6dc40754dc2 Valentin Schneider 2021-01-22 1803 bitmap_zero(distance_map, NR_DISTANCE_VALUES);
ed82092e5093338 Huang Ying 2022-02-08 1804 for_each_cpu_node_but(i, offline_node) {
ed82092e5093338 Huang Ying 2022-02-08 1805 for_each_cpu_node_but(j, offline_node) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1806 int distance = node_distance(i, j);
f2cb13609d5397c Ingo Molnar 2017-02-01 1807
620a6dc40754dc2 Valentin Schneider 2021-01-22 1808 if (distance < LOCAL_DISTANCE || distance >= NR_DISTANCE_VALUES) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1809 sched_numa_warn("Invalid distance value range");
ed82092e5093338 Huang Ying 2022-02-08 1810 bitmap_free(distance_map);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1811 return;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1812 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1813
620a6dc40754dc2 Valentin Schneider 2021-01-22 1814 bitmap_set(distance_map, distance, 1);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1815 }
620a6dc40754dc2 Valentin Schneider 2021-01-22 1816 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1817 /*
620a6dc40754dc2 Valentin Schneider 2021-01-22 1818 * We can now figure out how many unique distance values there are and
620a6dc40754dc2 Valentin Schneider 2021-01-22 1819 * allocate memory accordingly.
f2cb13609d5397c Ingo Molnar 2017-02-01 1820 */
620a6dc40754dc2 Valentin Schneider 2021-01-22 1821 nr_levels = bitmap_weight(distance_map, NR_DISTANCE_VALUES);
f2cb13609d5397c Ingo Molnar 2017-02-01 1822
ed82092e5093338 Huang Ying 2022-02-08 1823 distances = kcalloc(nr_levels, sizeof(int), GFP_KERNEL);
ed82092e5093338 Huang Ying 2022-02-08 1824 if (!distances) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1825 bitmap_free(distance_map);
Some error paths have cleanup
620a6dc40754dc2 Valentin Schneider 2021-01-22 1826 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1827 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1828
620a6dc40754dc2 Valentin Schneider 2021-01-22 1829 for (i = 0, j = 0; i < nr_levels; i++, j++) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1830 j = find_next_bit(distance_map, NR_DISTANCE_VALUES, j);
ed82092e5093338 Huang Ying 2022-02-08 1831 distances[i] = j;
f2cb13609d5397c Ingo Molnar 2017-02-01 1832 }
ed82092e5093338 Huang Ying 2022-02-08 1833 rcu_assign_pointer(sched_domains_numa_distance, distances);
f2cb13609d5397c Ingo Molnar 2017-02-01 1834
620a6dc40754dc2 Valentin Schneider 2021-01-22 1835 bitmap_free(distance_map);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1836
f2cb13609d5397c Ingo Molnar 2017-02-01 1837 /*
620a6dc40754dc2 Valentin Schneider 2021-01-22 1838 * 'nr_levels' contains the number of unique distances
f2cb13609d5397c Ingo Molnar 2017-02-01 1839 *
f2cb13609d5397c Ingo Molnar 2017-02-01 1840 * The sched_domains_numa_distance[] array includes the actual distance
f2cb13609d5397c Ingo Molnar 2017-02-01 1841 * numbers.
f2cb13609d5397c Ingo Molnar 2017-02-01 1842 */
f2cb13609d5397c Ingo Molnar 2017-02-01 1843
f2cb13609d5397c Ingo Molnar 2017-02-01 1844 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1845 * Here, we should temporarily reset sched_domains_numa_levels to 0.
f2cb13609d5397c Ingo Molnar 2017-02-01 1846 * If it fails to allocate memory for array sched_domains_numa_masks[][],
620a6dc40754dc2 Valentin Schneider 2021-01-22 1847 * the array will contain less then 'nr_levels' members. This could be
f2cb13609d5397c Ingo Molnar 2017-02-01 1848 * dangerous when we use it to iterate array sched_domains_numa_masks[][]
f2cb13609d5397c Ingo Molnar 2017-02-01 1849 * in other functions.
f2cb13609d5397c Ingo Molnar 2017-02-01 1850 *
620a6dc40754dc2 Valentin Schneider 2021-01-22 1851 * We reset it to 'nr_levels'@the end of this function.
f2cb13609d5397c Ingo Molnar 2017-02-01 1852 */
f2cb13609d5397c Ingo Molnar 2017-02-01 1853 sched_domains_numa_levels = 0;
f2cb13609d5397c Ingo Molnar 2017-02-01 1854
ed82092e5093338 Huang Ying 2022-02-08 1855 masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL);
ed82092e5093338 Huang Ying 2022-02-08 1856 if (!masks)
f2cb13609d5397c Ingo Molnar 2017-02-01 1857 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1858
f2cb13609d5397c Ingo Molnar 2017-02-01 1859 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1860 * Now for each level, construct a mask per node which contains all
f2cb13609d5397c Ingo Molnar 2017-02-01 1861 * CPUs of nodes that are that many hops away from us.
f2cb13609d5397c Ingo Molnar 2017-02-01 1862 */
620a6dc40754dc2 Valentin Schneider 2021-01-22 1863 for (i = 0; i < nr_levels; i++) {
ed82092e5093338 Huang Ying 2022-02-08 1864 masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL);
ed82092e5093338 Huang Ying 2022-02-08 1865 if (!masks[i])
f2cb13609d5397c Ingo Molnar 2017-02-01 @1866 return;
But some don't.
f2cb13609d5397c Ingo Molnar 2017-02-01 1867
ed82092e5093338 Huang Ying 2022-02-08 1868 for_each_cpu_node_but(j, offline_node) {
f2cb13609d5397c Ingo Molnar 2017-02-01 1869 struct cpumask *mask = kzalloc(cpumask_size(), GFP_KERNEL);
620a6dc40754dc2 Valentin Schneider 2021-01-22 1870 int k;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1871
f2cb13609d5397c Ingo Molnar 2017-02-01 1872 if (!mask)
f2cb13609d5397c Ingo Molnar 2017-02-01 1873 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1874
ed82092e5093338 Huang Ying 2022-02-08 1875 masks[i][j] = mask;
0083242c93759dd Valentin Schneider 2021-08-18 1876
ed82092e5093338 Huang Ying 2022-02-08 1877 for_each_cpu_node_but(k, offline_node) {
620a6dc40754dc2 Valentin Schneider 2021-01-22 1878 if (sched_debug() && (node_distance(j, k) != node_distance(k, j)))
620a6dc40754dc2 Valentin Schneider 2021-01-22 1879 sched_numa_warn("Node-distance not symmetric");
620a6dc40754dc2 Valentin Schneider 2021-01-22 1880
f2cb13609d5397c Ingo Molnar 2017-02-01 1881 if (node_distance(j, k) > sched_domains_numa_distance[i])
f2cb13609d5397c Ingo Molnar 2017-02-01 1882 continue;
f2cb13609d5397c Ingo Molnar 2017-02-01 1883
f2cb13609d5397c Ingo Molnar 2017-02-01 1884 cpumask_or(mask, mask, cpumask_of_node(k));
f2cb13609d5397c Ingo Molnar 2017-02-01 1885 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1886 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1887 }
ed82092e5093338 Huang Ying 2022-02-08 1888 rcu_assign_pointer(sched_domains_numa_masks, masks);
f2cb13609d5397c Ingo Molnar 2017-02-01 1889
f2cb13609d5397c Ingo Molnar 2017-02-01 1890 /* Compute default topology size */
f2cb13609d5397c Ingo Molnar 2017-02-01 1891 for (i = 0; sched_domain_topology[i].mask; i++);
f2cb13609d5397c Ingo Molnar 2017-02-01 1892
71e5f6644fb2f33 Dietmar Eggemann 2021-02-01 1893 tl = kzalloc((i + nr_levels + 1) *
f2cb13609d5397c Ingo Molnar 2017-02-01 1894 sizeof(struct sched_domain_topology_level), GFP_KERNEL);
f2cb13609d5397c Ingo Molnar 2017-02-01 1895 if (!tl)
f2cb13609d5397c Ingo Molnar 2017-02-01 1896 return;
f2cb13609d5397c Ingo Molnar 2017-02-01 1897
f2cb13609d5397c Ingo Molnar 2017-02-01 1898 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1899 * Copy the default topology bits..
f2cb13609d5397c Ingo Molnar 2017-02-01 1900 */
f2cb13609d5397c Ingo Molnar 2017-02-01 1901 for (i = 0; sched_domain_topology[i].mask; i++)
f2cb13609d5397c Ingo Molnar 2017-02-01 1902 tl[i] = sched_domain_topology[i];
f2cb13609d5397c Ingo Molnar 2017-02-01 1903
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1904 /*
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1905 * Add the NUMA identity distance, aka single NODE.
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1906 */
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1907 tl[i++] = (struct sched_domain_topology_level){
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1908 .mask = sd_numa_mask,
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1909 .numa_level = 0,
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1910 SD_INIT_NAME(NODE)
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1911 };
051f3ca02e46432 Suravee Suthikulpanit 2017-09-07 1912
f2cb13609d5397c Ingo Molnar 2017-02-01 1913 /*
f2cb13609d5397c Ingo Molnar 2017-02-01 1914 * .. and append 'j' levels of NUMA goodness.
f2cb13609d5397c Ingo Molnar 2017-02-01 1915 */
620a6dc40754dc2 Valentin Schneider 2021-01-22 1916 for (j = 1; j < nr_levels; i++, j++) {
f2cb13609d5397c Ingo Molnar 2017-02-01 1917 tl[i] = (struct sched_domain_topology_level){
f2cb13609d5397c Ingo Molnar 2017-02-01 1918 .mask = sd_numa_mask,
f2cb13609d5397c Ingo Molnar 2017-02-01 1919 .sd_flags = cpu_numa_flags,
f2cb13609d5397c Ingo Molnar 2017-02-01 1920 .flags = SDTL_OVERLAP,
f2cb13609d5397c Ingo Molnar 2017-02-01 1921 .numa_level = j,
f2cb13609d5397c Ingo Molnar 2017-02-01 1922 SD_INIT_NAME(NUMA)
f2cb13609d5397c Ingo Molnar 2017-02-01 1923 };
f2cb13609d5397c Ingo Molnar 2017-02-01 1924 }
f2cb13609d5397c Ingo Molnar 2017-02-01 1925
ed82092e5093338 Huang Ying 2022-02-08 1926 sched_domain_topology_saved = sched_domain_topology;
f2cb13609d5397c Ingo Molnar 2017-02-01 1927 sched_domain_topology = tl;
f2cb13609d5397c Ingo Molnar 2017-02-01 1928
620a6dc40754dc2 Valentin Schneider 2021-01-22 1929 sched_domains_numa_levels = nr_levels;
620a6dc40754dc2 Valentin Schneider 2021-01-22 1930 sched_max_numa_distance = sched_domains_numa_distance[nr_levels - 1];
f2cb13609d5397c Ingo Molnar 2017-02-01 1931
ed82092e5093338 Huang Ying 2022-02-08 1932 init_numa_topology_type(offline_node);
0083242c93759dd Valentin Schneider 2021-08-18 1933 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC PATCH -V2] NUMA balancing: fix NUMA topology for systems with CPU-less nodes
@ 2022-02-08 12:23 Huang Ying
2022-02-08 16:51 ` kernel test robot
2022-02-08 17:23 ` kernel test robot
0 siblings, 2 replies; 7+ messages in thread
From: Huang Ying @ 2022-02-08 12:23 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, Huang Ying, Valentin Schneider, Ingo Molnar,
Mel Gorman, Rik van Riel, Srikar Dronamraju
The NUMA topology parameters (sched_numa_topology_type,
sched_domains_numa_levels, and sched_max_numa_distance, etc.)
identified by scheduler may be wrong for systems with CPU-less nodes.
For example, the ACPI SLIT of a system with CPU-less persistent
memory (Intel Optane DCPMM) nodes is as follows,
[000h 0000 4] Signature : "SLIT" [System Locality Information Table]
[004h 0004 4] Table Length : 0000042C
[008h 0008 1] Revision : 01
[009h 0009 1] Checksum : 59
[00Ah 0010 6] Oem ID : "XXXX"
[010h 0016 8] Oem Table ID : "XXXXXXX"
[018h 0024 4] Oem Revision : 00000001
[01Ch 0028 4] Asl Compiler ID : "INTL"
[020h 0032 4] Asl Compiler Revision : 20091013
[024h 0036 8] Localities : 0000000000000004
[02Ch 0044 4] Locality 0 : 0A 15 11 1C
[030h 0048 4] Locality 1 : 15 0A 1C 11
[034h 0052 4] Locality 2 : 11 1C 0A 1C
[038h 0056 4] Locality 3 : 1C 11 1C 0A
While the `numactl -H` output is as follows,
available: 4 nodes (0-3)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
node 0 size: 64136 MB
node 0 free: 5981 MB
node 1 cpus: 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
node 1 size: 64466 MB
node 1 free: 10415 MB
node 2 cpus:
node 2 size: 253952 MB
node 2 free: 253920 MB
node 3 cpus:
node 3 size: 253952 MB
node 3 free: 253951 MB
node distances:
node 0 1 2 3
0: 10 21 17 28
1: 21 10 28 17
2: 17 28 10 28
3: 28 17 28 10
In this system, there are only 2 sockets. In each memory controller,
both DRAM and PMEM DIMMs are installed. Although the physical NUMA
topology is simple, the logical NUMA topology becomes a little
complex. Because both the distance(0, 1) and distance (1, 3) are less
than the distance (0, 3), it appears that node 1 sits between node 0
and node 3. And the whole system appears to be a glueless mesh NUMA
topology type. But it's definitely not, there is even no CPU in node 3.
This isn't a practical problem now yet. Because the PMEM nodes (node
2 and node 3 in example system) are offlined by default during system
boot. So init_numa_topology_type() called during system boot will
ignore them and set sched_numa_topology_type to NUMA_DIRECT. And
init_numa_topology_type() is only called at runtime when a CPU of a
never-onlined-before node gets plugged in. And there's no CPU in the
PMEM nodes. But it appears better to fix this to make the code more
robust.
To test the potential problem. We have used a debug patch to call
init_numa_topology_type() when the PMEM node is onlined (in
__set_migration_target_nodes()). With that, the NUMA parameters
identified by scheduler is as follows,
sched_numa_topology_type: NUMA_GLUELESS_MESH
sched_domains_numa_levels: 4
sched_max_numa_distance: 28
To fix the issue, the CPU-less nodes are ignored when the NUMA topology
parameters are identified. Because a node may become CPU-less or not
at run time because of CPU hotplug, the NUMA topology parameters need
to be re-initialized at runtime for CPU hotplug too.
With the patch, the NUMA parameters identified for the example system
above is as follows,
sched_numa_topology_type: NUMA_DIRECT
sched_domains_numa_levels: 2
sched_max_numa_distance: 21
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Cc: Valentin Schneider <valentin.schneider@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@surriel.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
---
kernel/sched/core.c | 4 +-
kernel/sched/fair.c | 2 +-
kernel/sched/sched.h | 3 +-
kernel/sched/topology.c | 204 +++++++++++++++++++++++-----------------
4 files changed, 126 insertions(+), 87 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 848eaa0efe0e..ec97834dbc0e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9044,6 +9044,7 @@ int sched_cpu_activate(unsigned int cpu)
set_cpu_active(cpu, true);
if (sched_smp_initialized) {
+ sched_reinit_numa(true, cpu);
sched_domains_numa_masks_set(cpu);
cpuset_cpu_active();
}
@@ -9122,6 +9123,7 @@ int sched_cpu_deactivate(unsigned int cpu)
if (!sched_smp_initialized)
return 0;
+ sched_reinit_numa(false, cpu);
ret = cpuset_cpu_inactive(cpu);
if (ret) {
balance_push_set(cpu, false);
@@ -9228,7 +9230,7 @@ int sched_cpu_dying(unsigned int cpu)
void __init sched_init_smp(void)
{
- sched_init_numa();
+ sched_init_numa(NUMA_NO_NODE);
/*
* There's no userspace yet to cause hotplug operations; hence all the
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 5146163bfabb..fe5450ef78e0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1283,7 +1283,7 @@ static unsigned long score_nearby_nodes(struct task_struct *p, int nid,
* The furthest away nodes in the system are not interesting
* for placement; nid was already counted.
*/
- if (dist == sched_max_numa_distance || node == nid)
+ if (dist >= sched_max_numa_distance || node == nid)
continue;
/*
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index de53be905739..0481a385c7a9 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1662,7 +1662,8 @@ enum numa_topology_type {
extern enum numa_topology_type sched_numa_topology_type;
extern int sched_max_numa_distance;
extern bool find_numa_distance(int distance);
-extern void sched_init_numa(void);
+extern void sched_init_numa(int offline_node);
+extern void sched_reinit_numa(bool online, int cpu);
extern void sched_domains_numa_masks_set(unsigned int cpu);
extern void sched_domains_numa_masks_clear(unsigned int cpu);
extern int sched_numa_find_closest(const struct cpumask *cpus, int cpu);
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index d201a7052a29..82107788dc3d 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1492,8 +1492,6 @@ static int sched_domains_curr_level;
int sched_max_numa_distance;
static int *sched_domains_numa_distance;
static struct cpumask ***sched_domains_numa_masks;
-
-static unsigned long __read_mostly *sched_numa_onlined_nodes;
#endif
/*
@@ -1651,6 +1649,7 @@ static struct sched_domain_topology_level default_topology[] = {
static struct sched_domain_topology_level *sched_domain_topology =
default_topology;
+static struct sched_domain_topology_level *sched_domain_topology_saved;
#define for_each_sd_topology(tl) \
for (tl = sched_domain_topology; tl->mask; tl++)
@@ -1661,6 +1660,7 @@ void set_sched_topology(struct sched_domain_topology_level *tl)
return;
sched_domain_topology = tl;
+ sched_domain_topology_saved = NULL;
}
#ifdef CONFIG_NUMA
@@ -1684,8 +1684,12 @@ static void sched_numa_warn(const char *str)
for (i = 0; i < nr_node_ids; i++) {
printk(KERN_WARNING " ");
- for (j = 0; j < nr_node_ids; j++)
- printk(KERN_CONT "%02d ", node_distance(i,j));
+ for (j = 0; j < nr_node_ids; j++) {
+ if (!node_state(i, N_CPU) || !node_state(j, N_CPU))
+ printk(KERN_CONT "(%02d) ", node_distance(i,j));
+ else
+ printk(KERN_CONT " %02d ", node_distance(i,j));
+ }
printk(KERN_CONT "\n");
}
printk(KERN_WARNING "\n");
@@ -1693,19 +1697,34 @@ static void sched_numa_warn(const char *str)
bool find_numa_distance(int distance)
{
- int i;
+ bool found = false;
+ int i, *distances;
if (distance == node_distance(0, 0))
return true;
+ rcu_read_lock();
+ distances = rcu_dereference(sched_domains_numa_distance);
+ if (!distances)
+ goto unlock;
for (i = 0; i < sched_domains_numa_levels; i++) {
- if (sched_domains_numa_distance[i] == distance)
- return true;
+ if (distances[i] == distance) {
+ found = true;
+ break;
+ }
}
+unlock:
+ rcu_read_unlock();
- return false;
+ return found;
}
+#define for_each_cpu_node_but(n, nbut) \
+ for_each_node_state(n, N_CPU) \
+ if (n == nbut) \
+ continue; \
+ else
+
/*
* A system can have three types of NUMA topology:
* NUMA_DIRECT: all nodes are directly connected, or not a NUMA system
@@ -1725,7 +1744,7 @@ bool find_numa_distance(int distance)
* there is an intermediary node C, which is < N hops away from both
* nodes A and B, the system is a glueless mesh.
*/
-static void init_numa_topology_type(void)
+static void init_numa_topology_type(int offline_node)
{
int a, b, c, n;
@@ -1736,14 +1755,14 @@ static void init_numa_topology_type(void)
return;
}
- for_each_online_node(a) {
- for_each_online_node(b) {
+ for_each_cpu_node_but(a, offline_node) {
+ for_each_cpu_node_but(b, offline_node) {
/* Find two nodes furthest removed from each other. */
if (node_distance(a, b) < n)
continue;
/* Is there an intermediary node between a and b? */
- for_each_online_node(c) {
+ for_each_cpu_node_but(c, offline_node) {
if (node_distance(a, c) < n &&
node_distance(b, c) < n) {
sched_numa_topology_type =
@@ -1756,17 +1775,22 @@ static void init_numa_topology_type(void)
return;
}
}
+
+ pr_err("Failed to find a NUMA topology type, defaulting to DIRECT\n");
+ sched_numa_topology_type = NUMA_DIRECT;
}
#define NR_DISTANCE_VALUES (1 << DISTANCE_BITS)
-void sched_init_numa(void)
+void sched_init_numa(int offline_node)
{
struct sched_domain_topology_level *tl;
unsigned long *distance_map;
int nr_levels = 0;
int i, j;
+ int *distances;
+ struct cpumask ***masks;
/*
* O(nr_nodes^2) deduplicating selection sort -- in order to find the
@@ -1777,12 +1801,13 @@ void sched_init_numa(void)
return;
bitmap_zero(distance_map, NR_DISTANCE_VALUES);
- for (i = 0; i < nr_node_ids; i++) {
- for (j = 0; j < nr_node_ids; j++) {
+ for_each_cpu_node_but(i, offline_node) {
+ for_each_cpu_node_but(j, offline_node) {
int distance = node_distance(i, j);
if (distance < LOCAL_DISTANCE || distance >= NR_DISTANCE_VALUES) {
sched_numa_warn("Invalid distance value range");
+ bitmap_free(distance_map);
return;
}
@@ -1795,16 +1820,17 @@ void sched_init_numa(void)
*/
nr_levels = bitmap_weight(distance_map, NR_DISTANCE_VALUES);
- sched_domains_numa_distance = kcalloc(nr_levels, sizeof(int), GFP_KERNEL);
- if (!sched_domains_numa_distance) {
+ distances = kcalloc(nr_levels, sizeof(int), GFP_KERNEL);
+ if (!distances) {
bitmap_free(distance_map);
return;
}
for (i = 0, j = 0; i < nr_levels; i++, j++) {
j = find_next_bit(distance_map, NR_DISTANCE_VALUES, j);
- sched_domains_numa_distance[i] = j;
+ distances[i] = j;
}
+ rcu_assign_pointer(sched_domains_numa_distance, distances);
bitmap_free(distance_map);
@@ -1826,8 +1852,8 @@ void sched_init_numa(void)
*/
sched_domains_numa_levels = 0;
- sched_domains_numa_masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL);
- if (!sched_domains_numa_masks)
+ masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL);
+ if (!masks)
return;
/*
@@ -1835,31 +1861,20 @@ void sched_init_numa(void)
* CPUs of nodes that are that many hops away from us.
*/
for (i = 0; i < nr_levels; i++) {
- sched_domains_numa_masks[i] =
- kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL);
- if (!sched_domains_numa_masks[i])
+ masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL);
+ if (!masks[i])
return;
- for (j = 0; j < nr_node_ids; j++) {
+ for_each_cpu_node_but(j, offline_node) {
struct cpumask *mask = kzalloc(cpumask_size(), GFP_KERNEL);
int k;
if (!mask)
return;
- sched_domains_numa_masks[i][j] = mask;
-
- for_each_node(k) {
- /*
- * Distance information can be unreliable for
- * offline nodes, defer building the node
- * masks to its bringup.
- * This relies on all unique distance values
- * still being visible at init time.
- */
- if (!node_online(j))
- continue;
+ masks[i][j] = mask;
+ for_each_cpu_node_but(k, offline_node) {
if (sched_debug() && (node_distance(j, k) != node_distance(k, j)))
sched_numa_warn("Node-distance not symmetric");
@@ -1870,6 +1885,7 @@ void sched_init_numa(void)
}
}
}
+ rcu_assign_pointer(sched_domains_numa_masks, masks);
/* Compute default topology size */
for (i = 0; sched_domain_topology[i].mask; i++);
@@ -1907,59 +1923,67 @@ void sched_init_numa(void)
};
}
+ sched_domain_topology_saved = sched_domain_topology;
sched_domain_topology = tl;
sched_domains_numa_levels = nr_levels;
sched_max_numa_distance = sched_domains_numa_distance[nr_levels - 1];
- init_numa_topology_type();
-
- sched_numa_onlined_nodes = bitmap_alloc(nr_node_ids, GFP_KERNEL);
- if (!sched_numa_onlined_nodes)
- return;
-
- bitmap_zero(sched_numa_onlined_nodes, nr_node_ids);
- for_each_online_node(i)
- bitmap_set(sched_numa_onlined_nodes, i, 1);
+ init_numa_topology_type(offline_node);
}
-static void __sched_domains_numa_masks_set(unsigned int node)
-{
- int i, j;
-
- /*
- * NUMA masks are not built for offline nodes in sched_init_numa().
- * Thus, when a CPU of a never-onlined-before node gets plugged in,
- * adding that new CPU to the right NUMA masks is not sufficient: the
- * masks of that CPU's node must also be updated.
- */
- if (test_bit(node, sched_numa_onlined_nodes))
- return;
- bitmap_set(sched_numa_onlined_nodes, node, 1);
-
- for (i = 0; i < sched_domains_numa_levels; i++) {
- for (j = 0; j < nr_node_ids; j++) {
- if (!node_online(j) || node == j)
- continue;
+void sched_reset_numa(void)
+{
+ int nr_levels, *distances;
+ struct cpumask ***masks;
- if (node_distance(j, node) > sched_domains_numa_distance[i])
+ nr_levels = sched_domains_numa_levels;
+ sched_domains_numa_levels = 0;
+ sched_max_numa_distance = 0;
+ sched_numa_topology_type = NUMA_DIRECT;
+ distances = sched_domains_numa_distance;
+ rcu_assign_pointer(sched_domains_numa_distance, NULL);
+ masks = sched_domains_numa_masks;
+ rcu_assign_pointer(sched_domains_numa_masks, NULL);
+ if (distances || masks) {
+ int i, j;
+
+ synchronize_rcu();
+ kfree(distances);
+ for (i = 0; i < nr_levels && masks; i++) {
+ if (!masks[i])
continue;
-
- /* Add remote nodes in our masks */
- cpumask_or(sched_domains_numa_masks[i][node],
- sched_domains_numa_masks[i][node],
- sched_domains_numa_masks[0][j]);
+ for_each_node(j)
+ kfree(masks[i][j]);
+ kfree(masks[i]);
}
+ kfree(masks);
}
+ if (sched_domain_topology_saved) {
+ kfree(sched_domain_topology);
+ sched_domain_topology = sched_domain_topology_saved;
+ sched_domain_topology_saved = NULL;
+ }
+}
+
+/*
+ * Call with hotplug lock held
+ */
+void sched_reinit_numa(bool online, int cpu)
+{
+ int node;
+ node = cpu_to_node(cpu);
/*
- * A new node has been brought up, potentially changing the topology
- * classification.
- *
- * Note that this is racy vs any use of sched_numa_topology_type :/
+ * Scheduler NUMA topology is updated when the first CPU of a
+ * node is onlined or the last CPU of a node is offlined.
*/
- init_numa_topology_type();
+ if (cpumask_weight(cpumask_of_node(node)) != 1)
+ return;
+
+ sched_reset_numa();
+ sched_init_numa(online ? NUMA_NO_NODE : node);
}
void sched_domains_numa_masks_set(unsigned int cpu)
@@ -1967,11 +1991,9 @@ void sched_domains_numa_masks_set(unsigned int cpu)
int node = cpu_to_node(cpu);
int i, j;
- __sched_domains_numa_masks_set(node);
-
for (i = 0; i < sched_domains_numa_levels; i++) {
for (j = 0; j < nr_node_ids; j++) {
- if (!node_online(j))
+ if (!node_state(j, N_CPU))
continue;
/* Set ourselves in the remote node's masks */
@@ -1986,8 +2008,10 @@ void sched_domains_numa_masks_clear(unsigned int cpu)
int i, j;
for (i = 0; i < sched_domains_numa_levels; i++) {
- for (j = 0; j < nr_node_ids; j++)
- cpumask_clear_cpu(cpu, sched_domains_numa_masks[i][j]);
+ for (j = 0; j < nr_node_ids; j++) {
+ if (sched_domains_numa_masks[i][j])
+ cpumask_clear_cpu(cpu, sched_domains_numa_masks[i][j]);
+ }
}
}
@@ -2001,14 +2025,26 @@ void sched_domains_numa_masks_clear(unsigned int cpu)
*/
int sched_numa_find_closest(const struct cpumask *cpus, int cpu)
{
- int i, j = cpu_to_node(cpu);
+ int i, j = cpu_to_node(cpu), found = nr_cpu_ids;
+ struct cpumask ***masks;
+ rcu_read_lock();
+ masks = rcu_dereference(sched_domains_numa_masks);
+ if (!masks)
+ goto unlock;
for (i = 0; i < sched_domains_numa_levels; i++) {
- cpu = cpumask_any_and(cpus, sched_domains_numa_masks[i][j]);
- if (cpu < nr_cpu_ids)
- return cpu;
+ if (!masks[i][j])
+ break;
+ cpu = cpumask_any_and(cpus, masks[i][j]);
+ if (cpu < nr_cpu_ids) {
+ found = cpu;
+ break;
+ }
}
- return nr_cpu_ids;
+unlock:
+ rcu_read_unlock();
+
+ return found;
}
#endif /* CONFIG_NUMA */
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [RFC PATCH -V2] NUMA balancing: fix NUMA topology for systems with CPU-less nodes
2022-02-08 12:23 Huang Ying
@ 2022-02-08 16:51 ` kernel test robot
2022-02-08 17:23 ` kernel test robot
1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-02-08 16:51 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 10421 bytes --]
Hi Huang,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on tip/sched/core]
[also build test ERROR on linux/master linus/master v5.17-rc3 next-20220208]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git c8eaf6ac76f40f6c59fc7d056e2e08c4a57ea9c7
config: arc-randconfig-r035-20220208 (https://download.01.org/0day-ci/archive/20220209/202202090047.ctMW1o2G-lkp(a)intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ed82092e509333870d756fc8e53d816885922fc4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
git checkout ed82092e509333870d756fc8e53d816885922fc4
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
kernel/sched/core.c:3454:6: warning: no previous prototype for 'sched_set_stop_task' [-Wmissing-prototypes]
3454 | void sched_set_stop_task(int cpu, struct task_struct *stop)
| ^~~~~~~~~~~~~~~~~~~
kernel/sched/core.c: In function 'sched_cpu_activate':
>> kernel/sched/core.c:9055:17: error: implicit declaration of function 'sched_reinit_numa'; did you mean 'sched_init_numa'? [-Werror=implicit-function-declaration]
9055 | sched_reinit_numa(true, cpu);
| ^~~~~~~~~~~~~~~~~
| sched_init_numa
kernel/sched/core.c: In function 'sched_init_smp':
>> kernel/sched/core.c:9241:9: error: too many arguments to function 'sched_init_numa'
9241 | sched_init_numa(NUMA_NO_NODE);
| ^~~~~~~~~~~~~~~
In file included from kernel/sched/core.c:13:
kernel/sched/sched.h:1671:20: note: declared here
1671 | static inline void sched_init_numa(void) { }
| ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +9055 kernel/sched/core.c
9033
9034 int sched_cpu_activate(unsigned int cpu)
9035 {
9036 struct rq *rq = cpu_rq(cpu);
9037 struct rq_flags rf;
9038
9039 /*
9040 * Clear the balance_push callback and prepare to schedule
9041 * regular tasks.
9042 */
9043 balance_push_set(cpu, false);
9044
9045 #ifdef CONFIG_SCHED_SMT
9046 /*
9047 * When going up, increment the number of cores with SMT present.
9048 */
9049 if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9050 static_branch_inc_cpuslocked(&sched_smt_present);
9051 #endif
9052 set_cpu_active(cpu, true);
9053
9054 if (sched_smp_initialized) {
> 9055 sched_reinit_numa(true, cpu);
9056 sched_domains_numa_masks_set(cpu);
9057 cpuset_cpu_active();
9058 }
9059
9060 /*
9061 * Put the rq online, if not already. This happens:
9062 *
9063 * 1) In the early boot process, because we build the real domains
9064 * after all CPUs have been brought up.
9065 *
9066 * 2) At runtime, if cpuset_cpu_active() fails to rebuild the
9067 * domains.
9068 */
9069 rq_lock_irqsave(rq, &rf);
9070 if (rq->rd) {
9071 BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
9072 set_rq_online(rq);
9073 }
9074 rq_unlock_irqrestore(rq, &rf);
9075
9076 return 0;
9077 }
9078
9079 int sched_cpu_deactivate(unsigned int cpu)
9080 {
9081 struct rq *rq = cpu_rq(cpu);
9082 struct rq_flags rf;
9083 int ret;
9084
9085 /*
9086 * Remove CPU from nohz.idle_cpus_mask to prevent participating in
9087 * load balancing when not active
9088 */
9089 nohz_balance_exit_idle(rq);
9090
9091 set_cpu_active(cpu, false);
9092
9093 /*
9094 * From this point forward, this CPU will refuse to run any task that
9095 * is not: migrate_disable() or KTHREAD_IS_PER_CPU, and will actively
9096 * push those tasks away until this gets cleared, see
9097 * sched_cpu_dying().
9098 */
9099 balance_push_set(cpu, true);
9100
9101 /*
9102 * We've cleared cpu_active_mask / set balance_push, wait for all
9103 * preempt-disabled and RCU users of this state to go away such that
9104 * all new such users will observe it.
9105 *
9106 * Specifically, we rely on ttwu to no longer target this CPU, see
9107 * ttwu_queue_cond() and is_cpu_allowed().
9108 *
9109 * Do sync before park smpboot threads to take care the rcu boost case.
9110 */
9111 synchronize_rcu();
9112
9113 rq_lock_irqsave(rq, &rf);
9114 if (rq->rd) {
9115 update_rq_clock(rq);
9116 BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
9117 set_rq_offline(rq);
9118 }
9119 rq_unlock_irqrestore(rq, &rf);
9120
9121 #ifdef CONFIG_SCHED_SMT
9122 /*
9123 * When going down, decrement the number of cores with SMT present.
9124 */
9125 if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9126 static_branch_dec_cpuslocked(&sched_smt_present);
9127
9128 sched_core_cpu_deactivate(cpu);
9129 #endif
9130
9131 if (!sched_smp_initialized)
9132 return 0;
9133
9134 sched_reinit_numa(false, cpu);
9135 ret = cpuset_cpu_inactive(cpu);
9136 if (ret) {
9137 balance_push_set(cpu, false);
9138 set_cpu_active(cpu, true);
9139 return ret;
9140 }
9141 sched_domains_numa_masks_clear(cpu);
9142 return 0;
9143 }
9144
9145 static void sched_rq_cpu_starting(unsigned int cpu)
9146 {
9147 struct rq *rq = cpu_rq(cpu);
9148
9149 rq->calc_load_update = calc_load_update;
9150 update_max_interval();
9151 }
9152
9153 int sched_cpu_starting(unsigned int cpu)
9154 {
9155 sched_core_cpu_starting(cpu);
9156 sched_rq_cpu_starting(cpu);
9157 sched_tick_start(cpu);
9158 return 0;
9159 }
9160
9161 #ifdef CONFIG_HOTPLUG_CPU
9162
9163 /*
9164 * Invoked immediately before the stopper thread is invoked to bring the
9165 * CPU down completely. At this point all per CPU kthreads except the
9166 * hotplug thread (current) and the stopper thread (inactive) have been
9167 * either parked or have been unbound from the outgoing CPU. Ensure that
9168 * any of those which might be on the way out are gone.
9169 *
9170 * If after this point a bound task is being woken on this CPU then the
9171 * responsible hotplug callback has failed to do it's job.
9172 * sched_cpu_dying() will catch it with the appropriate fireworks.
9173 */
9174 int sched_cpu_wait_empty(unsigned int cpu)
9175 {
9176 balance_hotplug_wait();
9177 return 0;
9178 }
9179
9180 /*
9181 * Since this CPU is going 'away' for a while, fold any nr_active delta we
9182 * might have. Called from the CPU stopper task after ensuring that the
9183 * stopper is the last running task on the CPU, so nr_active count is
9184 * stable. We need to take the teardown thread which is calling this into
9185 * account, so we hand in adjust = 1 to the load calculation.
9186 *
9187 * Also see the comment "Global load-average calculations".
9188 */
9189 static void calc_load_migrate(struct rq *rq)
9190 {
9191 long delta = calc_load_fold_active(rq, 1);
9192
9193 if (delta)
9194 atomic_long_add(delta, &calc_load_tasks);
9195 }
9196
9197 static void dump_rq_tasks(struct rq *rq, const char *loglvl)
9198 {
9199 struct task_struct *g, *p;
9200 int cpu = cpu_of(rq);
9201
9202 lockdep_assert_rq_held(rq);
9203
9204 printk("%sCPU%d enqueued tasks (%u total):\n", loglvl, cpu, rq->nr_running);
9205 for_each_process_thread(g, p) {
9206 if (task_cpu(p) != cpu)
9207 continue;
9208
9209 if (!task_on_rq_queued(p))
9210 continue;
9211
9212 printk("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);
9213 }
9214 }
9215
9216 int sched_cpu_dying(unsigned int cpu)
9217 {
9218 struct rq *rq = cpu_rq(cpu);
9219 struct rq_flags rf;
9220
9221 /* Handle pending wakeups and then migrate everything off */
9222 sched_tick_stop(cpu);
9223
9224 rq_lock_irqsave(rq, &rf);
9225 if (rq->nr_running != 1 || rq_has_pinned_tasks(rq)) {
9226 WARN(true, "Dying CPU not properly vacated!");
9227 dump_rq_tasks(rq, KERN_WARNING);
9228 }
9229 rq_unlock_irqrestore(rq, &rf);
9230
9231 calc_load_migrate(rq);
9232 update_max_interval();
9233 hrtick_clear(rq);
9234 sched_core_cpu_dying(cpu);
9235 return 0;
9236 }
9237 #endif
9238
9239 void __init sched_init_smp(void)
9240 {
> 9241 sched_init_numa(NUMA_NO_NODE);
9242
9243 /*
9244 * There's no userspace yet to cause hotplug operations; hence all the
9245 * CPU masks are stable and all blatant races in the below code cannot
9246 * happen.
9247 */
9248 mutex_lock(&sched_domains_mutex);
9249 sched_init_domains(cpu_active_mask);
9250 mutex_unlock(&sched_domains_mutex);
9251
9252 /* Move init over to a non-isolated CPU */
9253 if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0)
9254 BUG();
9255 current->flags &= ~PF_NO_SETAFFINITY;
9256 sched_init_granularity();
9257
9258 init_sched_rt_class();
9259 init_sched_dl_class();
9260
9261 sched_smp_initialized = true;
9262 }
9263
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [RFC PATCH -V2] NUMA balancing: fix NUMA topology for systems with CPU-less nodes
2022-02-08 12:23 Huang Ying
@ 2022-02-08 17:23 ` kernel test robot
2022-02-08 17:23 ` kernel test robot
1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-02-08 17:23 UTC (permalink / raw)
To: Huang Ying; +Cc: llvm, kbuild-all
Hi Huang,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on tip/sched/core]
[also build test ERROR on linux/master linus/master v5.17-rc3 next-20220208]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git c8eaf6ac76f40f6c59fc7d056e2e08c4a57ea9c7
config: hexagon-randconfig-r045-20220208 (https://download.01.org/0day-ci/archive/20220209/202202090152.0LoawqhI-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project e8bff9ae54a55b4dbfeb6ba55f723abbd81bf494)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ed82092e509333870d756fc8e53d816885922fc4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
git checkout ed82092e509333870d756fc8e53d816885922fc4
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash kernel/sched/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
kernel/sched/core.c:3454:6: warning: no previous prototype for function 'sched_set_stop_task' [-Wmissing-prototypes]
void sched_set_stop_task(int cpu, struct task_struct *stop)
^
kernel/sched/core.c:3454:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void sched_set_stop_task(int cpu, struct task_struct *stop)
^
static
>> kernel/sched/core.c:9055:3: error: implicit declaration of function 'sched_reinit_numa' [-Werror,-Wimplicit-function-declaration]
sched_reinit_numa(true, cpu);
^
kernel/sched/core.c:9055:3: note: did you mean 'sched_init_numa'?
kernel/sched/sched.h:1671:20: note: 'sched_init_numa' declared here
static inline void sched_init_numa(void) { }
^
kernel/sched/core.c:9134:2: error: implicit declaration of function 'sched_reinit_numa' [-Werror,-Wimplicit-function-declaration]
sched_reinit_numa(false, cpu);
^
>> kernel/sched/core.c:9241:18: error: too many arguments to function call, expected 0, have 1
sched_init_numa(NUMA_NO_NODE);
~~~~~~~~~~~~~~~ ^~~~~~~~~~~~
include/linux/numa.h:14:22: note: expanded from macro 'NUMA_NO_NODE'
#define NUMA_NO_NODE (-1)
^~~~
kernel/sched/sched.h:1671:20: note: 'sched_init_numa' declared here
static inline void sched_init_numa(void) { }
^
1 warning and 3 errors generated.
vim +/sched_reinit_numa +9055 kernel/sched/core.c
9033
9034 int sched_cpu_activate(unsigned int cpu)
9035 {
9036 struct rq *rq = cpu_rq(cpu);
9037 struct rq_flags rf;
9038
9039 /*
9040 * Clear the balance_push callback and prepare to schedule
9041 * regular tasks.
9042 */
9043 balance_push_set(cpu, false);
9044
9045 #ifdef CONFIG_SCHED_SMT
9046 /*
9047 * When going up, increment the number of cores with SMT present.
9048 */
9049 if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9050 static_branch_inc_cpuslocked(&sched_smt_present);
9051 #endif
9052 set_cpu_active(cpu, true);
9053
9054 if (sched_smp_initialized) {
> 9055 sched_reinit_numa(true, cpu);
9056 sched_domains_numa_masks_set(cpu);
9057 cpuset_cpu_active();
9058 }
9059
9060 /*
9061 * Put the rq online, if not already. This happens:
9062 *
9063 * 1) In the early boot process, because we build the real domains
9064 * after all CPUs have been brought up.
9065 *
9066 * 2) At runtime, if cpuset_cpu_active() fails to rebuild the
9067 * domains.
9068 */
9069 rq_lock_irqsave(rq, &rf);
9070 if (rq->rd) {
9071 BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
9072 set_rq_online(rq);
9073 }
9074 rq_unlock_irqrestore(rq, &rf);
9075
9076 return 0;
9077 }
9078
9079 int sched_cpu_deactivate(unsigned int cpu)
9080 {
9081 struct rq *rq = cpu_rq(cpu);
9082 struct rq_flags rf;
9083 int ret;
9084
9085 /*
9086 * Remove CPU from nohz.idle_cpus_mask to prevent participating in
9087 * load balancing when not active
9088 */
9089 nohz_balance_exit_idle(rq);
9090
9091 set_cpu_active(cpu, false);
9092
9093 /*
9094 * From this point forward, this CPU will refuse to run any task that
9095 * is not: migrate_disable() or KTHREAD_IS_PER_CPU, and will actively
9096 * push those tasks away until this gets cleared, see
9097 * sched_cpu_dying().
9098 */
9099 balance_push_set(cpu, true);
9100
9101 /*
9102 * We've cleared cpu_active_mask / set balance_push, wait for all
9103 * preempt-disabled and RCU users of this state to go away such that
9104 * all new such users will observe it.
9105 *
9106 * Specifically, we rely on ttwu to no longer target this CPU, see
9107 * ttwu_queue_cond() and is_cpu_allowed().
9108 *
9109 * Do sync before park smpboot threads to take care the rcu boost case.
9110 */
9111 synchronize_rcu();
9112
9113 rq_lock_irqsave(rq, &rf);
9114 if (rq->rd) {
9115 update_rq_clock(rq);
9116 BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
9117 set_rq_offline(rq);
9118 }
9119 rq_unlock_irqrestore(rq, &rf);
9120
9121 #ifdef CONFIG_SCHED_SMT
9122 /*
9123 * When going down, decrement the number of cores with SMT present.
9124 */
9125 if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9126 static_branch_dec_cpuslocked(&sched_smt_present);
9127
9128 sched_core_cpu_deactivate(cpu);
9129 #endif
9130
9131 if (!sched_smp_initialized)
9132 return 0;
9133
9134 sched_reinit_numa(false, cpu);
9135 ret = cpuset_cpu_inactive(cpu);
9136 if (ret) {
9137 balance_push_set(cpu, false);
9138 set_cpu_active(cpu, true);
9139 return ret;
9140 }
9141 sched_domains_numa_masks_clear(cpu);
9142 return 0;
9143 }
9144
9145 static void sched_rq_cpu_starting(unsigned int cpu)
9146 {
9147 struct rq *rq = cpu_rq(cpu);
9148
9149 rq->calc_load_update = calc_load_update;
9150 update_max_interval();
9151 }
9152
9153 int sched_cpu_starting(unsigned int cpu)
9154 {
9155 sched_core_cpu_starting(cpu);
9156 sched_rq_cpu_starting(cpu);
9157 sched_tick_start(cpu);
9158 return 0;
9159 }
9160
9161 #ifdef CONFIG_HOTPLUG_CPU
9162
9163 /*
9164 * Invoked immediately before the stopper thread is invoked to bring the
9165 * CPU down completely. At this point all per CPU kthreads except the
9166 * hotplug thread (current) and the stopper thread (inactive) have been
9167 * either parked or have been unbound from the outgoing CPU. Ensure that
9168 * any of those which might be on the way out are gone.
9169 *
9170 * If after this point a bound task is being woken on this CPU then the
9171 * responsible hotplug callback has failed to do it's job.
9172 * sched_cpu_dying() will catch it with the appropriate fireworks.
9173 */
9174 int sched_cpu_wait_empty(unsigned int cpu)
9175 {
9176 balance_hotplug_wait();
9177 return 0;
9178 }
9179
9180 /*
9181 * Since this CPU is going 'away' for a while, fold any nr_active delta we
9182 * might have. Called from the CPU stopper task after ensuring that the
9183 * stopper is the last running task on the CPU, so nr_active count is
9184 * stable. We need to take the teardown thread which is calling this into
9185 * account, so we hand in adjust = 1 to the load calculation.
9186 *
9187 * Also see the comment "Global load-average calculations".
9188 */
9189 static void calc_load_migrate(struct rq *rq)
9190 {
9191 long delta = calc_load_fold_active(rq, 1);
9192
9193 if (delta)
9194 atomic_long_add(delta, &calc_load_tasks);
9195 }
9196
9197 static void dump_rq_tasks(struct rq *rq, const char *loglvl)
9198 {
9199 struct task_struct *g, *p;
9200 int cpu = cpu_of(rq);
9201
9202 lockdep_assert_rq_held(rq);
9203
9204 printk("%sCPU%d enqueued tasks (%u total):\n", loglvl, cpu, rq->nr_running);
9205 for_each_process_thread(g, p) {
9206 if (task_cpu(p) != cpu)
9207 continue;
9208
9209 if (!task_on_rq_queued(p))
9210 continue;
9211
9212 printk("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);
9213 }
9214 }
9215
9216 int sched_cpu_dying(unsigned int cpu)
9217 {
9218 struct rq *rq = cpu_rq(cpu);
9219 struct rq_flags rf;
9220
9221 /* Handle pending wakeups and then migrate everything off */
9222 sched_tick_stop(cpu);
9223
9224 rq_lock_irqsave(rq, &rf);
9225 if (rq->nr_running != 1 || rq_has_pinned_tasks(rq)) {
9226 WARN(true, "Dying CPU not properly vacated!");
9227 dump_rq_tasks(rq, KERN_WARNING);
9228 }
9229 rq_unlock_irqrestore(rq, &rf);
9230
9231 calc_load_migrate(rq);
9232 update_max_interval();
9233 hrtick_clear(rq);
9234 sched_core_cpu_dying(cpu);
9235 return 0;
9236 }
9237 #endif
9238
9239 void __init sched_init_smp(void)
9240 {
> 9241 sched_init_numa(NUMA_NO_NODE);
9242
9243 /*
9244 * There's no userspace yet to cause hotplug operations; hence all the
9245 * CPU masks are stable and all blatant races in the below code cannot
9246 * happen.
9247 */
9248 mutex_lock(&sched_domains_mutex);
9249 sched_init_domains(cpu_active_mask);
9250 mutex_unlock(&sched_domains_mutex);
9251
9252 /* Move init over to a non-isolated CPU */
9253 if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0)
9254 BUG();
9255 current->flags &= ~PF_NO_SETAFFINITY;
9256 sched_init_granularity();
9257
9258 init_sched_rt_class();
9259 init_sched_dl_class();
9260
9261 sched_smp_initialized = true;
9262 }
9263
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [RFC PATCH -V2] NUMA balancing: fix NUMA topology for systems with CPU-less nodes
@ 2022-02-08 17:23 ` kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-02-08 17:23 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 10982 bytes --]
Hi Huang,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on tip/sched/core]
[also build test ERROR on linux/master linus/master v5.17-rc3 next-20220208]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git c8eaf6ac76f40f6c59fc7d056e2e08c4a57ea9c7
config: hexagon-randconfig-r045-20220208 (https://download.01.org/0day-ci/archive/20220209/202202090152.0LoawqhI-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project e8bff9ae54a55b4dbfeb6ba55f723abbd81bf494)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ed82092e509333870d756fc8e53d816885922fc4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Huang-Ying/NUMA-balancing-fix-NUMA-topology-for-systems-with-CPU-less-nodes/20220208-212402
git checkout ed82092e509333870d756fc8e53d816885922fc4
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash kernel/sched/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
kernel/sched/core.c:3454:6: warning: no previous prototype for function 'sched_set_stop_task' [-Wmissing-prototypes]
void sched_set_stop_task(int cpu, struct task_struct *stop)
^
kernel/sched/core.c:3454:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void sched_set_stop_task(int cpu, struct task_struct *stop)
^
static
>> kernel/sched/core.c:9055:3: error: implicit declaration of function 'sched_reinit_numa' [-Werror,-Wimplicit-function-declaration]
sched_reinit_numa(true, cpu);
^
kernel/sched/core.c:9055:3: note: did you mean 'sched_init_numa'?
kernel/sched/sched.h:1671:20: note: 'sched_init_numa' declared here
static inline void sched_init_numa(void) { }
^
kernel/sched/core.c:9134:2: error: implicit declaration of function 'sched_reinit_numa' [-Werror,-Wimplicit-function-declaration]
sched_reinit_numa(false, cpu);
^
>> kernel/sched/core.c:9241:18: error: too many arguments to function call, expected 0, have 1
sched_init_numa(NUMA_NO_NODE);
~~~~~~~~~~~~~~~ ^~~~~~~~~~~~
include/linux/numa.h:14:22: note: expanded from macro 'NUMA_NO_NODE'
#define NUMA_NO_NODE (-1)
^~~~
kernel/sched/sched.h:1671:20: note: 'sched_init_numa' declared here
static inline void sched_init_numa(void) { }
^
1 warning and 3 errors generated.
vim +/sched_reinit_numa +9055 kernel/sched/core.c
9033
9034 int sched_cpu_activate(unsigned int cpu)
9035 {
9036 struct rq *rq = cpu_rq(cpu);
9037 struct rq_flags rf;
9038
9039 /*
9040 * Clear the balance_push callback and prepare to schedule
9041 * regular tasks.
9042 */
9043 balance_push_set(cpu, false);
9044
9045 #ifdef CONFIG_SCHED_SMT
9046 /*
9047 * When going up, increment the number of cores with SMT present.
9048 */
9049 if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9050 static_branch_inc_cpuslocked(&sched_smt_present);
9051 #endif
9052 set_cpu_active(cpu, true);
9053
9054 if (sched_smp_initialized) {
> 9055 sched_reinit_numa(true, cpu);
9056 sched_domains_numa_masks_set(cpu);
9057 cpuset_cpu_active();
9058 }
9059
9060 /*
9061 * Put the rq online, if not already. This happens:
9062 *
9063 * 1) In the early boot process, because we build the real domains
9064 * after all CPUs have been brought up.
9065 *
9066 * 2) At runtime, if cpuset_cpu_active() fails to rebuild the
9067 * domains.
9068 */
9069 rq_lock_irqsave(rq, &rf);
9070 if (rq->rd) {
9071 BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
9072 set_rq_online(rq);
9073 }
9074 rq_unlock_irqrestore(rq, &rf);
9075
9076 return 0;
9077 }
9078
9079 int sched_cpu_deactivate(unsigned int cpu)
9080 {
9081 struct rq *rq = cpu_rq(cpu);
9082 struct rq_flags rf;
9083 int ret;
9084
9085 /*
9086 * Remove CPU from nohz.idle_cpus_mask to prevent participating in
9087 * load balancing when not active
9088 */
9089 nohz_balance_exit_idle(rq);
9090
9091 set_cpu_active(cpu, false);
9092
9093 /*
9094 * From this point forward, this CPU will refuse to run any task that
9095 * is not: migrate_disable() or KTHREAD_IS_PER_CPU, and will actively
9096 * push those tasks away until this gets cleared, see
9097 * sched_cpu_dying().
9098 */
9099 balance_push_set(cpu, true);
9100
9101 /*
9102 * We've cleared cpu_active_mask / set balance_push, wait for all
9103 * preempt-disabled and RCU users of this state to go away such that
9104 * all new such users will observe it.
9105 *
9106 * Specifically, we rely on ttwu to no longer target this CPU, see
9107 * ttwu_queue_cond() and is_cpu_allowed().
9108 *
9109 * Do sync before park smpboot threads to take care the rcu boost case.
9110 */
9111 synchronize_rcu();
9112
9113 rq_lock_irqsave(rq, &rf);
9114 if (rq->rd) {
9115 update_rq_clock(rq);
9116 BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
9117 set_rq_offline(rq);
9118 }
9119 rq_unlock_irqrestore(rq, &rf);
9120
9121 #ifdef CONFIG_SCHED_SMT
9122 /*
9123 * When going down, decrement the number of cores with SMT present.
9124 */
9125 if (cpumask_weight(cpu_smt_mask(cpu)) == 2)
9126 static_branch_dec_cpuslocked(&sched_smt_present);
9127
9128 sched_core_cpu_deactivate(cpu);
9129 #endif
9130
9131 if (!sched_smp_initialized)
9132 return 0;
9133
9134 sched_reinit_numa(false, cpu);
9135 ret = cpuset_cpu_inactive(cpu);
9136 if (ret) {
9137 balance_push_set(cpu, false);
9138 set_cpu_active(cpu, true);
9139 return ret;
9140 }
9141 sched_domains_numa_masks_clear(cpu);
9142 return 0;
9143 }
9144
9145 static void sched_rq_cpu_starting(unsigned int cpu)
9146 {
9147 struct rq *rq = cpu_rq(cpu);
9148
9149 rq->calc_load_update = calc_load_update;
9150 update_max_interval();
9151 }
9152
9153 int sched_cpu_starting(unsigned int cpu)
9154 {
9155 sched_core_cpu_starting(cpu);
9156 sched_rq_cpu_starting(cpu);
9157 sched_tick_start(cpu);
9158 return 0;
9159 }
9160
9161 #ifdef CONFIG_HOTPLUG_CPU
9162
9163 /*
9164 * Invoked immediately before the stopper thread is invoked to bring the
9165 * CPU down completely. At this point all per CPU kthreads except the
9166 * hotplug thread (current) and the stopper thread (inactive) have been
9167 * either parked or have been unbound from the outgoing CPU. Ensure that
9168 * any of those which might be on the way out are gone.
9169 *
9170 * If after this point a bound task is being woken on this CPU then the
9171 * responsible hotplug callback has failed to do it's job.
9172 * sched_cpu_dying() will catch it with the appropriate fireworks.
9173 */
9174 int sched_cpu_wait_empty(unsigned int cpu)
9175 {
9176 balance_hotplug_wait();
9177 return 0;
9178 }
9179
9180 /*
9181 * Since this CPU is going 'away' for a while, fold any nr_active delta we
9182 * might have. Called from the CPU stopper task after ensuring that the
9183 * stopper is the last running task on the CPU, so nr_active count is
9184 * stable. We need to take the teardown thread which is calling this into
9185 * account, so we hand in adjust = 1 to the load calculation.
9186 *
9187 * Also see the comment "Global load-average calculations".
9188 */
9189 static void calc_load_migrate(struct rq *rq)
9190 {
9191 long delta = calc_load_fold_active(rq, 1);
9192
9193 if (delta)
9194 atomic_long_add(delta, &calc_load_tasks);
9195 }
9196
9197 static void dump_rq_tasks(struct rq *rq, const char *loglvl)
9198 {
9199 struct task_struct *g, *p;
9200 int cpu = cpu_of(rq);
9201
9202 lockdep_assert_rq_held(rq);
9203
9204 printk("%sCPU%d enqueued tasks (%u total):\n", loglvl, cpu, rq->nr_running);
9205 for_each_process_thread(g, p) {
9206 if (task_cpu(p) != cpu)
9207 continue;
9208
9209 if (!task_on_rq_queued(p))
9210 continue;
9211
9212 printk("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);
9213 }
9214 }
9215
9216 int sched_cpu_dying(unsigned int cpu)
9217 {
9218 struct rq *rq = cpu_rq(cpu);
9219 struct rq_flags rf;
9220
9221 /* Handle pending wakeups and then migrate everything off */
9222 sched_tick_stop(cpu);
9223
9224 rq_lock_irqsave(rq, &rf);
9225 if (rq->nr_running != 1 || rq_has_pinned_tasks(rq)) {
9226 WARN(true, "Dying CPU not properly vacated!");
9227 dump_rq_tasks(rq, KERN_WARNING);
9228 }
9229 rq_unlock_irqrestore(rq, &rf);
9230
9231 calc_load_migrate(rq);
9232 update_max_interval();
9233 hrtick_clear(rq);
9234 sched_core_cpu_dying(cpu);
9235 return 0;
9236 }
9237 #endif
9238
9239 void __init sched_init_smp(void)
9240 {
> 9241 sched_init_numa(NUMA_NO_NODE);
9242
9243 /*
9244 * There's no userspace yet to cause hotplug operations; hence all the
9245 * CPU masks are stable and all blatant races in the below code cannot
9246 * happen.
9247 */
9248 mutex_lock(&sched_domains_mutex);
9249 sched_init_domains(cpu_active_mask);
9250 mutex_unlock(&sched_domains_mutex);
9251
9252 /* Move init over to a non-isolated CPU */
9253 if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0)
9254 BUG();
9255 current->flags &= ~PF_NO_SETAFFINITY;
9256 sched_init_granularity();
9257
9258 init_sched_rt_class();
9259 init_sched_dl_class();
9260
9261 sched_smp_initialized = true;
9262 }
9263
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-02-10 7:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-08 20:36 [RFC PATCH -V2] NUMA balancing: fix NUMA topology for systems with CPU-less nodes kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-02-09 16:00 kernel test robot
2022-02-10 7:55 ` Dan Carpenter
2022-02-08 12:23 Huang Ying
2022-02-08 16:51 ` kernel test robot
2022-02-08 17:23 ` kernel test robot
2022-02-08 17:23 ` kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.