Re: [PATCH UPDATE] x86: ignore spurious faults
From: Jeremy Fitzhardinge
Date: Fri Jan 25 2008 - 13:39:44 EST
Ingo Molnar wrote:
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 ;-)
Well, I guess this isn't really specific to x86; we could always
legitimately not do a tlb flush after increasing permissions and leave
the fault handler to clean up the mess where needed. But I don't think
that's necessarily much of a win; it's cheaper to just do the tlb flush
rather than take a spurious fault, unless the faults are very rare. If
someone is doing an mprotect on a piece of memory (esp to make it
writable), my guess is that they're going to touch that memory in the
very near future.
The big win for this patch is avoiding cross-cpu tlb invalidation when
changing kernel mappings. mprotect doesn't attempt to do that anyway,
and so can incur spurious faults on other CPUs.
J
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/