All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section
@ 2017-04-06 14:14 Anshuman Khandual
  2017-04-06 14:14 ` [PATCH 2/3] powerpc/mm: Add comments to the vmemmap layout Anshuman Khandual
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Anshuman Khandual @ 2017-04-06 14:14 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: aneesh.kumar, mpe

The commit (16a05bff1: powerpc: start loop at section start of
start in vmemmap_populated()) reused 'start' variable to compute
the starting address of the memory section where the given address
belongs. Then the same variable is used for iterating over starting
address of all memory sections before reaching the 'end' address.
Renaming it as 'section_start' makes the logic more clear.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
Previous discussions on this http://patchwork.ozlabs.org/patch/584103/

 arch/powerpc/mm/init_64.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index c22f207..2a15986 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -104,11 +104,15 @@ static unsigned long __meminit vmemmap_section_start(unsigned long page)
  */
 static int __meminit vmemmap_populated(unsigned long start, int page_size)
 {
-	unsigned long end = start + page_size;
-	start = (unsigned long)(pfn_to_page(vmemmap_section_start(start)));
+	unsigned long end, section_start;
 
-	for (; start < end; start += (PAGES_PER_SECTION * sizeof(struct page)))
-		if (pfn_valid(page_to_pfn((struct page *)start)))
+	end = start + page_size;
+	section_start = (unsigned long)(pfn_to_page
+					(vmemmap_section_start(start)));
+
+	for (; section_start < end; section_start
+				+= (PAGES_PER_SECTION * sizeof(struct page)))
+		if (pfn_valid(page_to_pfn((struct page *)section_start)))
 			return 1;
 
 	return 0;
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] powerpc/mm: Add comments to the vmemmap layout
  2017-04-06 14:14 [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section Anshuman Khandual
@ 2017-04-06 14:14 ` Anshuman Khandual
  2017-06-29 12:21   ` [2/3] " Michael Ellerman
  2017-04-06 14:14 ` [PATCH 3/3] powerpc/mm: Add comments on vmemmap physical mapping Anshuman Khandual
  2017-04-14 13:37 ` [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section Anshuman Khandual
  2 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2017-04-06 14:14 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: aneesh.kumar, mpe

Add some explaination to the layout of vmemmap virtual address
space and how physical page mapping is only used for valid PFNs
present at any point on the system.

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
Previous discussions around this http://patchwork.ozlabs.org/patch/584111/

 arch/powerpc/mm/pgtable-hash64.c | 75 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/arch/powerpc/mm/pgtable-hash64.c b/arch/powerpc/mm/pgtable-hash64.c
index 8b85a14..16877f6 100644
--- a/arch/powerpc/mm/pgtable-hash64.c
+++ b/arch/powerpc/mm/pgtable-hash64.c
@@ -22,6 +22,81 @@
 
 #ifdef CONFIG_SPARSEMEM_VMEMMAP
 /*
+ * vmemmap is the starting address of the virtual address space where
+ * struct pages are allocated for all possible PFNs present on the system
+ * including holes and bad memory (hence sparse). These virtual struct
+ * pages are stored in sequence in this virtual address space irrespective
+ * of the fact whether the corresponding PFN is valid or not. This achieves
+ * constant relationship between address of struct page and its PFN.
+ *
+ * During boot or memory hotplug operation when a new memory section is
+ * added, physical memory allocation (including hash table bolting) will
+ * be performed for the set of struct pages which are part of the memory
+ * section. This saves memory by not allocating struct pages for PFNs
+ * which are not valid.
+ *
+ *		----------------------------------------------
+ *		| PHYSICAL ALLOCATION OF VIRTUAL STRUCT PAGES|
+ *		----------------------------------------------
+ *
+ *	   f000000000000000                  c000000000000000
+ * vmemmap +--------------+                  +--------------+
+ *  +      |  page struct | +--------------> |  page struct |
+ *  |      +--------------+                  +--------------+
+ *  |      |  page struct | +--------------> |  page struct |
+ *  |      +--------------+ |                +--------------+
+ *  |      |  page struct | +       +------> |  page struct |
+ *  |      +--------------+         |        +--------------+
+ *  |      |  page struct |         |   +--> |  page struct |
+ *  |      +--------------+         |   |    +--------------+
+ *  |      |  page struct |         |   |
+ *  |      +--------------+         |   |
+ *  |      |  page struct |         |   |
+ *  |      +--------------+         |   |
+ *  |      |  page struct |         |   |
+ *  |      +--------------+         |   |
+ *  |      |  page struct |         |   |
+ *  |      +--------------+         |   |
+ *  |      |  page struct | +-------+   |
+ *  |      +--------------+             |
+ *  |      |  page struct | +-----------+
+ *  |      +--------------+
+ *  |      |  page struct | No mapping
+ *  |      +--------------+
+ *  |      |  page struct | No mapping
+ *  v      +--------------+
+ *
+ *		-----------------------------------------
+ *		| RELATION BETWEEN STRUCT PAGES AND PFNS|
+ *		-----------------------------------------
+ *
+ * vmemmap +--------------+                 +---------------+
+ *  +      |  page struct | +-------------> |      PFN      |
+ *  |      +--------------+                 +---------------+
+ *  |      |  page struct | +-------------> |      PFN      |
+ *  |      +--------------+                 +---------------+
+ *  |      |  page struct | +-------------> |      PFN      |
+ *  |      +--------------+                 +---------------+
+ *  |      |  page struct | +-------------> |      PFN      |
+ *  |      +--------------+                 +---------------+
+ *  |      |              |
+ *  |      +--------------+
+ *  |      |              |
+ *  |      +--------------+
+ *  |      |              |
+ *  |      +--------------+                 +---------------+
+ *  |      |  page struct | +-------------> |      PFN      |
+ *  |      +--------------+                 +---------------+
+ *  |      |              |
+ *  |      +--------------+
+ *  |      |              |
+ *  |      +--------------+                 +---------------+
+ *  |      |  page struct | +-------------> |      PFN      |
+ *  |      +--------------+                 +---------------+
+ *  |      |  page struct | +-------------> |      PFN      |
+ *  v      +--------------+                 +---------------+
+ */
+/*
  * On hash-based CPUs, the vmemmap is bolted in the hash table.
  *
  */
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] powerpc/mm: Add comments on vmemmap physical mapping
  2017-04-06 14:14 [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section Anshuman Khandual
  2017-04-06 14:14 ` [PATCH 2/3] powerpc/mm: Add comments to the vmemmap layout Anshuman Khandual
