Re: [PATCH 4/6] ftrace, x86: make kernel text writable only for conversions

Andi Kleen
2009-02-23T00:11:27Z

> We are changing over 19000 locations in the kernel. This touches almost
> all kernel text pages anyway. You want to map a page in and out for over
> 19000 locations?

Well kernel size / PAGE_SIZE times if you sort locations first and
take a last-hit cache. Or if you want to overoptimize you can
also use 2MB pages when available. Also it can be done much cheaper
than a full flush because it doesn't need to be global over all CPUs
(assuming you disable preempt, which you probably do anyways)
And it can use INVLPG on x86 (or similar directed flushed)
which is much much cheaper than blowing everything away.

I'm not sure which one would be faster, but I suspect the difference
will not be very large. And not changing the kernel has the
advantage that there is no window where it is unprotected.

-Andi

--
ak@linux.intel.com -- Speaking for myself only.