Linux SNPS ARC Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ARC: mm: remove __ARCH_USE_5LEVEL_HACK
@ 2019-10-08 21:38 Vineet.Gupta1
  2019-10-08 23:42 ` kirill.shutemov
  0 siblings, 1 reply; 7+ messages in thread
From: Vineet.Gupta1 @ 2019-10-08 21:38 UTC (permalink / raw)
  To: linux-snps-arc

Add the intermediate p4d accessors to make it 5 level compliant.

Thi sis non-functional change anyways since ARC has software page walker
with 2 lookup levels (pgd -> pte)

Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/include/asm/pgtable.h |  1 -
 arch/arc/mm/fault.c            | 10 ++++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
index 976b5931372e..902d45428cea 100644
--- a/arch/arc/include/asm/pgtable.h
+++ b/arch/arc/include/asm/pgtable.h
@@ -33,7 +33,6 @@
 #define _ASM_ARC_PGTABLE_H
 
 #include <linux/bits.h>
-#define __ARCH_USE_5LEVEL_HACK
 #include <asm-generic/pgtable-nopmd.h>
 #include <asm/page.h>
 #include <asm/mmu.h>	/* to propagate CONFIG_ARC_MMU_VER <n> */
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 3861543b66a0..fb86bc3e9b35 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -30,6 +30,7 @@ noinline static int handle_kernel_vaddr_fault(unsigned long address)
 	 * with the 'reference' page table.
 	 */
 	pgd_t *pgd, *pgd_k;
+	p4d_t *p4d, *p4d_k;
 	pud_t *pud, *pud_k;
 	pmd_t *pmd, *pmd_k;
 
@@ -39,8 +40,13 @@ noinline static int handle_kernel_vaddr_fault(unsigned long address)
 	if (!pgd_present(*pgd_k))
 		goto bad_area;
 
-	pud = pud_offset(pgd, address);
-	pud_k = pud_offset(pgd_k, address);
+	p4d = p4d_offset(pgd, address);
+	p4d_k = p4d_offset(pgd_k, address);
+	if (!p4d_present(*p4d_k))
+		goto bad_area;
+
+	pud = pud_offset(p4d, address);
+	pud_k = pud_offset(p4d_k, address);
 	if (!pud_present(*pud_k))
 		goto bad_area;
 
-- 
2.20.1

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

* [PATCH] ARC: mm: remove __ARCH_USE_5LEVEL_HACK
  2019-10-08 21:38 [PATCH] ARC: mm: remove __ARCH_USE_5LEVEL_HACK Vineet.Gupta1
@ 2019-10-08 23:42 ` kirill.shutemov
  2019-10-09 18:38   ` vineetg76
  0 siblings, 1 reply; 7+ messages in thread
From: kirill.shutemov @ 2019-10-08 23:42 UTC (permalink / raw)
  To: linux-snps-arc

On Tue, Oct 08, 2019@09:38:36PM +0000, Vineet Gupta wrote:
> Add the intermediate p4d accessors to make it 5 level compliant.
> 
> Thi sis non-functional change anyways since ARC has software page walker
     ^
     Typo.
> with 2 lookup levels (pgd -> pte)
> 
> Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
> ---
>  arch/arc/include/asm/pgtable.h |  1 -
>  arch/arc/mm/fault.c            | 10 ++++++++--
>  2 files changed, 8 insertions(+), 3 deletions(-)

Have you tested it with CONFIG_HIGHMEM=y? alloc_kmap_pgtable() has to be
converted too.

-- 
 Kirill A. Shutemov

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

* [PATCH] ARC: mm: remove __ARCH_USE_5LEVEL_HACK
  2019-10-08 23:42 ` kirill.shutemov
@ 2019-10-09 18:38   ` vineetg76
  2019-10-09 18:43     ` [PATCH v2] " Vineet.Gupta1
  0 siblings, 1 reply; 7+ messages in thread
From: vineetg76 @ 2019-10-09 18:38 UTC (permalink / raw)
  To: linux-snps-arc

On 10/8/19 4:42 PM, Kirill A. Shutemov wrote:
> On Tue, Oct 08, 2019@09:38:36PM +0000, Vineet Gupta wrote:
>> Add the intermediate p4d accessors to make it 5 level compliant.
>>
>> Thi sis non-functional change anyways since ARC has software page walker
>      ^
>      Typo.

Oops, fixed now !

...

> Have you tested it with CONFIG_HIGHMEM=y? alloc_kmap_pgtable() has to be
> converted too.

No I didn't. Fixed that as well.

Thx for looking
-Vineet

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

* [PATCH v2] ARC: mm: remove __ARCH_USE_5LEVEL_HACK
  2019-10-09 18:38   ` vineetg76
@ 2019-10-09 18:43     ` " Vineet.Gupta1
  2019-10-09 18:57       ` [PATCH v3] " Vineet.Gupta1
  0 siblings, 1 reply; 7+ messages in thread
From: Vineet.Gupta1 @ 2019-10-09 18:43 UTC (permalink / raw)
  To: linux-snps-arc

Add the intermediate p4d accessors to make it 5 level compliant.

This is a non-functional change anyways since ARC has software page walker
with 2 lookup levels (pgd -> pte)

There is slight code bloat due to pulling in needless p*d_free_tlb()
macros which needs to be addressed seperately.

| bloat-o-meter2 vmlinux-with-5LEVEL_HACK vmlinux-patched
| add/remove: 0/0 grow/shrink: 2/0 up/down: 128/0 (128)
| function                                     old     new   delta
| free_pgd_range                               546     656    +110
| p4d_clear_bad                                  2      20     +18
| Total: Before=4137148, After=4137276, chg 0.000000%

Cc: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
---
v2 <- v1:
  - fix highmem code
---
 arch/arc/include/asm/pgtable.h |  1 -
 arch/arc/mm/fault.c            | 10 ++++++++--
 arch/arc/mm/highmem.c          |  4 +++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
index 976b5931372e..902d45428cea 100644
--- a/arch/arc/include/asm/pgtable.h
+++ b/arch/arc/include/asm/pgtable.h
@@ -33,7 +33,6 @@
 #define _ASM_ARC_PGTABLE_H
 
 #include <linux/bits.h>
-#define __ARCH_USE_5LEVEL_HACK
 #include <asm-generic/pgtable-nopmd.h>
 #include <asm/page.h>
 #include <asm/mmu.h>	/* to propagate CONFIG_ARC_MMU_VER <n> */
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 3861543b66a0..fb86bc3e9b35 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -30,6 +30,7 @@ noinline static int handle_kernel_vaddr_fault(unsigned long address)
 	 * with the 'reference' page table.
 	 */
 	pgd_t *pgd, *pgd_k;
+	p4d_t *p4d, *p4d_k;
 	pud_t *pud, *pud_k;
 	pmd_t *pmd, *pmd_k;
 
@@ -39,8 +40,13 @@ noinline static int handle_kernel_vaddr_fault(unsigned long address)
 	if (!pgd_present(*pgd_k))
 		goto bad_area;
 
-	pud = pud_offset(pgd, address);
-	pud_k = pud_offset(pgd_k, address);
+	p4d = p4d_offset(pgd, address);
+	p4d_k = p4d_offset(pgd_k, address);
+	if (!p4d_present(*p4d_k))
+		goto bad_area;
+
+	pud = pud_offset(p4d, address);
+	pud_k = pud_offset(p4d_k, address);
 	if (!pud_present(*pud_k))
 		goto bad_area;
 
diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c
index a4856bfaedf3..69397c884a7b 100644
--- a/arch/arc/mm/highmem.c
+++ b/arch/arc/mm/highmem.c
@@ -111,12 +111,14 @@ EXPORT_SYMBOL(__kunmap_atomic);
 static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr)
 {
 	pgd_t *pgd_k;
+	p4d_t *p4d_k;
 	pud_t *pud_k;
 	pmd_t *pmd_k;
 	pte_t *pte_k;
 
 	pgd_k = pgd_offset_k(kvaddr);
-	pud_k = pud_offset(pgd_k, kvaddr);
+	p4d_k = p4d_offset(pgd_k, address);
+	pud_k = pud_offset(p4d_k, kvaddr);
 	pmd_k = pmd_offset(pud_k, kvaddr);
 
 	pte_k = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
-- 
2.20.1

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

* [PATCH v3] ARC: mm: remove __ARCH_USE_5LEVEL_HACK
  2019-10-09 18:43     ` [PATCH v2] " Vineet.Gupta1
@ 2019-10-09 18:57       ` " Vineet.Gupta1
  2019-10-10  8:28         ` kirill.shutemov
  2019-10-22 15:23         ` Mike Rapoport
  0 siblings, 2 replies; 7+ messages in thread
From: Vineet.Gupta1 @ 2019-10-09 18:57 UTC (permalink / raw)
  To: linux-snps-arc

Add the intermediate p4d accessors to make it 5 level compliant.

This is a non-functional change anyways since ARC has software page walker
with 2 lookup levels (pgd -> pte)

There is slight code bloat due to pulling in needless p*d_free_tlb()
macros which needs to be addressed seperately.

| bloat-o-meter2 vmlinux-with-5LEVEL_HACK vmlinux-patched
| add/remove: 0/0 grow/shrink: 2/0 up/down: 128/0 (128)
| function                                     old     new   delta
| free_pgd_range                               546     656    +110
| p4d_clear_bad                                  2      20     +18
| Total: Before=4137148, After=4137276, chg 0.000000%

Cc: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
---
v3 <- v2
  - fix highmem build error

v2 <- v1
 - fix highmem code
---
 arch/arc/include/asm/pgtable.h |  1 -
 arch/arc/mm/fault.c            | 10 ++++++++--
 arch/arc/mm/highmem.c          |  4 +++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
index 976b5931372e..902d45428cea 100644
--- a/arch/arc/include/asm/pgtable.h
+++ b/arch/arc/include/asm/pgtable.h
@@ -33,7 +33,6 @@
 #define _ASM_ARC_PGTABLE_H
 
 #include <linux/bits.h>
-#define __ARCH_USE_5LEVEL_HACK
 #include <asm-generic/pgtable-nopmd.h>
 #include <asm/page.h>
 #include <asm/mmu.h>	/* to propagate CONFIG_ARC_MMU_VER <n> */
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index 3861543b66a0..fb86bc3e9b35 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -30,6 +30,7 @@ noinline static int handle_kernel_vaddr_fault(unsigned long address)
 	 * with the 'reference' page table.
 	 */
 	pgd_t *pgd, *pgd_k;
+	p4d_t *p4d, *p4d_k;
 	pud_t *pud, *pud_k;
 	pmd_t *pmd, *pmd_k;
 
@@ -39,8 +40,13 @@ noinline static int handle_kernel_vaddr_fault(unsigned long address)
 	if (!pgd_present(*pgd_k))
 		goto bad_area;
 
-	pud = pud_offset(pgd, address);
-	pud_k = pud_offset(pgd_k, address);
+	p4d = p4d_offset(pgd, address);
+	p4d_k = p4d_offset(pgd_k, address);
+	if (!p4d_present(*p4d_k))
+		goto bad_area;
+
+	pud = pud_offset(p4d, address);
+	pud_k = pud_offset(p4d_k, address);
 	if (!pud_present(*pud_k))
 		goto bad_area;
 
diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c
index a4856bfaedf3..fc8849e4f72e 100644
--- a/arch/arc/mm/highmem.c
+++ b/arch/arc/mm/highmem.c
@@ -111,12 +111,14 @@ EXPORT_SYMBOL(__kunmap_atomic);
 static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr)
 {
 	pgd_t *pgd_k;
+	p4d_t *p4d_k;
 	pud_t *pud_k;
 	pmd_t *pmd_k;
 	pte_t *pte_k;
 
 	pgd_k = pgd_offset_k(kvaddr);
-	pud_k = pud_offset(pgd_k, kvaddr);
+	p4d_k = p4d_offset(pgd_k, kvaddr);
+	pud_k = pud_offset(p4d_k, kvaddr);
 	pmd_k = pmd_offset(pud_k, kvaddr);
 
 	pte_k = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
-- 
2.20.1

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

* [PATCH v3] ARC: mm: remove __ARCH_USE_5LEVEL_HACK
  2019-10-09 18:57       ` [PATCH v3] " Vineet.Gupta1
