Messages in this thread | | | Date | Thu, 17 Oct 2013 11:26:23 -0700 | Subject | Re: [PATCH] perf, x86: Optimize intel_pmu_pebs_fixup_ip() | From | Linus Torvalds <> |
| |
On Thu, Oct 17, 2013 at 9:30 AM, Peter Zijlstra <peterz@infradead.org> wrote: > > So avoid having to call copy_from_user_nmi() for every instruction. > Since we already limit the max basic block size, we can easily > pre-allocate a piece of memory to copy the entire thing into in one > go.
copy_from_user_nmi() itself is all kinds of nasty.
Using __get_user_pages_fast() for a single page is quite expensive, and mucks around with the page counts etc.
If copy_from_user_nmi() just did the (simple) page table walk by hand, it could avoid *all* of that. No page count stuff - just have interrupts disabled over not just the page walk, but the copy too - to guarantee that no cross-CPU TLB flush can come in.
So instead of trying to improve __get_user_pages_fast() - which is impossible because the interface fundamentally means that it has to iterate over things and check page counts - you could simplify the caller instead.
That is, if we really care any more. Maybe this "do the copy_from_user_nmi() just once" is already good enough that nobody much cares.
Linus
| |