numa.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/threads.h>
  12. #include <linux/bootmem.h>
  13. #include <linux/init.h>
  14. #include <linux/mm.h>
  15. #include <linux/mmzone.h>
  16. #include <linux/module.h>
  17. #include <linux/nodemask.h>
  18. #include <linux/cpu.h>
  19. #include <linux/notifier.h>
  20. #include <asm/sparsemem.h>
  21. #include <asm/lmb.h>
  22. #include <asm/system.h>
  23. #include <asm/smp.h>
  24. static int numa_enabled = 1;
  25. static int numa_debug;
  26. #define dbg(args...) if (numa_debug) { printk(KERN_INFO args); }
  27. int numa_cpu_lookup_table[NR_CPUS];
  28. cpumask_t numa_cpumask_lookup_table[MAX_NUMNODES];
  29. struct pglist_data *node_data[MAX_NUMNODES];
  30. EXPORT_SYMBOL(numa_cpu_lookup_table);
  31. EXPORT_SYMBOL(numa_cpumask_lookup_table);
  32. EXPORT_SYMBOL(node_data);
  33. static bootmem_data_t __initdata plat_node_bdata[MAX_NUMNODES];
  34. static int min_common_depth;
  35. /*
  36. * We need somewhere to store start/end/node for each region until we have
  37. * allocated the real node_data structures.
  38. */
  39. #define MAX_REGIONS (MAX_LMB_REGIONS*2)
  40. static struct {
  41. unsigned long start_pfn;
  42. unsigned long end_pfn;
  43. int nid;
  44. } init_node_data[MAX_REGIONS] __initdata;
  45. int __init early_pfn_to_nid(unsigned long pfn)
  46. {
  47. unsigned int i;
  48. for (i = 0; init_node_data[i].end_pfn; i++) {
  49. unsigned long start_pfn = init_node_data[i].start_pfn;
  50. unsigned long end_pfn = init_node_data[i].end_pfn;
  51. if ((start_pfn <= pfn) && (pfn < end_pfn))
  52. return init_node_data[i].nid;
  53. }
  54. return -1;
  55. }
  56. void __init add_region(unsigned int nid, unsigned long start_pfn,
  57. unsigned long pages)
  58. {
  59. unsigned int i;
  60. dbg("add_region nid %d start_pfn 0x%lx pages 0x%lx\n",
  61. nid, start_pfn, pages);
  62. for (i = 0; init_node_data[i].end_pfn; i++) {
  63. if (init_node_data[i].nid != nid)
  64. continue;
  65. if (init_node_data[i].end_pfn == start_pfn) {
  66. init_node_data[i].end_pfn += pages;
  67. return;
  68. }
  69. if (init_node_data[i].start_pfn == (start_pfn + pages)) {
  70. init_node_data[i].start_pfn -= pages;
  71. return;
  72. }
  73. }
  74. /*
  75. * Leave last entry NULL so we dont iterate off the end (we use
  76. * entry.end_pfn to terminate the walk).
  77. */
  78. if (i >= (MAX_REGIONS - 1)) {
  79. printk(KERN_ERR "WARNING: too many memory regions in "
  80. "numa code, truncating\n");
  81. return;
  82. }
  83. init_node_data[i].start_pfn = start_pfn;
  84. init_node_data[i].end_pfn = start_pfn + pages;
  85. init_node_data[i].nid = nid;
  86. }
  87. /* We assume init_node_data has no overlapping regions */
  88. void __init get_region(unsigned int nid, unsigned long *start_pfn,
  89. unsigned long *end_pfn, unsigned long *pages_present)
  90. {
  91. unsigned int i;
  92. *start_pfn = -1UL;
  93. *end_pfn = *pages_present = 0;
  94. for (i = 0; init_node_data[i].end_pfn; i++) {
  95. if (init_node_data[i].nid != nid)
  96. continue;
  97. *pages_present += init_node_data[i].end_pfn -
  98. init_node_data[i].start_pfn;
  99. if (init_node_data[i].start_pfn < *start_pfn)
  100. *start_pfn = init_node_data[i].start_pfn;
  101. if (init_node_data[i].end_pfn > *end_pfn)
  102. *end_pfn = init_node_data[i].end_pfn;
  103. }
  104. /* We didnt find a matching region, return start/end as 0 */
  105. if (*start_pfn == -1UL)
  106. *start_pfn = 0;
  107. }
  108. static inline void map_cpu_to_node(int cpu, int node)
  109. {
  110. numa_cpu_lookup_table[cpu] = node;
  111. if (!(cpu_isset(cpu, numa_cpumask_lookup_table[node])))
  112. cpu_set(cpu, numa_cpumask_lookup_table[node]);
  113. }
  114. #ifdef CONFIG_HOTPLUG_CPU
  115. static void unmap_cpu_from_node(unsigned long cpu)
  116. {
  117. int node = numa_cpu_lookup_table[cpu];
  118. dbg("removing cpu %lu from node %d\n", cpu, node);
  119. if (cpu_isset(cpu, numa_cpumask_lookup_table[node])) {
  120. cpu_clear(cpu, numa_cpumask_lookup_table[node]);
  121. } else {
  122. printk(KERN_ERR "WARNING: cpu %lu not found in node %d\n",
  123. cpu, node);
  124. }
  125. }
  126. #endif /* CONFIG_HOTPLUG_CPU */
  127. static struct device_node *find_cpu_node(unsigned int cpu)
  128. {
  129. unsigned int hw_cpuid = get_hard_smp_processor_id(cpu);
  130. struct device_node *cpu_node = NULL;
  131. unsigned int *interrupt_server, *reg;
  132. int len;
  133. while ((cpu_node = of_find_node_by_type(cpu_node, "cpu")) != NULL) {
  134. /* Try interrupt server first */
  135. interrupt_server = (unsigned int *)get_property(cpu_node,
  136. "ibm,ppc-interrupt-server#s", &len);
  137. len = len / sizeof(u32);
  138. if (interrupt_server && (len > 0)) {
  139. while (len--) {
  140. if (interrupt_server[len] == hw_cpuid)
  141. return cpu_node;
  142. }
  143. } else {
  144. reg = (unsigned int *)get_property(cpu_node,
  145. "reg", &len);
  146. if (reg && (len > 0) && (reg[0] == hw_cpuid))
  147. return cpu_node;
  148. }
  149. }
  150. return NULL;
  151. }
  152. /* must hold reference to node during call */
  153. static int *of_get_associativity(struct device_node *dev)
  154. {
  155. return (unsigned int *)get_property(dev, "ibm,associativity", NULL);
  156. }
  157. static int of_node_numa_domain(struct device_node *device)
  158. {
  159. int numa_domain;
  160. unsigned int *tmp;
  161. if (min_common_depth == -1)
  162. return 0;
  163. tmp = of_get_associativity(device);
  164. if (tmp && (tmp[0] >= min_common_depth)) {
  165. numa_domain = tmp[min_common_depth];
  166. } else {
  167. dbg("WARNING: no NUMA information for %s\n",
  168. device->full_name);
  169. numa_domain = 0;
  170. }
  171. return numa_domain;
  172. }
  173. /*
  174. * In theory, the "ibm,associativity" property may contain multiple
  175. * associativity lists because a resource may be multiply connected
  176. * into the machine. This resource then has different associativity
  177. * characteristics relative to its multiple connections. We ignore
  178. * this for now. We also assume that all cpu and memory sets have
  179. * their distances represented at a common level. This won't be
  180. * true for heirarchical NUMA.
  181. *
  182. * In any case the ibm,associativity-reference-points should give
  183. * the correct depth for a normal NUMA system.
  184. *
  185. * - Dave Hansen <haveblue@us.ibm.com>
  186. */
  187. static int __init find_min_common_depth(void)
  188. {
  189. int depth;
  190. unsigned int *ref_points;
  191. struct device_node *rtas_root;
  192. unsigned int len;
  193. rtas_root = of_find_node_by_path("/rtas");
  194. if (!rtas_root)
  195. return -1;
  196. /*
  197. * this property is 2 32-bit integers, each representing a level of
  198. * depth in the associativity nodes. The first is for an SMP
  199. * configuration (should be all 0's) and the second is for a normal
  200. * NUMA configuration.
  201. */
  202. ref_points = (unsigned int *)get_property(rtas_root,
  203. "ibm,associativity-reference-points", &len);
  204. if ((len >= 1) && ref_points) {
  205. depth = ref_points[1];
  206. } else {
  207. dbg("WARNING: could not find NUMA "
  208. "associativity reference point\n");
  209. depth = -1;
  210. }
  211. of_node_put(rtas_root);
  212. return depth;
  213. }
  214. static int __init get_mem_addr_cells(void)
  215. {
  216. struct device_node *memory = NULL;
  217. int rc;
  218. memory = of_find_node_by_type(memory, "memory");
  219. if (!memory)
  220. return 0; /* it won't matter */
  221. rc = prom_n_addr_cells(memory);
  222. return rc;
  223. }
  224. static int __init get_mem_size_cells(void)
  225. {
  226. struct device_node *memory = NULL;
  227. int rc;
  228. memory = of_find_node_by_type(memory, "memory");
  229. if (!memory)
  230. return 0; /* it won't matter */
  231. rc = prom_n_size_cells(memory);
  232. return rc;
  233. }
  234. static unsigned long __init read_n_cells(int n, unsigned int **buf)
  235. {
  236. unsigned long result = 0;
  237. while (n--) {
  238. result = (result << 32) | **buf;
  239. (*buf)++;
  240. }
  241. return result;
  242. }
  243. /*
  244. * Figure out to which domain a cpu belongs and stick it there.
  245. * Return the id of the domain used.
  246. */
  247. static int numa_setup_cpu(unsigned long lcpu)
  248. {
  249. int numa_domain = 0;
  250. struct device_node *cpu = find_cpu_node(lcpu);
  251. if (!cpu) {
  252. WARN_ON(1);
  253. goto out;
  254. }
  255. numa_domain = of_node_numa_domain(cpu);
  256. if (numa_domain >= num_online_nodes()) {
  257. /*
  258. * POWER4 LPAR uses 0xffff as invalid node,
  259. * dont warn in this case.
  260. */
  261. if (numa_domain != 0xffff)
  262. printk(KERN_ERR "WARNING: cpu %ld "
  263. "maps to invalid NUMA node %d\n",
  264. lcpu, numa_domain);
  265. numa_domain = 0;
  266. }
  267. out:
  268. node_set_online(numa_domain);
  269. map_cpu_to_node(lcpu, numa_domain);
  270. of_node_put(cpu);
  271. return numa_domain;
  272. }
  273. static int cpu_numa_callback(struct notifier_block *nfb,
  274. unsigned long action,
  275. void *hcpu)
  276. {
  277. unsigned long lcpu = (unsigned long)hcpu;
  278. int ret = NOTIFY_DONE;
  279. switch (action) {
  280. case CPU_UP_PREPARE:
  281. if (min_common_depth == -1 || !numa_enabled)
  282. map_cpu_to_node(lcpu, 0);
  283. else
  284. numa_setup_cpu(lcpu);
  285. ret = NOTIFY_OK;
  286. break;
  287. #ifdef CONFIG_HOTPLUG_CPU
  288. case CPU_DEAD:
  289. case CPU_UP_CANCELED:
  290. unmap_cpu_from_node(lcpu);
  291. break;
  292. ret = NOTIFY_OK;
  293. #endif
  294. }
  295. return ret;
  296. }
  297. /*
  298. * Check and possibly modify a memory region to enforce the memory limit.
  299. *
  300. * Returns the size the region should have to enforce the memory limit.
  301. * This will either be the original value of size, a truncated value,
  302. * or zero. If the returned value of size is 0 the region should be
  303. * discarded as it lies wholy above the memory limit.
  304. */
  305. static unsigned long __init numa_enforce_memory_limit(unsigned long start,
  306. unsigned long size)
  307. {
  308. /*
  309. * We use lmb_end_of_DRAM() in here instead of memory_limit because
  310. * we've already adjusted it for the limit and it takes care of
  311. * having memory holes below the limit.
  312. */
  313. if (! memory_limit)
  314. return size;
  315. if (start + size <= lmb_end_of_DRAM())
  316. return size;
  317. if (start >= lmb_end_of_DRAM())
  318. return 0;
  319. return lmb_end_of_DRAM() - start;
  320. }
  321. static int __init parse_numa_properties(void)
  322. {
  323. struct device_node *cpu = NULL;
  324. struct device_node *memory = NULL;
  325. int addr_cells, size_cells;
  326. int max_domain;
  327. unsigned long i;
  328. if (numa_enabled == 0) {
  329. printk(KERN_WARNING "NUMA disabled by user\n");
  330. return -1;
  331. }
  332. min_common_depth = find_min_common_depth();
  333. dbg("NUMA associativity depth for CPU/Memory: %d\n", min_common_depth);
  334. if (min_common_depth < 0)
  335. return min_common_depth;
  336. max_domain = numa_setup_cpu(boot_cpuid);
  337. /*
  338. * Even though we connect cpus to numa domains later in SMP init,
  339. * we need to know the maximum node id now. This is because each
  340. * node id must have NODE_DATA etc backing it.
  341. * As a result of hotplug we could still have cpus appear later on
  342. * with larger node ids. In that case we force the cpu into node 0.
  343. */
  344. for_each_cpu(i) {
  345. int numa_domain;
  346. cpu = find_cpu_node(i);
  347. if (cpu) {
  348. numa_domain = of_node_numa_domain(cpu);
  349. of_node_put(cpu);
  350. if (numa_domain < MAX_NUMNODES &&
  351. max_domain < numa_domain)
  352. max_domain = numa_domain;
  353. }
  354. }
  355. addr_cells = get_mem_addr_cells();
  356. size_cells = get_mem_size_cells();
  357. memory = NULL;
  358. while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
  359. unsigned long start;
  360. unsigned long size;
  361. int numa_domain;
  362. int ranges;
  363. unsigned int *memcell_buf;
  364. unsigned int len;
  365. memcell_buf = (unsigned int *)get_property(memory, "reg", &len);
  366. if (!memcell_buf || len <= 0)
  367. continue;
  368. ranges = memory->n_addrs;
  369. new_range:
  370. /* these are order-sensitive, and modify the buffer pointer */
  371. start = read_n_cells(addr_cells, &memcell_buf);
  372. size = read_n_cells(size_cells, &memcell_buf);
  373. numa_domain = of_node_numa_domain(memory);
  374. if (numa_domain >= MAX_NUMNODES) {
  375. if (numa_domain != 0xffff)
  376. printk(KERN_ERR "WARNING: memory at %lx maps "
  377. "to invalid NUMA node %d\n", start,
  378. numa_domain);
  379. numa_domain = 0;
  380. }
  381. if (max_domain < numa_domain)
  382. max_domain = numa_domain;
  383. if (!(size = numa_enforce_memory_limit(start, size))) {
  384. if (--ranges)
  385. goto new_range;
  386. else
  387. continue;
  388. }
  389. add_region(numa_domain, start >> PAGE_SHIFT,
  390. size >> PAGE_SHIFT);
  391. if (--ranges)
  392. goto new_range;
  393. }
  394. for (i = 0; i <= max_domain; i++)
  395. node_set_online(i);
  396. return 0;
  397. }
  398. static void __init setup_nonnuma(void)
  399. {
  400. unsigned long top_of_ram = lmb_end_of_DRAM();
  401. unsigned long total_ram = lmb_phys_mem_size();
  402. unsigned int i;
  403. printk(KERN_INFO "Top of RAM: 0x%lx, Total RAM: 0x%lx\n",
  404. top_of_ram, total_ram);
  405. printk(KERN_INFO "Memory hole size: %ldMB\n",
  406. (top_of_ram - total_ram) >> 20);
  407. map_cpu_to_node(boot_cpuid, 0);
  408. for (i = 0; i < lmb.memory.cnt; ++i)
  409. add_region(0, lmb.memory.region[i].base >> PAGE_SHIFT,
  410. lmb_size_pages(&lmb.memory, i));
  411. node_set_online(0);
  412. }
  413. static void __init dump_numa_topology(void)
  414. {
  415. unsigned int node;
  416. unsigned int count;
  417. if (min_common_depth == -1 || !numa_enabled)
  418. return;
  419. for_each_online_node(node) {
  420. unsigned long i;
  421. printk(KERN_INFO "Node %d Memory:", node);
  422. count = 0;
  423. for (i = 0; i < lmb_end_of_DRAM();
  424. i += (1 << SECTION_SIZE_BITS)) {
  425. if (early_pfn_to_nid(i >> PAGE_SHIFT) == node) {
  426. if (count == 0)
  427. printk(" 0x%lx", i);
  428. ++count;
  429. } else {
  430. if (count > 0)
  431. printk("-0x%lx", i);
  432. count = 0;
  433. }
  434. }
  435. if (count > 0)
  436. printk("-0x%lx", i);
  437. printk("\n");
  438. }
  439. return;
  440. }
  441. /*
  442. * Allocate some memory, satisfying the lmb or bootmem allocator where
  443. * required. nid is the preferred node and end is the physical address of
  444. * the highest address in the node.
  445. *
  446. * Returns the physical address of the memory.
  447. */
  448. static void __init *careful_allocation(int nid, unsigned long size,
  449. unsigned long align,
  450. unsigned long end_pfn)
  451. {
  452. int new_nid;
  453. unsigned long ret = lmb_alloc_base(size, align, end_pfn << PAGE_SHIFT);
  454. /* retry over all memory */
  455. if (!ret)
  456. ret = lmb_alloc_base(size, align, lmb_end_of_DRAM());
  457. if (!ret)
  458. panic("numa.c: cannot allocate %lu bytes on node %d",
  459. size, nid);
  460. /*
  461. * If the memory came from a previously allocated node, we must
  462. * retry with the bootmem allocator.
  463. */
  464. new_nid = early_pfn_to_nid(ret >> PAGE_SHIFT);
  465. if (new_nid < nid) {
  466. ret = (unsigned long)__alloc_bootmem_node(NODE_DATA(new_nid),
  467. size, align, 0);
  468. if (!ret)
  469. panic("numa.c: cannot allocate %lu bytes on node %d",
  470. size, new_nid);
  471. ret = __pa(ret);
  472. dbg("alloc_bootmem %lx %lx\n", ret, size);
  473. }
  474. return (void *)ret;
  475. }
  476. void __init do_init_bootmem(void)
  477. {
  478. int nid;
  479. unsigned int i;
  480. static struct notifier_block ppc64_numa_nb = {
  481. .notifier_call = cpu_numa_callback,
  482. .priority = 1 /* Must run before sched domains notifier. */
  483. };
  484. min_low_pfn = 0;
  485. max_low_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT;
  486. max_pfn = max_low_pfn;
  487. if (parse_numa_properties())
  488. setup_nonnuma();
  489. else
  490. dump_numa_topology();
  491. register_cpu_notifier(&ppc64_numa_nb);
  492. for_each_online_node(nid) {
  493. unsigned long start_pfn, end_pfn, pages_present;
  494. unsigned long bootmem_paddr;
  495. unsigned long bootmap_pages;
  496. get_region(nid, &start_pfn, &end_pfn, &pages_present);
  497. /* Allocate the node structure node local if possible */
  498. NODE_DATA(nid) = careful_allocation(nid,
  499. sizeof(struct pglist_data),
  500. SMP_CACHE_BYTES, end_pfn);
  501. NODE_DATA(nid) = __va(NODE_DATA(nid));
  502. memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
  503. dbg("node %d\n", nid);
  504. dbg("NODE_DATA() = %p\n", NODE_DATA(nid));
  505. NODE_DATA(nid)->bdata = &plat_node_bdata[nid];
  506. NODE_DATA(nid)->node_start_pfn = start_pfn;
  507. NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn;
  508. if (NODE_DATA(nid)->node_spanned_pages == 0)
  509. continue;
  510. dbg("start_paddr = %lx\n", start_pfn << PAGE_SHIFT);
  511. dbg("end_paddr = %lx\n", end_pfn << PAGE_SHIFT);
  512. bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
  513. bootmem_paddr = (unsigned long)careful_allocation(nid,
  514. bootmap_pages << PAGE_SHIFT,
  515. PAGE_SIZE, end_pfn);
  516. memset(__va(bootmem_paddr), 0, bootmap_pages << PAGE_SHIFT);
  517. dbg("bootmap_paddr = %lx\n", bootmem_paddr);
  518. init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT,
  519. start_pfn, end_pfn);
  520. /* Add free regions on this node */
  521. for (i = 0; init_node_data[i].end_pfn; i++) {
  522. unsigned long start, end;
  523. if (init_node_data[i].nid != nid)
  524. continue;
  525. start = init_node_data[i].start_pfn << PAGE_SHIFT;
  526. end = init_node_data[i].end_pfn << PAGE_SHIFT;
  527. dbg("free_bootmem %lx %lx\n", start, end - start);
  528. free_bootmem_node(NODE_DATA(nid), start, end - start);
  529. }
  530. /* Mark reserved regions on this node */
  531. for (i = 0; i < lmb.reserved.cnt; i++) {
  532. unsigned long physbase = lmb.reserved.region[i].base;
  533. unsigned long size = lmb.reserved.region[i].size;
  534. unsigned long start_paddr = start_pfn << PAGE_SHIFT;
  535. unsigned long end_paddr = end_pfn << PAGE_SHIFT;
  536. if (early_pfn_to_nid(physbase >> PAGE_SHIFT) != nid &&
  537. early_pfn_to_nid((physbase+size-1) >> PAGE_SHIFT) != nid)
  538. continue;
  539. if (physbase < end_paddr &&
  540. (physbase+size) > start_paddr) {
  541. /* overlaps */
  542. if (physbase < start_paddr) {
  543. size -= start_paddr - physbase;
  544. physbase = start_paddr;
  545. }
  546. if (size > end_paddr - physbase)
  547. size = end_paddr - physbase;
  548. dbg("reserve_bootmem %lx %lx\n", physbase,
  549. size);
  550. reserve_bootmem_node(NODE_DATA(nid), physbase,
  551. size);
  552. }
  553. }
  554. /* Add regions into sparsemem */
  555. for (i = 0; init_node_data[i].end_pfn; i++) {
  556. unsigned long start, end;
  557. if (init_node_data[i].nid != nid)
  558. continue;
  559. start = init_node_data[i].start_pfn;
  560. end = init_node_data[i].end_pfn;
  561. memory_present(nid, start, end);
  562. }
  563. }
  564. }
  565. void __init paging_init(void)
  566. {
  567. unsigned long zones_size[MAX_NR_ZONES];
  568. unsigned long zholes_size[MAX_NR_ZONES];
  569. int nid;
  570. memset(zones_size, 0, sizeof(zones_size));
  571. memset(zholes_size, 0, sizeof(zholes_size));
  572. for_each_online_node(nid) {
  573. unsigned long start_pfn, end_pfn, pages_present;
  574. get_region(nid, &start_pfn, &end_pfn, &pages_present);
  575. zones_size[ZONE_DMA] = end_pfn - start_pfn;
  576. zholes_size[ZONE_DMA] = zones_size[ZONE_DMA] - pages_present;
  577. dbg("free_area_init node %d %lx %lx (hole: %lx)\n", nid,
  578. zones_size[ZONE_DMA], start_pfn, zholes_size[ZONE_DMA]);
  579. free_area_init_node(nid, NODE_DATA(nid), zones_size, start_pfn,
  580. zholes_size);
  581. }
  582. }
  583. static int __init early_numa(char *p)
  584. {
  585. if (!p)
  586. return 0;
  587. if (strstr(p, "off"))
  588. numa_enabled = 0;
  589. if (strstr(p, "debug"))
  590. numa_debug = 1;
  591. return 0;
  592. }
  593. early_param("numa", early_numa);