@ 2019-10-10  8:28         ` kirill.shutemov
  2019-10-22 15:23         ` Mike Rapoport
  1 sibling, 0 replies; 7+ messages in thread
From: kirill.shutemov @ 2019-10-10  8:28 UTC (permalink / raw)
  To: linux-snps-arc

On Wed, Oct 09, 2019@06:57:31PM +0000, Vineet Gupta wrote:
> Add the intermediate p4d accessors to make it 5 level compliant.
> 
> This is a non-functional change anyways since ARC has software page walker
> with 2 lookup levels (pgd -> pte)
> 
> There is slight code bloat due to pulling in needless p*d_free_tlb()
> macros which needs to be addressed seperately.
> 
> | bloat-o-meter2 vmlinux-with-5LEVEL_HACK vmlinux-patched
> | add/remove: 0/0 grow/shrink: 2/0 up/down: 128/0 (128)
> | function                                     old     new   delta
> | free_pgd_range                               546     656    +110
> | p4d_clear_bad                                  2      20     +18
> | Total: Before=4137148, After=4137276, chg 0.000000%
> 
> Cc: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
> Signed-off-by: Vineet Gupta <vgupta at synopsys.com>

Acked-by: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>

-- 
 Kirill A. Shutemov

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

* Re: [PATCH v3] ARC: mm: remove __ARCH_USE_5LEVEL_HACK
  2019-10-09 18:57       ` [PATCH v3] " Vineet.Gupta1
  2019-10-10  8:28         ` kirill.shutemov
