mmzone.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Written by Kanoj Sarcar (kanoj@sgi.com) Aug 99
  3. *
  4. * PowerPC64 port:
  5. * Copyright (C) 2002 Anton Blanchard, IBM Corp.
  6. */
  7. #ifndef _ASM_MMZONE_H_
  8. #define _ASM_MMZONE_H_
  9. #include <linux/config.h>
  10. #include <asm/smp.h>
  11. /* generic non-linear memory support:
  12. *
  13. * 1) we will not split memory into more chunks than will fit into the
  14. * flags field of the struct page
  15. */
  16. #ifdef CONFIG_NEED_MULTIPLE_NODES
  17. extern struct pglist_data *node_data[];
  18. /*
  19. * Return a pointer to the node data for node n.
  20. */
  21. #define NODE_DATA(nid) (node_data[nid])
  22. /*
  23. * Following are specific to this numa platform.
  24. */
  25. extern int numa_cpu_lookup_table[];
  26. extern char *numa_memory_lookup_table;
  27. extern cpumask_t numa_cpumask_lookup_table[];
  28. extern int nr_cpus_in_node[];
  29. /* 16MB regions */
  30. #define MEMORY_INCREMENT_SHIFT 24
  31. #define MEMORY_INCREMENT (1UL << MEMORY_INCREMENT_SHIFT)
  32. /* NUMA debugging, will not work on a DLPAR machine */
  33. #undef DEBUG_NUMA
  34. static inline int pa_to_nid(unsigned long pa)
  35. {
  36. int nid;
  37. nid = numa_memory_lookup_table[pa >> MEMORY_INCREMENT_SHIFT];
  38. #ifdef DEBUG_NUMA
  39. /* the physical address passed in is not in the map for the system */
  40. if (nid == -1) {
  41. printk("bad address: %lx\n", pa);
  42. BUG();
  43. }
  44. #endif
  45. return nid;
  46. }
  47. #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
  48. /*
  49. * Following are macros that each numa implmentation must define.
  50. */
  51. #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
  52. #define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
  53. #ifdef CONFIG_DISCONTIGMEM
  54. /*
  55. * Given a kernel address, find the home node of the underlying memory.
  56. */
  57. #define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
  58. #define pfn_to_nid(pfn) pa_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
  59. /* Written this way to avoid evaluating arguments twice */
  60. #define discontigmem_pfn_to_page(pfn) \
  61. ({ \
  62. unsigned long __tmp = pfn; \
  63. (NODE_DATA(pfn_to_nid(__tmp))->node_mem_map + \
  64. node_localnr(__tmp, pfn_to_nid(__tmp))); \
  65. })
  66. #define discontigmem_page_to_pfn(p) \
  67. ({ \
  68. struct page *__tmp = p; \
  69. (((__tmp) - page_zone(__tmp)->zone_mem_map) + \
  70. page_zone(__tmp)->zone_start_pfn); \
  71. })
  72. /* XXX fix for discontiguous physical memory */
  73. #define discontigmem_pfn_valid(pfn) ((pfn) < num_physpages)
  74. #endif /* CONFIG_DISCONTIGMEM */
  75. #endif /* CONFIG_NEED_MULTIPLE_NODES */
  76. #ifdef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
  77. #define early_pfn_to_nid(pfn) pa_to_nid(((unsigned long)pfn) << PAGE_SHIFT)
  78. #endif
  79. #endif /* _ASM_MMZONE_H_ */