mmzone.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /* Should really switch to dynamic allocation at some point */
  11. #define NODEMAPSIZE 0x4fff
  12. /* Simple perfect hash to map physical addresses to node numbers */
  13. struct memnode {
  14. int shift;
  15. u8 map[NODEMAPSIZE];
  16. } ____cacheline_aligned;
  17. extern struct memnode memnode;
  18. #define memnode_shift memnode.shift
  19. #define memnodemap memnode.map
  20. extern struct pglist_data *node_data[];
  21. static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
  22. {
  23. unsigned nid;
  24. VIRTUAL_BUG_ON((addr >> memnode_shift) >= NODEMAPSIZE);
  25. nid = memnodemap[addr >> memnode_shift];
  26. VIRTUAL_BUG_ON(nid >= MAX_NUMNODES || !node_data[nid]);
  27. return nid;
  28. }
  29. #define NODE_DATA(nid) (node_data[nid])
  30. #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
  31. #define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
  32. NODE_DATA(nid)->node_spanned_pages)
  33. #ifdef CONFIG_DISCONTIGMEM
  34. #define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
  35. #define kvaddr_to_nid(kaddr) phys_to_nid(__pa(kaddr))
  36. extern int pfn_valid(unsigned long pfn);
  37. #endif
  38. #endif
  39. #endif