Re: [PATCH UPDATE] x86: ignore spurious faults

Ingo Molnar
2008-01-25T18:09:10Z

* Jeremy Fitzhardinge <jeremy@goop.org> wrote:

> Ingo Molnar wrote:
>> thanks, applied.
>>
>> it would be nice to expose this ability of the architecture to the core
>> Linux kernel mprotect code as well, and let it skip on a TLB flush when
>> doing a RO->RW transition.
>
> The usermode fault handler already effectively does this; this patch
> just does it for kernel mode as well. I don't know if mprotect takes
> advantage of this.

spurious faults happen all the time on SMP, in the native kernel.

And what i mean is that Linux mprotect currently does not take advantage
of x86's ability to just change the ptes, because there's no structured
way to tell mm/mprotect.c that "it's safe to skip the TLB flush here".

The flush happens in mm/mprotect.c's change_protection() function:

flush_tlb_range(vma, start, end);

and that is unnecessary when we increase the protection rights, such as
in a RO->RW change. (all that is needed is an smp_wmb() instead, to make
sure all the pte modifications are visible when the syscall returns.)

and it's a really rare case these days that you can find an area where
Linux does not make use of a hardware MMU feature - so we should fix
this ;-)

Ingo