@ 2019-10-22 15:23         ` Mike Rapoport
  1 sibling, 0 replies; 7+ messages in thread
From: Mike Rapoport @ 2019-10-22 15:23 UTC (permalink / raw)
  To: Vineet Gupta; +Cc: linux-mm, linux-snps-arc, linux-kernel, Kirill A . Shutemov

On Wed, Oct 09, 2019 at 11:57:31AM -0700, Vineet Gupta wrote:
> Add the intermediate p4d accessors to make it 5 level compliant.
> 
> This is a non-functional change anyways since ARC has software page walker
> with 2 lookup levels (pgd -> pte)
> 
> There is slight code bloat due to pulling in needless p*d_free_tlb()
> macros which needs to be addressed seperately.
> 
> | bloat-o-meter2 vmlinux-with-5LEVEL_HACK vmlinux-patched
> | add/remove: 0/0 grow/shrink: 2/0 up/down: 128/0 (128)
> | function                                     old     new   delta
> | free_pgd_range                               546     656    +110
> | p4d_clear_bad                                  2      20     +18
> | Total: Before=4137148, After=4137276, chg 0.000000%
> 
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

Acked-by: Mike Rapoport <rppt@linux.ibm.com>

> ---
> v3 <- v2
>   - fix highmem build error
> 
> v2 <- v1
>  - fix highmem code
> ---
>  arch/arc/include/asm/pgtable.h |  1 -
>  arch/arc/mm/fault.c            | 10 ++++++++--
>  arch/arc/mm/highmem.c          |  4 +++-
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
> index 976b5931372e..902d45428cea 100644
> --- a/arch/arc/include/asm/pgtable.h
> +++ b/arch/arc/include/asm/pgtable.h
> @@ -33,7 +33,6 @@
>  #define _ASM_ARC_PGTABLE_H
>  
>  #include <linux/bits.h>
> -#define __ARCH_USE_5LEVEL_HACK
>  #include <asm-generic/pgtable-nopmd.h>
>  #include <asm/page.h>
>  #include <asm/mmu.h>	/* to propagate CONFIG_ARC_MMU_VER <n> */
> diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
> index 3861543b66a0..fb86bc3e9b35 100644
> --- a/arch/arc/mm/fault.c
> +++ b/arch/arc/mm/fault.c
> @@ -30,6 +30,7 @@ noinline static int handle_kernel_vaddr_fault(unsigned long address)
>  	 * with the 'reference' page table.
>  	 */
>  	pgd_t *pgd, *pgd_k;
> +	p4d_t *p4d, *p4d_k;
>  	pud_t *pud, *pud_k;
>  	pmd_t *pmd, *pmd_k;
>  
> @@ -39,8 +40,13 @@ noinline static int handle_kernel_vaddr_fault(unsigned long address)
>  	if (!pgd_present(*pgd_k))
>  		goto bad_area;
>  
> -	pud = pud_offset(pgd, address);
> -	pud_k = pud_offset(pgd_k, address);
> +	p4d = p4d_offset(pgd, address);
> +	p4d_k = p4d_offset(pgd_k, address);
> +	if (!p4d_present(*p4d_k))
> +		goto bad_area;
> +
> +	pud = pud_offset(p4d, address);
> +	pud_k = pud_offset(p4d_k, address);
>  	if (!pud_present(*pud_k))
>  		goto bad_area;
>  
> diff --git a/arch/arc/mm/highmem.c b/arch/arc/mm/highmem.c
> index a4856bfaedf3..fc8849e4f72e 100644
> --- a/arch/arc/mm/highmem.c
> +++ b/arch/arc/mm/highmem.c
> @@ -111,12 +111,14 @@ EXPORT_SYMBOL(__kunmap_atomic);
>  static noinline pte_t * __init alloc_kmap_pgtable(unsigned long kvaddr)
>  {
>  	pgd_t *pgd_k;
> +	p4d_t *p4d_k;
>  	pud_t *pud_k;
>  	pmd_t *pmd_k;
>  	pte_t *pte_k;
>  
>  	pgd_k = pgd_offset_k(kvaddr);
> -	pud_k = pud_offset(pgd_k, kvaddr);
> +	p4d_k = p4d_offset(pgd_k, kvaddr);
> +	pud_k = pud_offset(p4d_k, kvaddr);
>  	pmd_k = pmd_offset(pud_k, kvaddr);
>  
>  	pte_k = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
> -- 
> 2.20.1
> 
> 

-- 
Sincerely yours,
Mike.


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08 21:38 [PATCH] ARC: mm: remove __ARCH_USE_5LEVEL_HACK Vineet.Gupta1
2019-10-08 23:42 ` kirill.shutemov
2019-10-09 18:38   ` vineetg76
2019-10-09 18:43     ` [PATCH v2] " Vineet.Gupta1
2019-10-09 18:57       ` [PATCH v3] " Vineet.Gupta1
2019-10-10  8:28         ` kirill.shutemov
2019-10-22 15:23         ` Mike Rapoport

Linux SNPS ARC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-snps-arc/0 linux-snps-arc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-snps-arc linux-snps-arc/ https://lore.kernel.org/linux-snps-arc \
		linux-snps-arc@lists.infradead.org
	public-inbox-index linux-snps-arc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-snps-arc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git