numa.c (544af6429777cefae2f8af9a9866df5e8cb21763) numa.c (506c2075ffd8db352c53201ef166948a272e3bce)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * pSeries NUMA support
4 *
5 * Copyright (C) 2002 Anton Blanchard <anton@au.ibm.com>, IBM
6 */
7#define pr_fmt(fmt) "numa: " fmt
8

--- 148 unchanged lines hidden (view full) ---

157{
158 int node = numa_cpu_lookup_table[cpu];
159
160 pr_debug("removing cpu %lu from node %d\n", cpu, node);
161
162 if (cpumask_test_cpu(cpu, node_to_cpumask_map[node])) {
163 cpumask_clear_cpu(cpu, node_to_cpumask_map[node]);
164 } else {
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * pSeries NUMA support
4 *
5 * Copyright (C) 2002 Anton Blanchard <anton@au.ibm.com>, IBM
6 */
7#define pr_fmt(fmt) "numa: " fmt
8

--- 148 unchanged lines hidden (view full) ---

157{
158 int node = numa_cpu_lookup_table[cpu];
159
160 pr_debug("removing cpu %lu from node %d\n", cpu, node);
161
162 if (cpumask_test_cpu(cpu, node_to_cpumask_map[node])) {
163 cpumask_clear_cpu(cpu, node_to_cpumask_map[node]);
164 } else {
165 printk(KERN_ERR "WARNING: cpu %lu not found in node %d\n",
166 cpu, node);
165 pr_warn("Warning: cpu %lu not found in node %d\n", cpu, node);
167 }
168}
169#endif /* CONFIG_HOTPLUG_CPU || CONFIG_PPC_SPLPAR */
170
171static int __associativity_to_nid(const __be32 *associativity,
172 int max_array_sz)
173{
174 int nid;

--- 299 unchanged lines hidden (view full) ---

474 * NUMA boundary and the following are progressively less significant
475 * boundaries. There can be more than one level of NUMA.
476 */
477 distance_ref_points = of_get_property(root,
478 "ibm,associativity-reference-points",
479 &distance_ref_points_depth);
480
481 if (!distance_ref_points) {
166 }
167}
168#endif /* CONFIG_HOTPLUG_CPU || CONFIG_PPC_SPLPAR */
169
170static int __associativity_to_nid(const __be32 *associativity,
171 int max_array_sz)
172{
173 int nid;

--- 299 unchanged lines hidden (view full) ---

473 * NUMA boundary and the following are progressively less significant
474 * boundaries. There can be more than one level of NUMA.
475 */
476 distance_ref_points = of_get_property(root,
477 "ibm,associativity-reference-points",
478 &distance_ref_points_depth);
479
480 if (!distance_ref_points) {
482 pr_debug("NUMA: ibm,associativity-reference-points not found.\n");
481 pr_debug("ibm,associativity-reference-points not found.\n");
483 goto err;
484 }
485
486 distance_ref_points_depth /= sizeof(int);
487 if (affinity_form == FORM0_AFFINITY) {
488 if (distance_ref_points_depth < 2) {
482 goto err;
483 }
484
485 distance_ref_points_depth /= sizeof(int);
486 if (affinity_form == FORM0_AFFINITY) {
487 if (distance_ref_points_depth < 2) {
489 printk(KERN_WARNING "NUMA: "
490 "short ibm,associativity-reference-points\n");
488 pr_warn("short ibm,associativity-reference-points\n");
491 goto err;
492 }
493
494 index = of_read_number(&distance_ref_points[1], 1);
495 } else {
496 /*
497 * Both FORM1 and FORM2 affinity find the primary domain details
498 * at the same offset.
499 */
500 index = of_read_number(distance_ref_points, 1);
501 }
502 /*
503 * Warn and cap if the hardware supports more than
504 * MAX_DISTANCE_REF_POINTS domains.
505 */
506 if (distance_ref_points_depth > MAX_DISTANCE_REF_POINTS) {
489 goto err;
490 }
491
492 index = of_read_number(&distance_ref_points[1], 1);
493 } else {
494 /*
495 * Both FORM1 and FORM2 affinity find the primary domain details
496 * at the same offset.
497 */
498 index = of_read_number(distance_ref_points, 1);
499 }
500 /*
501 * Warn and cap if the hardware supports more than
502 * MAX_DISTANCE_REF_POINTS domains.
503 */
504 if (distance_ref_points_depth > MAX_DISTANCE_REF_POINTS) {
507 printk(KERN_WARNING "NUMA: distance array capped at "
508 "%d entries\n", MAX_DISTANCE_REF_POINTS);
505 pr_warn("distance array capped at %d entries\n",
506 MAX_DISTANCE_REF_POINTS);
509 distance_ref_points_depth = MAX_DISTANCE_REF_POINTS;
510 }
511
512 of_node_put(root);
513 return index;
514
515err:
516 of_node_put(root);

--- 388 unchanged lines hidden (view full) ---

905static int __init parse_numa_properties(void)
906{
907 struct device_node *memory;
908 int default_nid = 0;
909 unsigned long i;
910 const __be32 *associativity;
911
912 if (numa_enabled == 0) {
507 distance_ref_points_depth = MAX_DISTANCE_REF_POINTS;
508 }
509
510 of_node_put(root);
511 return index;
512
513err:
514 of_node_put(root);

--- 388 unchanged lines hidden (view full) ---

903static int __init parse_numa_properties(void)
904{
905 struct device_node *memory;
906 int default_nid = 0;
907 unsigned long i;
908 const __be32 *associativity;
909
910 if (numa_enabled == 0) {
913 printk(KERN_WARNING "NUMA disabled by user\n");
911 pr_warn("disabled by user\n");
914 return -1;
915 }
916
917 primary_domain_index = find_primary_domain_index();
918
919 if (primary_domain_index < 0) {
920 /*
921 * if we fail to parse primary_domain_index from device tree
922 * mark the numa disabled, boot with numa disabled.
923 */
924 numa_enabled = false;
925 return primary_domain_index;
926 }
927
912 return -1;
913 }
914
915 primary_domain_index = find_primary_domain_index();
916
917 if (primary_domain_index < 0) {
918 /*
919 * if we fail to parse primary_domain_index from device tree
920 * mark the numa disabled, boot with numa disabled.
921 */
922 numa_enabled = false;
923 return primary_domain_index;
924 }
925
928 pr_debug("NUMA associativity depth for CPU/Memory: %d\n", primary_domain_index);
926 pr_debug("associativity depth for CPU/Memory: %d\n", primary_domain_index);
929
930 /*
931 * If it is FORM2 initialize the distance table here.
932 */
933 if (affinity_form == FORM2_AFFINITY)
934 initialize_form2_numa_distance_lookup_table();
935
936 /*

--- 96 unchanged lines hidden (view full) ---

1033static void __init setup_nonnuma(void)
1034{
1035 unsigned long top_of_ram = memblock_end_of_DRAM();
1036 unsigned long total_ram = memblock_phys_mem_size();
1037 unsigned long start_pfn, end_pfn;
1038 unsigned int nid = 0;
1039 int i;
1040
927
928 /*
929 * If it is FORM2 initialize the distance table here.
930 */
931 if (affinity_form == FORM2_AFFINITY)
932 initialize_form2_numa_distance_lookup_table();
933
934 /*

--- 96 unchanged lines hidden (view full) ---

1031static void __init setup_nonnuma(void)
1032{
1033 unsigned long top_of_ram = memblock_end_of_DRAM();
1034 unsigned long total_ram = memblock_phys_mem_size();
1035 unsigned long start_pfn, end_pfn;
1036 unsigned int nid = 0;
1037 int i;
1038
1041 printk(KERN_DEBUG "Top of RAM: 0x%lx, Total RAM: 0x%lx\n",
1042 top_of_ram, total_ram);
1043 printk(KERN_DEBUG "Memory hole size: %ldMB\n",
1044 (top_of_ram - total_ram) >> 20);
1039 pr_debug("Top of RAM: 0x%lx, Total RAM: 0x%lx\n", top_of_ram, total_ram);
1040 pr_debug("Memory hole size: %ldMB\n", (top_of_ram - total_ram) >> 20);
1045
1046 for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) {
1047 fake_numa_create_new_node(end_pfn, &nid);
1048 memblock_set_node(PFN_PHYS(start_pfn),
1049 PFN_PHYS(end_pfn - start_pfn),
1050 &memblock.memory, nid);
1051 node_set_online(nid);
1052 }

--- 454 unchanged lines hidden ---
1041
1042 for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, NULL) {
1043 fake_numa_create_new_node(end_pfn, &nid);
1044 memblock_set_node(PFN_PHYS(start_pfn),
1045 PFN_PHYS(end_pfn - start_pfn),
1046 &memblock.memory, nid);
1047 node_set_online(nid);
1048 }

--- 454 unchanged lines hidden ---