mmzone_32.h 1.7 KB

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