From bd573d98573627fb88168372950ffa6b99ddf09e Mon Sep 17 00:00:00 2001 From: Alexander Kuleshov Date: Tue, 18 Oct 2016 00:23:07 +0600 Subject: [PATCH] better explanation of memblock_merge_regions() --- mm/linux-mm-1.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/linux-mm-1.md b/mm/linux-mm-1.md index 8c4ac85..6bbccd9 100644 --- a/mm/linux-mm-1.md +++ b/mm/linux-mm-1.md @@ -310,7 +310,7 @@ As we update the size of the first memory region with the size of the next memor memmove(next, next + 1, (type->cnt - (i + 2)) * sizeof(*next)); ``` -And decrease the count of the memory regions which belong to the `memblock_type`: +The `memmove` here moves all regions which are located after the `next` region to the base address of the `next` region. In the end we just decrease the count of the memory regions which belong to the `memblock_type`: ```C type->cnt--; @@ -329,6 +329,8 @@ After this we will get two memory regions merged into one: +------------------------------------------------+ ``` +As we decreased counts of regions in a memblock with certain type, increased size of the `this` region and shifted all regions which are located after `next` region to its place. + That's all. This is the whole principle of the work of the `memblock_add_range` function. There is also `memblock_reserve` function which does the same as `memblock_add`, but with one difference. It stores `memblock_type.reserved` in the memblock instead of `memblock_type.memory`.