From: Andrew Morton <akpm@digeo.com>
To: Hirokazu Takahashi <taka@valinux.co.jp>
Cc: linux-kernel@vger.kernel.org, janetmor@us.ibm.com
Subject: Re: [patch] readv/writev rework
Date: Fri, 13 Sep 2002 01:29:52 -0700 [thread overview]
Message-ID: <3D81A200.C1B6A293@digeo.com> (raw)
In-Reply-To: 20020913.162252.56050784.taka@valinux.co.jp
Hirokazu Takahashi wrote:
>
> Hello,
>
> I updated the writev patch which may be easy to understand.
> How about it?
Looks nice. And yes, you hung onto the atomic kmap across multiple
iov segments ;) That will save a tlb invalidate per segment.
> But I have one question, Could let me know if you have any idea,
> why does filemap_copy_from_user() try to call kamp()+__copy_from_user()
> again after the first trial get fault.
>
> Is there any meanings?
We're not allowed to schedule away inside atomic_kmap - must remain
in the same task, on the same CPU etc. So the pagefault handler
will return immediately if we take a pagefault while copying to/from
userspace while holding an atomic kmap.
So the code first touches the userspace page (via __get_user) to
fault it in. Now, there is a 99.999999% chance that the copy_*_user()
will not fault - it will remain wholly atomic.
But there is the 0.0000001% chance that the VM will evict (or at least
unmap) the page between the __get_user() and the completion of the
copy_*_user(). In this case, copy_*_user() will fail and will return
a short copy.
Now, we could just touch the page with another __get_user() and retry
the atomic kmap approach. But I flipped a coin and decided to fall back
to a regular sleeping kmap instead. With a sleeping kmap, in a
non-atomic region the kernel will actually take the fault, fix it up
and the copy_*_user() will work OK.
> ...
> --- linux/mm/filemap.c.ORG Wed Sep 11 19:48:00 2030
> +++ linux/mm/filemap.c Fri Sep 13 16:08:51 2030
I shall retest...
next prev parent reply other threads:[~2002-09-13 8:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-11 8:30 [patch] readv/writev rework Andrew Morton
2002-09-12 13:00 ` Hirokazu Takahashi
2002-09-12 18:47 ` Andrew Morton
2002-09-13 1:18 ` Hirokazu Takahashi
2002-09-13 3:31 ` Andrew Morton
2002-09-14 4:54 ` Andrew Morton
2002-09-14 7:39 ` Hirokazu Takahashi
2002-09-13 7:22 ` Hirokazu Takahashi
2002-09-13 8:29 ` Andrew Morton [this message]
2002-09-13 8:26 ` Hirokazu Takahashi
2002-09-13 9:23 ` Hirokazu Takahashi
2002-09-13 17:43 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D81A200.C1B6A293@digeo.com \
--to=akpm@digeo.com \
--cc=janetmor@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=taka@valinux.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox