linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/vma: Append unlikely() while testing VMA access permissions
@ 2020-02-24  6:21 Anshuman Khandual
  2020-02-24 10:09 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Anshuman Khandual @ 2020-02-24  6:21 UTC (permalink / raw)
  To: linux-mm
  Cc: Anshuman Khandual, Guo Ren, Geert Uytterhoeven, Ralf Baechle,
	Paul Burton, Mike Rapoport, Andrew Morton, linux-m68k,
	linux-mips, linux-csky, linux-kernel

It is unlikely that an inaccessible VMA without required permission flags
will get a page fault. Hence lets just append unlikely() directive to such
checks in order to improve performance while also standardizing it across
various platforms.

Cc: Guo Ren <guoren@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@vger.kernel.org
Cc: linux-csky@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This patch applies on v5.6-rc3 along with the recent VMA series V2
(https://patchwork.kernel.org/cover/11399319/). This has only been
build tested for mips and m68k platforms.

 arch/csky/mm/fault.c | 2 +-
 arch/m68k/mm/fault.c | 2 +-
 arch/mips/mm/fault.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/csky/mm/fault.c b/arch/csky/mm/fault.c
index 4b3511b8298d..01caae98c350 100644
--- a/arch/csky/mm/fault.c
+++ b/arch/csky/mm/fault.c
@@ -137,7 +137,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
 		if (!(vma->vm_flags & VM_WRITE))
 			goto bad_area;
 	} else {
-		if (!vma_is_accessible(vma))
+		if (unlikely(!vma_is_accessible(vma)))
 			goto bad_area;
 	}
 
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index d5131ec5d923..d5dd75ed77f1 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -125,7 +125,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
 		case 1:		/* read, present */
 			goto acc_err;
 		case 0:		/* read, not present */
-			if (!vma_is_accessible(vma))
+			if (unlikely(!vma_is_accessible(vma)))
 				goto acc_err;
 	}
 
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 5b9f947bfa32..db4b51a40c58 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -142,7 +142,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,
 				goto bad_area;
 			}
 		} else {
-			if (!vma_is_accessible(vma))
+			if (unlikely(!vma_is_accessible(vma)))
 				goto bad_area;
 		}
 	}
-- 
2.20.1


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

* Re: [PATCH] mm/vma: Append unlikely() while testing VMA access permissions
  2020-02-24  6:21 [PATCH] mm/vma: Append unlikely() while testing VMA access permissions Anshuman Khandual
@ 2020-02-24 10:09 ` Geert Uytterhoeven
  2020-02-24 13:19   ` Anshuman Khandual
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2020-02-24 10:09 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: Linux MM, Guo Ren, Ralf Baechle, Paul Burton, Mike Rapoport,
	Andrew Morton, linux-m68k, linux-mips, linux-csky,
	Linux Kernel Mailing List

Hi Anshuman,

Thanks for your patch!

On Mon, Feb 24, 2020 at 7:22 AM Anshuman Khandual
<anshuman.khandual@arm.com> wrote:
> It is unlikely that an inaccessible VMA without required permission flags
> will get a page fault. Hence lets just append unlikely() directive to such

Why? Isn't it the idea that you get a page fault when the page is not
accessible?

> checks in order to improve performance while also standardizing it across
> various platforms.

Does it make a difference to add these? Have you benchmarked this?
https://lwn.net/Articles/420019/

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] mm/vma: Append unlikely() while testing VMA access permissions
  2020-02-24 10:09 ` Geert Uytterhoeven
@ 2020-02-24 13:19   ` Anshuman Khandual
  0 siblings, 0 replies; 3+ messages in thread
From: Anshuman Khandual @ 2020-02-24 13:19 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linux MM, Guo Ren, Ralf Baechle, Paul Burton, Mike Rapoport,
	Andrew Morton, linux-m68k, linux-mips, linux-csky,
	Linux Kernel Mailing List


On 02/24/2020 03:39 PM, Geert Uytterhoeven wrote:
> Hi Anshuman,
> 
> Thanks for your patch!
> 
> On Mon, Feb 24, 2020 at 7:22 AM Anshuman Khandual
> <anshuman.khandual@arm.com> wrote:
>> It is unlikely that an inaccessible VMA without required permission flags
>> will get a page fault. Hence lets just append unlikely() directive to such
> 
> Why? Isn't it the idea that you get a page fault when the page is not
> accessible?

Yeah it is. But the point here is to have a directive indicating that it is
unlikely that such scenarios will exist frequently even though they are very
much possible.

> 
>> checks in order to improve performance while also standardizing it across
>> various platforms.
> 
> Does it make a difference to add these? Have you benchmarked this?
> https://lwn.net/Articles/420019/

I dont have access to these platforms. As I had noted down previously, this
was only build tested. The primary motivation was that the likeliness or
rather unlikeliness for page faults on inaccessible VMAs are more workload
specific. Hence should not be platform dependent and this change was just
trying to make it similar in some platforms.

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
> 

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

end of thread, other threads:[~2020-02-24 13:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24  6:21 [PATCH] mm/vma: Append unlikely() while testing VMA access permissions Anshuman Khandual
2020-02-24 10:09 ` Geert Uytterhoeven
2020-02-24 13:19   ` Anshuman Khandual

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).