numa.c (5d88aa85c00bb4026dd986430dc496effc637d42) | numa.c (30c05350c39de6c17132cfee649518b842d89dd5) |
---|---|
1/* 2 * pSeries NUMA support 3 * 4 * Copyright (C) 2002 Anton Blanchard <anton@au.ibm.com>, IBM 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 8 unchanged lines hidden (view full) --- 17#include <linux/nodemask.h> 18#include <linux/cpu.h> 19#include <linux/notifier.h> 20#include <linux/memblock.h> 21#include <linux/of.h> 22#include <linux/pfn.h> 23#include <linux/cpuset.h> 24#include <linux/node.h> | 1/* 2 * pSeries NUMA support 3 * 4 * Copyright (C) 2002 Anton Blanchard <anton@au.ibm.com>, IBM 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 8 unchanged lines hidden (view full) --- 17#include <linux/nodemask.h> 18#include <linux/cpu.h> 19#include <linux/notifier.h> 20#include <linux/memblock.h> 21#include <linux/of.h> 22#include <linux/pfn.h> 23#include <linux/cpuset.h> 24#include <linux/node.h> |
25#include <linux/stop_machine.h> |
|
25#include <asm/sparsemem.h> 26#include <asm/prom.h> 27#include <asm/smp.h> 28#include <asm/firmware.h> 29#include <asm/paca.h> 30#include <asm/hvcall.h> 31#include <asm/setup.h> 32 --- 1216 unchanged lines hidden (view full) --- 1249u64 memory_hotplug_max(void) 1250{ 1251 return max(hot_add_drconf_memory_max(), memblock_end_of_DRAM()); 1252} 1253#endif /* CONFIG_MEMORY_HOTPLUG */ 1254 1255/* Virtual Processor Home Node (VPHN) support */ 1256#ifdef CONFIG_PPC_SPLPAR | 26#include <asm/sparsemem.h> 27#include <asm/prom.h> 28#include <asm/smp.h> 29#include <asm/firmware.h> 30#include <asm/paca.h> 31#include <asm/hvcall.h> 32#include <asm/setup.h> 33 --- 1216 unchanged lines hidden (view full) --- 1250u64 memory_hotplug_max(void) 1251{ 1252 return max(hot_add_drconf_memory_max(), memblock_end_of_DRAM()); 1253} 1254#endif /* CONFIG_MEMORY_HOTPLUG */ 1255 1256/* Virtual Processor Home Node (VPHN) support */ 1257#ifdef CONFIG_PPC_SPLPAR |
1258struct topology_update_data { 1259 struct topology_update_data *next; 1260 unsigned int cpu; 1261 int old_nid; 1262 int new_nid; 1263}; 1264 |
|
1257static u8 vphn_cpu_change_counts[NR_CPUS][MAX_DISTANCE_REF_POINTS]; 1258static cpumask_t cpu_associativity_changes_mask; 1259static int vphn_enabled; 1260static int prrn_enabled; 1261static void reset_topology_timer(void); 1262 1263/* 1264 * Store the current values of the associativity change counters in the --- 135 unchanged lines hidden (view full) --- 1400 "preventing VPHN. Disabling polling...\n"); 1401 stop_topology_update(); 1402 } 1403 1404 return rc; 1405} 1406 1407/* | 1265static u8 vphn_cpu_change_counts[NR_CPUS][MAX_DISTANCE_REF_POINTS]; 1266static cpumask_t cpu_associativity_changes_mask; 1267static int vphn_enabled; 1268static int prrn_enabled; 1269static void reset_topology_timer(void); 1270 1271/* 1272 * Store the current values of the associativity change counters in the --- 135 unchanged lines hidden (view full) --- 1408 "preventing VPHN. Disabling polling...\n"); 1409 stop_topology_update(); 1410 } 1411 1412 return rc; 1413} 1414 1415/* |
1416 * Update the CPU maps and sysfs entries for a single CPU when its NUMA 1417 * characteristics change. This function doesn't perform any locking and is 1418 * only safe to call from stop_machine(). 1419 */ 1420static int update_cpu_topology(void *data) 1421{ 1422 struct topology_update_data *update; 1423 unsigned long cpu; 1424 1425 if (!data) 1426 return -EINVAL; 1427 1428 cpu = get_cpu(); 1429 1430 for (update = data; update; update = update->next) { 1431 if (cpu != update->cpu) 1432 continue; 1433 1434 unregister_cpu_under_node(update->cpu, update->old_nid); 1435 unmap_cpu_from_node(update->cpu); 1436 map_cpu_to_node(update->cpu, update->new_nid); 1437 register_cpu_under_node(update->cpu, update->new_nid); 1438 } 1439 1440 return 0; 1441} 1442 1443/* |
|
1408 * Update the node maps and sysfs entries for each cpu whose home node 1409 * has changed. Returns 1 when the topology has changed, and 0 otherwise. 1410 */ 1411int arch_update_cpu_topology(void) 1412{ | 1444 * Update the node maps and sysfs entries for each cpu whose home node 1445 * has changed. Returns 1 when the topology has changed, and 0 otherwise. 1446 */ 1447int arch_update_cpu_topology(void) 1448{ |
1413 int cpu, nid, old_nid, changed = 0; | 1449 unsigned int cpu, changed = 0; 1450 struct topology_update_data *updates, *ud; |
1414 unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0}; 1415 struct device *dev; | 1451 unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0}; 1452 struct device *dev; |
1453 int weight, i = 0; |
|
1416 | 1454 |
1455 weight = cpumask_weight(&cpu_associativity_changes_mask); 1456 if (!weight) 1457 return 0; 1458 1459 updates = kzalloc(weight * (sizeof(*updates)), GFP_KERNEL); 1460 if (!updates) 1461 return 0; 1462 |
|
1417 for_each_cpu(cpu, &cpu_associativity_changes_mask) { | 1463 for_each_cpu(cpu, &cpu_associativity_changes_mask) { |
1464 ud = &updates[i++]; 1465 ud->cpu = cpu; |
|
1418 vphn_get_associativity(cpu, associativity); | 1466 vphn_get_associativity(cpu, associativity); |
1419 nid = associativity_to_nid(associativity); | 1467 ud->new_nid = associativity_to_nid(associativity); |
1420 | 1468 |
1421 if (nid < 0 || !node_online(nid)) 1422 nid = first_online_node; | 1469 if (ud->new_nid < 0 || !node_online(ud->new_nid)) 1470 ud->new_nid = first_online_node; |
1423 | 1471 |
1424 old_nid = numa_cpu_lookup_table[cpu]; | 1472 ud->old_nid = numa_cpu_lookup_table[cpu]; |
1425 | 1473 |
1426 /* Disable hotplug while we update the cpu 1427 * masks and sysfs. 1428 */ 1429 get_online_cpus(); 1430 unregister_cpu_under_node(cpu, old_nid); 1431 unmap_cpu_from_node(cpu); 1432 map_cpu_to_node(cpu, nid); 1433 register_cpu_under_node(cpu, nid); 1434 put_online_cpus(); | 1474 if (i < weight) 1475 ud->next = &updates[i]; 1476 } |
1435 | 1477 |
1436 dev = get_cpu_device(cpu); | 1478 stop_machine(update_cpu_topology, &updates[0], cpu_online_mask); 1479 1480 for (ud = &updates[0]; ud; ud = ud->next) { 1481 dev = get_cpu_device(ud->cpu); |
1437 if (dev) 1438 kobject_uevent(&dev->kobj, KOBJ_CHANGE); | 1482 if (dev) 1483 kobject_uevent(&dev->kobj, KOBJ_CHANGE); |
1439 cpumask_clear_cpu(cpu, &cpu_associativity_changes_mask); | 1484 cpumask_clear_cpu(ud->cpu, &cpu_associativity_changes_mask); |
1440 changed = 1; 1441 } 1442 | 1485 changed = 1; 1486 } 1487 |
1488 kfree(updates); |
|
1443 return changed; 1444} 1445 1446static void topology_work_fn(struct work_struct *work) 1447{ 1448 rebuild_sched_domains(); 1449} 1450static DECLARE_WORK(topology_work, topology_work_fn); --- 32 unchanged lines hidden (view full) --- 1483 1484static int dt_update_callback(struct notifier_block *nb, 1485 unsigned long action, void *data) 1486{ 1487 struct of_prop_reconfig *update; 1488 int rc = NOTIFY_DONE; 1489 1490 switch (action) { | 1489 return changed; 1490} 1491 1492static void topology_work_fn(struct work_struct *work) 1493{ 1494 rebuild_sched_domains(); 1495} 1496static DECLARE_WORK(topology_work, topology_work_fn); --- 32 unchanged lines hidden (view full) --- 1529 1530static int dt_update_callback(struct notifier_block *nb, 1531 unsigned long action, void *data) 1532{ 1533 struct of_prop_reconfig *update; 1534 int rc = NOTIFY_DONE; 1535 1536 switch (action) { |
1491 case OF_RECONFIG_ADD_PROPERTY: | |
1492 case OF_RECONFIG_UPDATE_PROPERTY: 1493 update = (struct of_prop_reconfig *)data; | 1537 case OF_RECONFIG_UPDATE_PROPERTY: 1538 update = (struct of_prop_reconfig *)data; |
1494 if (!of_prop_cmp(update->dn->type, "cpu")) { | 1539 if (!of_prop_cmp(update->dn->type, "cpu") && 1540 !of_prop_cmp(update->prop->name, "ibm,associativity")) { |
1495 u32 core_id; 1496 of_property_read_u32(update->dn, "reg", &core_id); 1497 stage_topology_update(core_id); 1498 rc = NOTIFY_OK; 1499 } 1500 break; 1501 } 1502 --- 54 unchanged lines hidden --- | 1541 u32 core_id; 1542 of_property_read_u32(update->dn, "reg", &core_id); 1543 stage_topology_update(core_id); 1544 rc = NOTIFY_OK; 1545 } 1546 break; 1547 } 1548 --- 54 unchanged lines hidden --- |