@ 2017-04-06 14:14 ` Anshuman Khandual
  2017-06-29 12:21   ` [3/3] " Michael Ellerman
  2017-04-14 13:37 ` [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section Anshuman Khandual
  2 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2017-04-06 14:14 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: aneesh.kumar, mpe

Adds some explaination on how the vmemmap based struct page layout's
physical mapping is allocated and tracked through linked list. It
also keeps note of a possible race condition.

Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
Previous discussions on this http://patchwork.ozlabs.org/patch/584110/
Michael Ellerman had agreed to take the comments alone.

 arch/powerpc/mm/init_64.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 2a15986..6e5c54d 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -118,8 +118,28 @@ static int __meminit vmemmap_populated(unsigned long start, int page_size)
 	return 0;
 }
 
+/*
+ * vmemmap virtual address space management does not have a traditonal page
+ * table to track which virtual struct pages are backed by physical mapping.
+ * The virtual to physical mappings are tracked in a simple linked list
+ * format. 'vmemmap_list' maintains the entire vmemmap physical mapping at
+ * all times where as the 'next' list maintains the available
+ * vmemmap_backing structures which have been deleted from the
+ * 'vmemmap_global' list during system runtime (memory hotplug remove
+ * operation). The freed 'vmemmap_backing' structures are reused later when
+ * new requests come in without allocating fresh memory. This pointer also
+ * tracks the allocated 'vmemmap_backing' structures as we allocate one
+ * full page memory at a time when we dont have any.
+ */
 struct vmemmap_backing *vmemmap_list;
 static struct vmemmap_backing *next;
+
+/* The same pointer 'next' tracks individual chunks inside the allocated
+ * full page during the boot time and again tracks the freeed nodes during
+ * runtime. It is racy but it does not happen as they are separated by the
+ * boot process. Will create problem if some how we have memory hotplug
+ * operation during boot !!
+ */
 static int num_left;
 static int num_freed;
 
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section
  2017-04-06 14:14 [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section Anshuman Khandual
  2017-04-06 14:14 ` [PATCH 2/3] powerpc/mm: Add comments to the vmemmap layout Anshuman Khandual
  2017-04-06 14:14 ` [PATCH 3/3] powerpc/mm: Add comments on vmemmap physical mapping Anshuman Khandual
@ 2017-04-14 13:37 ` Anshuman Khandual
  2 siblings, 0 replies; 6+ messages in thread
