vmemmap_dedup.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ==========
  3. Device DAX
  4. ==========
  5. The device-dax interface uses the tail deduplication technique explained in
  6. Documentation/mm/vmemmap_dedup.rst
  7. On powerpc, vmemmap deduplication is only used with radix MMU translation. Also
  8. with a 64K page size, only the devdax namespace with 1G alignment uses vmemmap
  9. deduplication.
  10. With 2M PMD level mapping, we require 32 struct pages and a single 64K vmemmap
  11. page can contain 1024 struct pages (64K/sizeof(struct page)). Hence there is no
  12. vmemmap deduplication possible.
  13. With 1G PUD level mapping, we require 16384 struct pages and a single 64K
  14. vmemmap page can contain 1024 struct pages (64K/sizeof(struct page)). Hence we
  15. require 16 64K pages in vmemmap to map the struct page for 1G PUD level mapping.
  16. Here's how things look like on device-dax after the sections are populated::
  17. +-----------+ ---virt_to_page---> +-----------+ mapping to +-----------+
  18. | | | 0 | -------------> | 0 |
  19. | | +-----------+ +-----------+
  20. | | | 1 | -------------> | 1 |
  21. | | +-----------+ +-----------+
  22. | | | 2 | ----------------^ ^ ^ ^ ^ ^
  23. | | +-----------+ | | | | |
  24. | | | 3 | ------------------+ | | | |
  25. | | +-----------+ | | | |
  26. | | | 4 | --------------------+ | | |
  27. | PUD | +-----------+ | | |
  28. | level | | . | ----------------------+ | |
  29. | mapping | +-----------+ | |
  30. | | | . | ------------------------+ |
  31. | | +-----------+ |
  32. | | | 15 | --------------------------+
  33. | | +-----------+
  34. | |
  35. | |
  36. | |
  37. +-----------+
  38. With 4K page size, 2M PMD level mapping requires 512 struct pages and a single
  39. 4K vmemmap page contains 64 struct pages(4K/sizeof(struct page)). Hence we
  40. require 8 4K pages in vmemmap to map the struct page for 2M pmd level mapping.
  41. Here's how things look like on device-dax after the sections are populated::
  42. +-----------+ ---virt_to_page---> +-----------+ mapping to +-----------+
  43. | | | 0 | -------------> | 0 |
  44. | | +-----------+ +-----------+
  45. | | | 1 | -------------> | 1 |
  46. | | +-----------+ +-----------+
  47. | | | 2 | ----------------^ ^ ^ ^ ^ ^
  48. | | +-----------+ | | | | |
  49. | | | 3 | ------------------+ | | | |
  50. | | +-----------+ | | | |
  51. | | | 4 | --------------------+ | | |
  52. | PMD | +-----------+ | | |
  53. | level | | 5 | ----------------------+ | |
  54. | mapping | +-----------+ | |
  55. | | | 6 | ------------------------+ |
  56. | | +-----------+ |
  57. | | | 7 | --------------------------+
  58. | | +-----------+
  59. | |
  60. | |
  61. | |
  62. +-----------+
  63. With 1G PUD level mapping, we require 262144 struct pages and a single 4K
  64. vmemmap page can contain 64 struct pages (4K/sizeof(struct page)). Hence we
  65. require 4096 4K pages in vmemmap to map the struct pages for 1G PUD level
  66. mapping.
  67. Here's how things look like on device-dax after the sections are populated::
  68. +-----------+ ---virt_to_page---> +-----------+ mapping to +-----------+
  69. | | | 0 | -------------> | 0 |
  70. | | +-----------+ +-----------+
  71. | | | 1 | -------------> | 1 |
  72. | | +-----------+ +-----------+
  73. | | | 2 | ----------------^ ^ ^ ^ ^ ^
  74. | | +-----------+ | | | | |
  75. | | | 3 | ------------------+ | | | |
  76. | | +-----------+ | | | |
  77. | | | 4 | --------------------+ | | |
  78. | PUD | +-----------+ | | |
  79. | level | | . | ----------------------+ | |
  80. | mapping | +-----------+ | |
  81. | | | . | ------------------------+ |
  82. | | +-----------+ |
  83. | | | 4095 | --------------------------+
  84. | | +-----------+
  85. | |
  86. | |
  87. | |
  88. +-----------+