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