From: Anshuman Khandual @ 2017-04-14 13:37 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: aneesh.kumar, Michael Ellerman

On 04/06/2017 07:44 PM, Anshuman Khandual wrote:
> The commit (16a05bff1: powerpc: start loop at section start of
> start in vmemmap_populated()) reused 'start' variable to compute
> the starting address of the memory section where the given address
> belongs. Then the same variable is used for iterating over starting
> address of all memory sections before reaching the 'end' address.
> Renaming it as 'section_start' makes the logic more clear.
> 
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> Previous discussions on this http://patchwork.ozlabs.org/patch/584103/

Hello Michael,

Are you okay with this cleanup, we had discussed about this before which
can be pulled up from the link above. The other two patches are just
in-code documentation addition to relevant files.

Regards
Anshuman

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [3/3] powerpc/mm: Add comments on vmemmap physical mapping
  2017-04-06 14:14 ` [PATCH 3/3] powerpc/mm: Add comments on vmemmap physical mapping Anshuman Khandual
@ 2017-06-29 12:21   ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2017-06-29 12:21 UTC (permalink / raw)
  To: Anshuman Khandual, linuxppc-dev; +Cc: aneesh.kumar

On Thu, 2017-04-06 at 14:14:50 UTC, Anshuman Khandual wrote:
> Adds some explaination on how the vmemmap based struct page layout's
> physical mapping is allocated and tracked through linked list. It
> also keeps note of a possible race condition.
> 
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/39e46751839dfe4c34eb354eee1e27

cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [2/3] powerpc/mm: Add comments to the vmemmap layout
  2017-04-06 14:14 ` [PATCH 2/3] powerpc/mm: Add comments to the vmemmap layout Anshuman Khandual
@ 2017-06-29 12:21   ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2017-06-29 12:21 UTC (permalink / raw)
  To: Anshuman Khandual, linuxppc-dev; +Cc: aneesh.kumar

On Thu, 2017-04-06 at 14:14:49 UTC, Anshuman Khandual wrote:
> Add some explaination to the layout of vmemmap virtual address
> space and how physical page mapping is only used for valid PFNs
> present at any point on the system.
> 
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b0f36c10de8d9bd271ae261604d4e4

cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-06-29 12:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06 14:14 [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section Anshuman Khandual
2017-04-06 14:14 ` [PATCH 2/3] powerpc/mm: Add comments to the vmemmap layout Anshuman Khandual
2017-06-29 12:21   ` [2/3] " Michael Ellerman
2017-04-06 14:14 ` [PATCH 3/3] powerpc/mm: Add comments on vmemmap physical mapping Anshuman Khandual
2017-06-29 12:21   ` [3/3] " Michael Ellerman
2017-04-14 13:37 ` [PATCH 1/3] powerpc/mm: Rename variable to reflect start address of a section Anshuman Khandual

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.