Skip to contentSkip to conversation

docs/vm: add documentation of memory models

PATCH Superseded Mike Rapoport 2 participants 2 messages Apr 25, 2019 – Apr 27, 2019

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 docs/vm: add documentation of memory models

Describe what {FLAT,DISCONTIG,SPARSE}MEM are and how they manage to maintain pfn <-> struct page correspondence.

---
v2 changes:
* spelling/grammar fixes
* added note about deprectation of DISCONTIGMEM
* added a paragraph about 'struct vmem_altmap'

 Documentation/vm/index.rst        |   1 +
 Documentation/vm/memory-model.rst | 183 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 184 insertions(+)
 create mode 100644 Documentation/vm/memory-model.rst
Documentation/vm/index.rst +1 -0
index b58cc3b..e8d943b 100644
@@ -37,6 +37,7 @@ descriptions of data structures and algorithms.
    hwpoison
    hugetlbfs_reserv
    ksm
+   memory-model
    mmu_notifier
    numa
    overcommit-accounting
Documentation/vm/memory-model.rst new file +183 -0

183 lines not on this page · raw message

Signature · 1 line
2.7.4
reviewer
#1 lore raw
Quoted 8 lines · Mike Rapoport

Describe what {FLAT,DISCONTIG,SPARSE}MEM are and how they manage to maintain pfn <-> struct page correspondence.

---
v2 changes:
* spelling/grammar fixes
* added note about deprectation of DISCONTIGMEM

deprecation

and a few more comments below...

Quoted 34 lines

* added a paragraph about 'struct vmem_altmap'

 Documentation/vm/index.rst        |   1 +
 Documentation/vm/memory-model.rst | 183 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 184 insertions(+)
 create mode 100644 Documentation/vm/memory-model.rst
Documentation/vm/index.rst +1 -0
index b58cc3b..e8d943b 100644
@@ -37,6 +37,7 @@ descriptions of data structures and algorithms.
    hwpoison
    hugetlbfs_reserv
    ksm
+   memory-model
    mmu_notifier
    numa
    overcommit-accounting
Documentation/vm/memory-model.rst new file +9 -0
new file mode 100644
index 0000000..0b4cf19
@@ -0,0 +1,183 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. _physical_memory_model:
+
+=====================
+Physical Memory Model
+=====================
+
+Physical memory in a system may be addressed in different ways. The

Documentation/vm/memory-model.rst line 19

Quoted 10 lines
Documentation/vm/memory-model.rst new file +10 -0
+simplest case is when the physical memory starts at address 0 and
+spans a contiguous range up to the maximal address. It could be,
+however, that this range contains small holes that are not accessible
+for the CPU. Then there could be several contiguous ranges at
+completely distinct addresses. And, don't forget about NUMA, where
+different memory banks are attached to different CPUs.
+
+Linux abstracts this diversity using one of the three memory models:
+FLATMEM, DISCONTIGMEM and SPARSEMEM. Each architecture defines what
+memory models it supports, what is the default memory model and

what the default memory model is and

Documentation/vm/memory-model.rst line 20

Quoted 1 line
Documentation/vm/memory-model.rst new file +1 -0
+whether it possible to manually override that default.

whether it is possible

Documentation/vm/memory-model.rst line 24

Quoted 4 lines
Documentation/vm/memory-model.rst new file +4 -0
+
+.. note::
+   At time of this writing, DISCONTIGMEM is considered deprecated,
+   although it is still in use by several architectures

end with '.'

Documentation/vm/memory-model.rst line 35

Quoted 11 lines
Documentation/vm/memory-model.rst new file +11 -0
+
+All the memory models track the status of physical page frames using
+:c:type:`struct page` arranged in one or more arrays.
+
+Regardless of the selected memory model, there exists one-to-one
+mapping between the physical page frame number (PFN) and the
+corresponding `struct page`.
+
+Each memory model defines :c:func:`pfn_to_page` and :c:func:`page_to_pfn`
+helpers that allow the conversion from PFN to `struct page` and vice
+versa.

[snip]

thanks.

Signature · 1 line
~Randy