All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use flush tlb last level when change protection
@ 2019-02-23  6:47 ` Xuefeng Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Xuefeng Wang @ 2019-02-23  6:47 UTC (permalink / raw)
  To: catalin.marinas, will.deacon, linux-arm-kernel, linux-kernel
  Cc: wxf.wang, guohanjun

The protection attributes are only kept in last level tlb, so
protection changing only need invalidate last level tlb, exclude
the PWC entries.

Signed-off-by: Xuefeng Wang <wxf.wang@hisilicon.com>
---
 mm/mprotect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index 36cb358..0c4303d 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -287,7 +287,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma,
 
 	/* Only flush the TLB if we actually modified any entries: */
 	if (pages)
-		flush_tlb_range(vma, start, end);
+		__flush_tlb_range(vma, start, end, PAGE_SIZE, true);
 	dec_tlb_flush_pending(mm);
 
 	return pages;
-- 
1.7.12.4


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

* [PATCH] Use flush tlb last level when change protection
@ 2019-02-23  6:47 ` Xuefeng Wang
  0 siblings, 0 replies; 8+ messages in thread
From: Xuefeng Wang @ 2019-02-23  6:47 UTC (permalink / raw)
  To: catalin.marinas, will.deacon, linux-arm-kernel, linux-kernel
  Cc: guohanjun, wxf.wang

The protection attributes are only kept in last level tlb, so
protection changing only need invalidate last level tlb, exclude
the PWC entries.

Signed-off-by: Xuefeng Wang <wxf.wang@hisilicon.com>
---
 mm/mprotect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index 36cb358..0c4303d 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -287,7 +287,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma,
 
 	/* Only flush the TLB if we actually modified any entries: */
 	if (pages)
-		flush_tlb_range(vma, start, end);
+		__flush_tlb_range(vma, start, end, PAGE_SIZE, true);
 	dec_tlb_flush_pending(mm);
 
 	return pages;
-- 
1.7.12.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] Use flush tlb last level when change protection
  2019-02-23  6:47 ` Xuefeng Wang
@ 2019-02-24 11:08   ` Catalin Marinas
  -1 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2019-02-24 11:08 UTC (permalink / raw)
  To: Xuefeng Wang; +Cc: will.deacon, linux-arm-kernel, linux-kernel, guohanjun

On Sat, Feb 23, 2019 at 02:47:27PM +0800, Xuefeng Wang wrote:
> The protection attributes are only kept in last level tlb, so
> protection changing only need invalidate last level tlb, exclude
> the PWC entries.
> 
> Signed-off-by: Xuefeng Wang <wxf.wang@hisilicon.com>
> ---
>  mm/mprotect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index 36cb358..0c4303d 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -287,7 +287,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma,
>  
>  	/* Only flush the TLB if we actually modified any entries: */
>  	if (pages)
> -		flush_tlb_range(vma, start, end);
> +		__flush_tlb_range(vma, start, end, PAGE_SIZE, true);
>  	dec_tlb_flush_pending(mm);

You are changing a generic file to call an arm64-internal function,
breaking all the other architectures, so NAK.

Do you actually see any performance improvement?

-- 
Catalin

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

* Re: [PATCH] Use flush tlb last level when change protection
@ 2019-02-24 11:08   ` Catalin Marinas
  0 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2019-02-24 11:08 UTC (permalink / raw)
  To: Xuefeng Wang; +Cc: will.deacon, linux-kernel, linux-arm-kernel, guohanjun

On Sat, Feb 23, 2019 at 02:47:27PM +0800, Xuefeng Wang wrote:
> The protection attributes are only kept in last level tlb, so
> protection changing only need invalidate last level tlb, exclude
> the PWC entries.
> 
> Signed-off-by: Xuefeng Wang <wxf.wang@hisilicon.com>
> ---
>  mm/mprotect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index 36cb358..0c4303d 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -287,7 +287,7 @@ static unsigned long change_protection_range(struct vm_area_struct *vma,
>  
>  	/* Only flush the TLB if we actually modified any entries: */
>  	if (pages)
> -		flush_tlb_range(vma, start, end);
> +		__flush_tlb_range(vma, start, end, PAGE_SIZE, true);
>  	dec_tlb_flush_pending(mm);

You are changing a generic file to call an arm64-internal function,
breaking all the other architectures, so NAK.

Do you actually see any performance improvement?

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] Use flush tlb last level when change protection
  2019-02-23  6:47 ` Xuefeng Wang
