[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090414151924.C653.A69D9226@jp.fujitsu.com>
Date: Tue, 14 Apr 2009 15:20:20 +0900 (JST)
From: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
To: LKML <linux-kernel@...r.kernel.org>,
Zach Brown <zach.brown@...cle.com>,
Jens Axboe <jens.axboe@...cle.com>, linux-api@...r.kernel.org
Cc: kosaki.motohiro@...fujitsu.com, Linus Torvalds <torvalds@...l.org>,
Andrew Morton <akpm@...l.org>,
Nick Piggin <nickpiggin@...oo.com.au>,
Andrea Arcangeli <aarcange@...hat.com>,
Jeff Moyer <jmoyer@...hat.com>, linux-mm@...ck.org,
linux-fsdevel@...r.kernel.org
Subject: [RFC][PATCH v3 4/6] aio: Don't inherit aio ring memory at fork
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.
In addition, This patch has good side effect. it also fix "get_user_pages() vs fork" problem.
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.
Cc: Jeff Moyer <jmoyer@...hat.com>
Cc: Zach Brown <zach.brown@...cle.com>
Cc: Jens Axboe <jens.axboe@...cle.com>
Cc: linux-fsdevel@...r.kernel.org
Cc: linux-api@...r.kernel.org,
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
---
fs/aio.c | 8 ++++++++
1 file changed, 8 insertions(+)
Index: b/fs/aio.c
===================================================================
--- a/fs/aio.c 2009-04-12 23:33:59.000000000 +0900
+++ b/fs/aio.c 2009-04-13 02:56:05.000000000 +0900
@@ -106,6 +106,7 @@ static int aio_setup_ring(struct kioctx
unsigned nr_events = ctx->max_reqs;
unsigned long size;
int nr_pages;
+ int ret;
/* Compensate for the ring buffer's head/tail overlap entry */
nr_events += 2; /* 1 is required, 2 for good luck */
@@ -140,6 +141,13 @@ static int aio_setup_ring(struct kioctx
return -EAGAIN;
}
+ /*
+ * aio context doesn't inherit while fork. (see mm_init())
+ * Then, aio ring also mark DONTFORK.
+ */
+ ret = sys_madvise(info->mmap_base, info->mmap_size, MADV_DONTFORK);
+ BUG_ON(ret);
+
dprintk("mmap address: 0x%08lx\n", info->mmap_base);
info->nr_pages = get_user_pages(current, ctx->mm,
info->mmap_base, nr_pages,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists