mmzone.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* K8 NUMA support */
  2. /* Copyright 2002,2003 by Andi Kleen, SuSE Labs */
  3. /* 2.5 Version loosely based on the NUMAQ Code by Pat Gaughen. */
  4. #ifndef _ASM_X86_64_MMZONE_H
  5. #define _ASM_X86_64_MMZONE_H 1
  6. #include <linux/config.h>
  7. #ifdef CONFIG_NUMA
  8. #define VIRTUAL_BUG_ON(x)
  9. #include <asm/smp.h>
  10. #define NODEMAPSIZE 0xfff
  11. /* Simple perfect hash to map physical addresses to node numbers */
  12. struct memnode {
  13. int shift;
  14. u8 map[NODEMAPSIZE];
  15. } ____cacheline_aligned;
  16. extern struct memnode memnode;
  17. #define memnode_shift memnode.shift
  18. #define memnodemap memnode.map
  19. extern struct pglist_data *node_data[];
  20. static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
  21. {
  22. unsigned nid;
  23. VIRTUAL_BUG_ON((addr >> memnode_shift) >= NODEMAPSIZE);
  24. nid = memnodemap[addr >> memnode_shift];
  25. VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]);
  26. return nid;
  27. }
  28. #define NODE_DATA(nid) (node_data[nid])
  29. #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
  30. #define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
  31. NODE_DATA(nid)->node_spanned_pages)
  32. #ifdef CONFIG_DISCONTIGMEM
  33. #define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
  34. #define kvaddr_to_nid(kaddr) phys_to_nid(__pa(kaddr))
  35. extern int pfn_valid(unsigned long pfn);
  36. #endif
  37. #endif
  38. #endif