@ 2019-02-25 14:38   ` kbuild test robot
  -1 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2019-02-25 14:38 UTC (permalink / raw)
  To: Xuefeng Wang
  Cc: kbuild-all, catalin.marinas, will.deacon, linux-arm-kernel,
	linux-kernel, wxf.wang, guohanjun

[-- Attachment #1: Type: text/plain, Size: 2202 bytes --]

Hi Xuefeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc8 next-20190225]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Xuefeng-Wang/Use-flush-tlb-last-level-when-change-protection/20190225-214747
config: x86_64-randconfig-x017-201908 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-21) 8.2.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   mm/mprotect.c: In function 'change_protection_range':
>> mm/mprotect.c:290:3: error: implicit declaration of function '__flush_tlb_range'; did you mean 'flush_tlb_range'? [-Werror=implicit-function-declaration]
      __flush_tlb_range(vma, start, end, PAGE_SIZE, true);
      ^~~~~~~~~~~~~~~~~
      flush_tlb_range
   cc1: some warnings being treated as errors

vim +290 mm/mprotect.c

   265	
   266	static unsigned long change_protection_range(struct vm_area_struct *vma,
   267			unsigned long addr, unsigned long end, pgprot_t newprot,
   268			int dirty_accountable, int prot_numa)
   269	{
   270		struct mm_struct *mm = vma->vm_mm;
   271		pgd_t *pgd;
   272		unsigned long next;
   273		unsigned long start = addr;
   274		unsigned long pages = 0;
   275	
   276		BUG_ON(addr >= end);
   277		pgd = pgd_offset(mm, addr);
   278		flush_cache_range(vma, addr, end);
   279		inc_tlb_flush_pending(mm);
   280		do {
   281			next = pgd_addr_end(addr, end);
   282			if (pgd_none_or_clear_bad(pgd))
   283				continue;
   284			pages += change_p4d_range(vma, pgd, addr, next, newprot,
   285					 dirty_accountable, prot_numa);
   286		} while (pgd++, addr = next, addr != end);
   287	
   288		/* Only flush the TLB if we actually modified any entries: */
   289		if (pages)
 > 290			__flush_tlb_range(vma, start, end, PAGE_SIZE, true);
   291		dec_tlb_flush_pending(mm);
   292	
   293		return pages;
   294	}
   295	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30091 bytes --]

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

* Re: [PATCH] Use flush tlb last level when change protection
@ 2019-02-25 14:38   ` kbuild test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2019-02-25 14:38 UTC (permalink / raw)
  To: Xuefeng Wang
  Cc: wxf.wang, catalin.marinas, will.deacon, linux-kernel, kbuild-all,
	guohanjun, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 2202 bytes --]

Hi Xuefeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc8 next-20190225]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Xuefeng-Wang/Use-flush-tlb-last-level-when-change-protection/20190225-214747
config: x86_64-randconfig-x017-201908 (attached as .config)
compiler: gcc-8 (Debian 8.2.0-21) 8.2.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   mm/mprotect.c: In function 'change_protection_range':
>> mm/mprotect.c:290:3: error: implicit declaration of function '__flush_tlb_range'; did you mean 'flush_tlb_range'? [-Werror=implicit-function-declaration]
      __flush_tlb_range(vma, start, end, PAGE_SIZE, true);
      ^~~~~~~~~~~~~~~~~
      flush_tlb_range
   cc1: some warnings being treated as errors

vim +290 mm/mprotect.c

   265	
   266	static unsigned long change_protection_range(struct vm_area_struct *vma,
   267			unsigned long addr, unsigned long end, pgprot_t newprot,
   268			int dirty_accountable, int prot_numa)
   269	{
   270		struct mm_struct *mm = vma->vm_mm;
   271		pgd_t *pgd;
   272		unsigned long next;
   273		unsigned long start = addr;
   274		unsigned long pages = 0;
   275	
   276		BUG_ON(addr >= end);
   277		pgd = pgd_offset(mm, addr);
   278		flush_cache_range(vma, addr, end);
   279		inc_tlb_flush_pending(mm);
   280		do {
   281			next = pgd_addr_end(addr, end);
   282			if (pgd_none_or_clear_bad(pgd))
   283				continue;
   284			pages += change_p4d_range(vma, pgd, addr, next, newprot,
   285					 dirty_accountable, prot_numa);
   286		} while (pgd++, addr = next, addr != end);
   287	
   288		/* Only flush the TLB if we actually modified any entries: */
   289		if (pages)
 > 290			__flush_tlb_range(vma, start, end, PAGE_SIZE, true);
   291		dec_tlb_flush_pending(mm);
   292	
   293		return pages;
   294	}
   295	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30091 bytes --]

