From: Jeff Moyer <jmoyer@redhat.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Zach Brown <zach.brown@oracle.com>,
Jens Axboe <jens.axboe@oracle.com>,
linux-api@vger.kernel.org, Linus Torvalds <torvalds@osdl.org>,
Andrew Morton <akpm@osdl.org>,
Nick Piggin <nickpiggin@yahoo.com.au>,
Andrea Arcangeli <aarcange@redhat.com>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: Re: [RFC][PATCH v3 4/6] aio: Don't inherit aio ring memory at fork
Date: Tue, 14 Apr 2009 22:44:03 -0400 [thread overview]
Message-ID: <x49tz4qiqks.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <20090415091534.AC18.A69D9226@jp.fujitsu.com> (KOSAKI Motohiro's message of "Wed, 15 Apr 2009 09:56:34 +0900 (JST)")
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> writes:
> Hi!
>
>> KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> writes:
>>
>> > AIO folks, Am I missing anything?
>> >
>> > ===============
>> > Subject: [RFC][PATCH] aio: Don't inherit aio ring memory at fork
>> >
>> > Currently, mm_struct::ioctx_list member isn't copyed at fork. IOW aio context don't inherit at fork.
>> > but only ring memory inherited. that's strange.
>> >
>> > This patch mark DONTFORK to ring-memory too.
>>
>> Well, given that clearly nobody relies on io contexts being copied to
>> the child, I think it's okay to make this change. I think the current
>> behaviour violates the principal of least surprise, but I'm having a
>> hard time getting upset about that. ;)
>
> ok.
> So, Can I get your Acked-by?
I have more comments below.
>> > In addition, This patch has good side effect. it also fix
>> > "get_user_pages() vs fork" problem.
>>
>> Hmm, I don't follow you, here. As I understand it, the get_user_pages
>> vs. fork problem has to do with the pages used for the actual I/O, not
>> the pages used to store the completion data. So, could you elaborate a
>> bit on what you mean by the above statement?
>
> No.
>
> The problem is, get_user_pages() increment page_count only.
> but VM page-fault logic don't care page_count. (it only care page::_mapcount)
> Then, fork and pagefault can change virtual-physical relationship although
> get_user_pages() is called.
>
> drawback worst aio scenario here
> -----------------------------------------------------------------------
> io_setup() and gup inc page_count
>
> fork inc mapcount
> and make write-protect to pte
>
> write ring from userland(*) page fault and
> COW break.
> parent process get copyed page and
> child get original page owner-ship.
>
> kmap and memcpy from kernel change child page. (it mean data lost)
>
> (*) Is this happend?
I guess it's possible, but I don't know of any programs that do this.
> MADV_DONTFORK or down_read(mmap_sem) or down_read(mm_pinned_sem)
> or copy-at-fork mecanism(=Nick/Andrea patch) solve it.
OK, thanks for the explanation.
+ /*
+ * aio context doesn't inherit while fork. (see mm_init())
+ * Then, aio ring also mark DONTFORK.
+ */
Would you mind if I did some word-smithing on that comment? Something
like:
/*
* The io_context is not inherited by the child after fork()
* (see mm_init). Therefore, it makes little sense for the
* completion ring to be inherited.
*/
+ ret = sys_madvise(info->mmap_base, info->mmap_size, MADV_DONTFORK);
+ BUG_ON(ret);
+
It appears there's no other way to set the VM_DONTCOPY flag, so I guess
calling sys_madvise is fine. I'm not sure I agree with the BUG_ON(ret),
however, as EAGAIN may be feasible.
So, fix that up and you can add my reviewed-by. I think you should push
this patch independent of the other patches in this series.
>> > I think "man fork" also sould be changed. it only say
>> >
>> > * The child does not inherit outstanding asynchronous I/O operations from
>> > its parent (aio_read(3), aio_write(3)).
>> > but aio_context_t (return value of io_setup(2)) also don't inherit in current implementaion.
>>
>> I can certainly make that change, as I have other changes I need to push
>> to Michael, anyway.
>
> thanks.
No problem. As you know, I've already sent a patch for this.
Cheers,
Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-04-15 2:44 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090414151204.C647.A69D9226@jp.fujitsu.com>
2009-04-14 6:16 ` [RFC][PATCH v3 1/6] mm: Don't unmap gup()ed page KOSAKI Motohiro
2009-04-14 9:25 ` Nick Piggin
2009-04-14 12:02 ` KOSAKI Motohiro
2009-04-14 12:25 ` Nick Piggin
2009-04-14 13:39 ` KOSAKI Motohiro
2009-04-14 14:12 ` Andrea Arcangeli
2009-04-14 14:26 ` Nick Piggin
2009-04-14 14:32 ` Andrea Arcangeli
2009-04-14 14:42 ` Nick Piggin
2009-04-14 15:21 ` Andrea Arcangeli
2009-04-15 8:05 ` KOSAKI Motohiro
2009-04-15 8:22 ` Nick Piggin
2009-04-15 9:22 ` Nick Piggin
2009-04-15 10:46 ` Andrea Arcangeli
2009-04-15 11:39 ` KOSAKI Motohiro
2009-04-15 11:41 ` Andrea Arcangeli
2009-04-15 11:53 ` KOSAKI Motohiro
2009-04-19 12:37 ` KOSAKI Motohiro
2009-04-14 14:38 ` Andrea Arcangeli
2009-04-14 6:18 ` [RFC][PATCH v3 2/6] mm, directio: fix fork vs direct-io race (read(2) side IOW gup(write) side) KOSAKI Motohiro
2009-04-14 6:25 ` KOSAKI Motohiro
2009-04-14 16:45 ` Jeff Moyer
2009-04-14 17:51 ` Andrea Arcangeli
2009-04-14 18:10 ` Jeff Moyer
2009-04-14 19:48 ` Andrea Arcangeli
2009-04-14 6:19 ` [RFC][PATCH v3 3/6] nfs, direct-io: fix fork vs direct-io race on nfs KOSAKI Motohiro
2009-04-14 16:48 ` Jeff Moyer
2009-04-14 6:20 ` [RFC][PATCH v3 4/6] aio: Don't inherit aio ring memory at fork KOSAKI Motohiro
2009-04-14 13:41 ` Andrea Arcangeli
2009-04-14 16:01 ` Jeff Moyer
2009-04-15 0:56 ` KOSAKI Motohiro
2009-04-15 2:44 ` Jeff Moyer [this message]
2009-04-15 3:00 ` KOSAKI Motohiro
2009-04-14 6:21 ` [RFC][PATCH v3 5/6] don't use bio-map in read() path KOSAKI Motohiro
2009-04-14 6:23 ` [RFC][PATCH v3 6/6] fix wrong get_user_pages usage in iovlock.c KOSAKI Motohiro
2009-04-14 6:56 ` Nick Piggin
2009-04-14 6:58 ` KOSAKI Motohiro
2009-04-15 8:48 ` KOSAKI Motohiro
2009-04-17 15:07 ` Sosnowski, Maciej
2009-04-19 12:37 ` KOSAKI Motohiro
2009-04-23 12:48 ` Sosnowski, Maciej
2009-04-14 8:41 ` [RFC][PATCH 0/6] IO pinning(get_user_pages()) vs fork race fix Nick Piggin
2009-04-14 9:19 ` KOSAKI Motohiro
2009-04-14 9:37 ` Nick Piggin
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=x49tz4qiqks.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=aarcange@redhat.com \
--cc=akpm@osdl.org \
--cc=jens.axboe@oracle.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nickpiggin@yahoo.com.au \
--cc=torvalds@osdl.org \
--cc=zach.brown@oracle.com \
/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;
as well as URLs for NNTP newsgroup(s).