mm/vma: Append unlikely() while testing VMA access permissions
Subsystems (4)
PATCH 1/1 mm/vma: Append unlikely() while testing VMA access permissions
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.
---
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(-)
arch/csky/mm/fault.c +1 -1
@@ -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; }
arch/m68k/mm/fault.c +1 -1
@@ -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; }
arch/mips/mm/fault.c +1 -1
@@ -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; } }
Signature · 1 line
2.20.1
Geert Uytterhoeven
maintainerHi Anshuman,
Thanks for your patch!
Quoted 2 lines · Anshuman Khandual
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?
Quoted 2 lines
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 -- [email protected]
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
Quoted 11 lines · Geert Uytterhoeven
Hi Anshuman,
Thanks for your patch!
Quoted 2 lines · Anshuman Khandual
It is unlikely that an inaccessible VMA without required permission flags will get a page fault. Hence lets just append
unlikely()directive to suchWhy? 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.
Quoted 6 lines
Quoted 3 lines
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.
Quoted 13 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]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