[-- Attachment #3: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] Use flush tlb last level when change protection
  2019-02-23  6:47 ` Xuefeng Wang
@ 2019-02-25 15:02   ` kbuild test robot
  -1 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2019-02-25 15:02 UTC (permalink / raw)
  To: Xuefeng Wang
  Cc: kbuild-all, catalin.marinas, will.deacon, linux-arm-kernel,
	linux-kernel, wxf.wang, guohanjun

[-- Attachment #1: Type: text/plain, Size: 2376 bytes --]

Hi Xuefeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc8 next-20190225]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Xuefeng-Wang/Use-flush-tlb-last-level-when-change-protection/20190225-214747
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.2.0 make.cross ARCH=sparc64 

All errors (new ones prefixed by >>):

   mm/mprotect.c: In function 'change_protection_range':
>> mm/mprotect.c:290:3: error: implicit declaration of function '__flush_tlb_range'; did you mean '__flush_tlb_page'? [-Werror=implicit-function-declaration]
      __flush_tlb_range(vma, start, end, PAGE_SIZE, true);
      ^~~~~~~~~~~~~~~~~
      __flush_tlb_page
   cc1: some warnings being treated as errors

vim +290 mm/mprotect.c

   265	
   266	static unsigned long change_protection_range(struct vm_area_struct *vma,
   267			unsigned long addr, unsigned long end, pgprot_t newprot,
   268			int dirty_accountable, int prot_numa)
   269	{
   270		struct mm_struct *mm = vma->vm_mm;
   271		pgd_t *pgd;
   272		unsigned long next;
   273		unsigned long start = addr;
   274		unsigned long pages = 0;
   275	
   276		BUG_ON(addr >= end);
   277		pgd = pgd_offset(mm, addr);
   278		flush_cache_range(vma, addr, end);
   279		inc_tlb_flush_pending(mm);
   280		do {
   281			next = pgd_addr_end(addr, end);
   282			if (pgd_none_or_clear_bad(pgd))
   283				continue;
   284			pages += change_p4d_range(vma, pgd, addr, next, newprot,
   285					 dirty_accountable, prot_numa);
   286		} while (pgd++, addr = next, addr != end);
   287	
   288		/* Only flush the TLB if we actually modified any entries: */
   289		if (pages)
 > 290			__flush_tlb_range(vma, start, end, PAGE_SIZE, true);
   291		dec_tlb_flush_pending(mm);
   292	
   293		return pages;
   294	}
   295	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 56427 bytes --]

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

* Re: [PATCH] Use flush tlb last level when change protection
@ 2019-02-25 15:02   ` kbuild test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2019-02-25 15:02 UTC (permalink / raw)
  To: Xuefeng Wang
  Cc: wxf.wang, catalin.marinas, will.deacon, linux-kernel, kbuild-all,
	guohanjun, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 2376 bytes --]

Hi Xuefeng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.0-rc8 next-20190225]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Xuefeng-Wang/Use-flush-tlb-last-level-when-change-protection/20190225-214747
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.2.0 make.cross ARCH=sparc64 

All errors (new ones prefixed by >>):

   mm/mprotect.c: In function 'change_protection_range':
>> mm/mprotect.c:290:3: error: implicit declaration of function '__flush_tlb_range'; did you mean '__flush_tlb_page'? [-Werror=implicit-function-declaration]
      __flush_tlb_range(vma, start, end, PAGE_SIZE, true);
      ^~~~~~~~~~~~~~~~~
      __flush_tlb_page
   cc1: some warnings being treated as errors

vim +290 mm/mprotect.c

   265	
   266	static unsigned long change_protection_range(struct vm_area_struct *vma,
   267			unsigned long addr, unsigned long end, pgprot_t newprot,
   268			int dirty_accountable, int prot_numa)
   269	{
   270		struct mm_struct *mm = vma->vm_mm;
   271		pgd_t *pgd;
   272		unsigned long next;
   273		unsigned long start = addr;
   274		unsigned long pages = 0;
   275	
   276		BUG_ON(addr >= end);
   277		pgd = pgd_offset(mm, addr);
   278		flush_cache_range(vma, addr, end);
   279		inc_tlb_flush_pending(mm);
   280		do {
   281			next = pgd_addr_end(addr, end);
   282			if (pgd_none_or_clear_bad(pgd))
   283				continue;
   284			pages += change_p4d_range(vma, pgd, addr, next, newprot,
   285					 dirty_accountable, prot_numa);
   286		} while (pgd++, addr = next, addr != end);
   287	
   288		/* Only flush the TLB if we actually modified any entries: */
   289		if (pages)
 > 290			__flush_tlb_range(vma, start, end, PAGE_SIZE, true);
   291		dec_tlb_flush_pending(mm);
   292	
   293		return pages;
   294	}
   295	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 56427 bytes --]

[-- Attachment #3: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-02-25 15:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-23  6:47 [PATCH] Use flush tlb last level when change protection Xuefeng Wang
2019-02-23  6:47 ` Xuefeng Wang
2019-02-24 11:08 ` Catalin Marinas
2019-02-24 11:08   ` Catalin Marinas
2019-02-25 14:38 ` kbuild test robot
2019-02-25 14:38   ` kbuild test robot
2019-02-25 15:02 ` kbuild test robot
2019-02-25 15:02   ` kbuild test robot

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.