mmzone.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifdef CONFIG_NUMA
  7. #define VIRTUAL_BUG_ON(x)
  8. #include <asm/smp.h>
  9. /* Should really switch to dynamic allocation at some point */
  10. #define NODEMAPSIZE 0x4fff
  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. extern int pfn_valid(unsigned long pfn);
  35. #endif
  36. #endif
  37. #endif