page-flags-layout.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef PAGE_FLAGS_LAYOUT_H
  2. #define PAGE_FLAGS_LAYOUT_H
  3. #include <linux/numa.h>
  4. #include <generated/bounds.h>
  5. /*
  6. * When a memory allocation must conform to specific limitations (such
  7. * as being suitable for DMA) the caller will pass in hints to the
  8. * allocator in the gfp_mask, in the zone modifier bits. These bits
  9. * are used to select a priority ordered list of memory zones which
  10. * match the requested limits. See gfp_zone() in include/linux/gfp.h
  11. */
  12. #if MAX_NR_ZONES < 2
  13. #define ZONES_SHIFT 0
  14. #elif MAX_NR_ZONES <= 2
  15. #define ZONES_SHIFT 1
  16. #elif MAX_NR_ZONES <= 4
  17. #define ZONES_SHIFT 2
  18. #else
  19. #error ZONES_SHIFT -- too many zones configured adjust calculation
  20. #endif
  21. #ifdef CONFIG_SPARSEMEM
  22. #include <asm/sparsemem.h>
  23. /* SECTION_SHIFT #bits space required to store a section # */
  24. #define SECTIONS_SHIFT (MAX_PHYSMEM_BITS - SECTION_SIZE_BITS)
  25. #endif /* CONFIG_SPARSEMEM */
  26. /*
  27. * page->flags layout:
  28. *
  29. * There are three possibilities for how page->flags get
  30. * laid out. The first is for the normal case, without
  31. * sparsemem. The second is for sparsemem when there is
  32. * plenty of space for node and section. The last is when
  33. * we have run out of space and have to fall back to an
  34. * alternate (slower) way of determining the node.
  35. *
  36. * No sparsemem or sparsemem vmemmap: | NODE | ZONE | ... | FLAGS |
  37. * classic sparse with space for node:| SECTION | NODE | ZONE | ... | FLAGS |
  38. * classic sparse no space for node: | SECTION | ZONE | ... | FLAGS |
  39. */
  40. #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
  41. #define SECTIONS_WIDTH SECTIONS_SHIFT
  42. #else
  43. #define SECTIONS_WIDTH 0
  44. #endif
  45. #define ZONES_WIDTH ZONES_SHIFT
  46. #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS
  47. #define NODES_WIDTH NODES_SHIFT
  48. #else
  49. #ifdef CONFIG_SPARSEMEM_VMEMMAP
  50. #error "Vmemmap: No space for nodes field in page flags"
  51. #endif
  52. #define NODES_WIDTH 0
  53. #endif
  54. /*
  55. * We are going to use the flags for the page to node mapping if its in
  56. * there. This includes the case where there is no node, so it is implicit.
  57. */
  58. #if !(NODES_WIDTH > 0 || NODES_SHIFT == 0)
  59. #define NODE_NOT_IN_PAGE_FLAGS
  60. #endif
  61. #endif /* _LINUX_PAGE_FLAGS_LAYOUT */