Re: [patch 6/12] hold atomic kmaps across generic_file_read

Andrew Morton
2002-08-10T05:58:55Z

Linus Torvalds wrote:
>
> ...
> > We'll need need to manually fault in the user page on the
> > generic_file_read() path before taking the kmap, because reading
> > into an unmapped page is a common case: malloc/read.
>
> I actually suspect that most reads are fairly small, and the page already
> exists. But who knows.. pre-loading is certainly easy (a single
> instruction).

These things can be measured ;)

Across a `make -j6 bzImage' the kernel reads 166,000 pages via
file_read_actor(). And 31,000 of those generated a fault in
the copy_*_user. (It wrote 14,400 pages and, of course, none
of those faulted).

And if gcc is getting a fault 20% of the time, some other apps will
get many more. Which implies that we must prefault the page in
file_read_actor to get full benefit.

And if we do that, I'll bet you Victor's dollar that the fixup path
is never executed. I'd have to disable the prefault even to be able
to test it.

What would be nice is a way of formalising the prefault, to pin
the mm's pages across the copy_*_user() in some manner, perhaps?