mmzone_32.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002
  3. *
  4. */
  5. #ifndef _ASM_X86_MMZONE_32_H
  6. #define _ASM_X86_MMZONE_32_H
  7. #include <asm/smp.h>
  8. #ifdef CONFIG_NUMA
  9. extern struct pglist_data *node_data[];
  10. #define NODE_DATA(nid) (node_data[nid])
  11. #include <asm/numaq.h>
  12. /* summit or generic arch */
  13. #include <asm/srat.h>
  14. extern void resume_map_numa_kva(pgd_t *pgd);
  15. #else /* !CONFIG_NUMA */
  16. static inline void resume_map_numa_kva(pgd_t *pgd) {}
  17. #endif /* CONFIG_NUMA */
  18. #ifdef CONFIG_DISCONTIGMEM
  19. /*
  20. * generic node memory support, the following assumptions apply:
  21. *
  22. * 1) memory comes in 64Mb contiguous chunks which are either present or not
  23. * 2) we will not have more than 64Gb in total
  24. *
  25. * for now assume that 64Gb is max amount of RAM for whole system
  26. * 64Gb / 4096bytes/page = 16777216 pages
  27. */
  28. #define MAX_NR_PAGES 16777216
  29. #define MAX_ELEMENTS 1024
  30. #define PAGES_PER_ELEMENT (MAX_NR_PAGES/MAX_ELEMENTS)
  31. extern s8 physnode_map[];
  32. static inline int pfn_to_nid(unsigned long pfn)
  33. {
  34. #ifdef CONFIG_NUMA
  35. return((int) physnode_map[(pfn) / PAGES_PER_ELEMENT]);
  36. #else
  37. return 0;
  38. #endif
  39. }
  40. /*
  41. * Following are macros that each numa implmentation must define.
  42. */
  43. #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
  44. #define node_end_pfn(nid) \
  45. ({ \
  46. pg_data_t *__pgdat = NODE_DATA(nid); \
  47. __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
  48. })
  49. static inline int pfn_valid(int pfn)
  50. {
  51. int nid = pfn_to_nid(pfn);
  52. if (nid >= 0)
  53. return (pfn < node_end_pfn(nid));
  54. return 0;
  55. }
  56. #endif /* CONFIG_DISCONTIGMEM */
  57. #ifdef CONFIG_NEED_MULTIPLE_NODES
  58. /* always use node 0 for bootmem on this numa platform */
  59. #define bootmem_arch_preferred_node(__bdata, size, align, goal, limit) \
  60. (NODE_DATA(0)->bdata)
  61. #endif /* CONFIG_NEED_MULTIPLE_NODES */
  62. #endif /* _ASM_X86_MMZONE_32_H */