numa.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * This file contains NUMA specific variables and functions which can
  7. * be split away from DISCONTIGMEM and are used on NUMA machines with
  8. * contiguous memory.
  9. *
  10. * 2002/08/07 Erich Focht <efocht@ess.nec.de>
  11. */
  12. #include <linux/config.h>
  13. #include <linux/cpu.h>
  14. #include <linux/kernel.h>
  15. #include <linux/mm.h>
  16. #include <linux/node.h>
  17. #include <linux/init.h>
  18. #include <linux/bootmem.h>
  19. #include <asm/mmzone.h>
  20. #include <asm/numa.h>
  21. /*
  22. * The following structures are usually initialized by ACPI or
  23. * similar mechanisms and describe the NUMA characteristics of the machine.
  24. */
  25. int num_node_memblks;
  26. struct node_memblk_s node_memblk[NR_NODE_MEMBLKS];
  27. struct node_cpuid_s node_cpuid[NR_CPUS];
  28. /*
  29. * This is a matrix with "distances" between nodes, they should be
  30. * proportional to the memory access latency ratios.
  31. */
  32. u8 numa_slit[MAX_NUMNODES * MAX_NUMNODES];
  33. /* Identify which cnode a physical address resides on */
  34. int
  35. paddr_to_nid(unsigned long paddr)
  36. {
  37. int i;
  38. for (i = 0; i < num_node_memblks; i++)
  39. if (paddr >= node_memblk[i].start_paddr &&
  40. paddr < node_memblk[i].start_paddr + node_memblk[i].size)
  41. break;
  42. return (i < num_node_memblks) ? node_memblk[i].nid : (num_node_memblks ? -1 : 0);
  43. }