mmzone.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #ifdef CONFIG_DISCONTIGMEM
  12. extern struct pglist_data *node_data[];
  13. /*
  14. * Following are specific to this numa platform.
  15. */
  16. extern int numa_cpu_lookup_table[];
  17. extern char *numa_memory_lookup_table;
  18. extern cpumask_t numa_cpumask_lookup_table[];
  19. extern int nr_cpus_in_node[];
  20. /* 16MB regions */
  21. #define MEMORY_INCREMENT_SHIFT 24
  22. #define MEMORY_INCREMENT (1UL << MEMORY_INCREMENT_SHIFT)
  23. /* NUMA debugging, will not work on a DLPAR machine */
  24. #undef DEBUG_NUMA
  25. static inline int pa_to_nid(unsigned long pa)
  26. {
  27. int nid;
  28. nid = numa_memory_lookup_table[pa >> MEMORY_INCREMENT_SHIFT];
  29. #ifdef DEBUG_NUMA
  30. /* the physical address passed in is not in the map for the system */
  31. if (nid == -1) {
  32. printk("bad address: %lx\n", pa);
  33. BUG();
  34. }
  35. #endif
  36. return nid;
  37. }
  38. #define pfn_to_nid(pfn) pa_to_nid((pfn) << PAGE_SHIFT)
  39. /*
  40. * Return a pointer to the node data for node n.
  41. */
  42. #define NODE_DATA(nid) (node_data[nid])
  43. #define node_localnr(pfn, nid) ((pfn) - NODE_DATA(nid)->node_start_pfn)
  44. /*
  45. * Following are macros that each numa implmentation must define.
  46. */
  47. /*
  48. * Given a kernel address, find the home node of the underlying memory.
  49. */
  50. #define kvaddr_to_nid(kaddr) pa_to_nid(__pa(kaddr))
  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. /* Written this way to avoid evaluating arguments twice */
  56. #define discontigmem_pfn_to_page(pfn) \
  57. ({ \
  58. unsigned long __tmp = pfn; \
  59. (NODE_DATA(pfn_to_nid(__tmp))->node_mem_map + \
  60. node_localnr(__tmp, pfn_to_nid(__tmp))); \
  61. })
  62. #define discontigmem_page_to_pfn(p) \
  63. ({ \
  64. struct page *__tmp = p; \
  65. (((__tmp) - page_zone(__tmp)->zone_mem_map) + \
  66. page_zone(__tmp)->zone_start_pfn); \
  67. })
  68. /* XXX fix for discontiguous physical memory */
  69. #define discontigmem_pfn_valid(pfn) ((pfn) < num_physpages)
  70. #endif /* CONFIG_DISCONTIGMEM */
  71. #endif /* _ASM_MMZONE_H_ */