mmzone.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #define local_mapnr(kvaddr) \
  54. ( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr))
  55. #ifdef CONFIG_DISCONTIGMEM
  56. /*
  57. * Given a kernel address, find the home node of the underlying memory.
  58. */
  59. #define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
  60. #define pfn_to_nid(pfn) pa_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
  61. /* Written this way to avoid evaluating arguments twice */
  62. #define discontigmem_pfn_to_page(pfn) \
  63. ({ \
  64. unsigned long __tmp = pfn; \
  65. (NODE_DATA(pfn_to_nid(__tmp))->node_mem_map + \
  66. node_localnr(__tmp, pfn_to_nid(__tmp))); \
  67. })
  68. #define discontigmem_page_to_pfn(p) \
  69. ({ \
  70. struct page *__tmp = p; \
  71. (((__tmp) - page_zone(__tmp)->zone_mem_map) + \
  72. page_zone(__tmp)->zone_start_pfn); \
  73. })
  74. /* XXX fix for discontiguous physical memory */
  75. #define discontigmem_pfn_valid(pfn) ((pfn) < num_physpages)
  76. #endif /* CONFIG_DISCONTIGMEM */
  77. #endif /* CONFIG_NEED_MULTIPLE_NODES */
  78. #ifdef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
  79. #define early_pfn_to_nid(pfn) pa_to_nid(((unsigned long)pfn) << PAGE_SHIFT)
  80. #endif
  81. #endif /* _ASM_MMZONE_H_ */