All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 0/6] IO pinning(get_user_pages()) vs fork race fix
@ 2009-04-14  6:15 ` KOSAKI Motohiro
  0 siblings, 0 replies; 93+ messages in thread
From: KOSAKI Motohiro @ 2009-04-14  6:15 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton, Nick Piggin, Andrea Arcangeli,
	Jeff Moyer, linux-mm, linux-fsdevel, LKML
  Cc: kosaki.motohiro


Linux Device Drivers, Third Edition, Chapter 15: Memory Mapping and DMA says

	get_user_pages is a low-level memory management function, with a suitably complex
	interface. It also requires that the mmap reader/writer semaphore for the address
	space be obtained in read mode before the call. As a result, calls to get_user_pages
	usually look something like:

		down_read(&current->mm->mmap_sem);
		result = get_user_pages(current, current->mm, ...);
		up_read(&current->mm->mmap_sem);

	The return value is the number of pages actually mapped, which could be fewer than
	the number requested (but greater than zero).

but, it isn't true. mmap_sem isn't only used for vma traversal, but also prevent vs-fork race.
up_read(mmap_sem) mean end of critical section, IOW after up_read() code is fork unsafe.
(access_process_vm() explain proper get_user_pages() usage)

Oh well, We have many wrong caller now. What is the best fix method?

Nick Piggin and Andrea Arcangeli proposed to change get_user_pages() semantics as caller expected.
  see "[PATCH] fork vs gup(-fast) fix" thead in linux-mm
but Linus NACKed it.

Thus I made caller change approach patch series. it is made for discuss to compare Nick's approach.
I don't hope submit it yet.

Nick, This version fixed vmsplice and aio issue (you pointed). I hope to hear your opiniton ;)



ChangeLog:
  V2 -> V3
   o remove early decow logic
   o introduce prevent unmap logic
   o fix nfs-directio
   o fix aio
   o fix bio (only bandaid fix)

  V1 -> V2
   o fix aio+dio case

TODO
  o implement down_write_killable()
  o fix kvm (need?)
  o fix get_arg_page() (Why this function don't use mmap_sem?)



^ permalink raw reply	[flat|nested] 93+ messages in thread

end of thread, other threads:[~2009-04-23 12:49 UTC | newest]

Thread overview: 93+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14  6:15 [RFC][PATCH 0/6] IO pinning(get_user_pages()) vs fork race fix KOSAKI Motohiro
2009-04-14  6:15 ` KOSAKI Motohiro
2009-04-14  6:16 ` [RFC][PATCH v3 1/6] mm: Don't unmap gup()ed page KOSAKI Motohiro
2009-04-14  6:16   ` KOSAKI Motohiro
2009-04-14  9:25   ` Nick Piggin
2009-04-14  9:25     ` Nick Piggin
2009-04-14 12:02     ` KOSAKI Motohiro
2009-04-14 12:02       ` KOSAKI Motohiro
2009-04-14 12:25       ` Nick Piggin
2009-04-14 12:25         ` Nick Piggin
2009-04-14 13:39         ` KOSAKI Motohiro
2009-04-14 13:39           ` KOSAKI Motohiro
2009-04-14 13:39           ` KOSAKI Motohiro
2009-04-14 14:12           ` Andrea Arcangeli
2009-04-14 14:12             ` Andrea Arcangeli
2009-04-14 14:26             ` Nick Piggin
2009-04-14 14:26               ` Nick Piggin
2009-04-14 14:32               ` Andrea Arcangeli
2009-04-14 14:32                 ` Andrea Arcangeli
2009-04-14 14:42                 ` Nick Piggin
2009-04-14 14:42                   ` Nick Piggin
2009-04-14 15:21                   ` Andrea Arcangeli
2009-04-14 15:21                     ` Andrea Arcangeli
2009-04-15  8:05                   ` KOSAKI Motohiro
2009-04-15  8:05                     ` KOSAKI Motohiro
2009-04-15  8:22                     ` Nick Piggin
2009-04-15  8:22                       ` Nick Piggin
2009-04-15  9:22                       ` Nick Piggin
2009-04-15  9:22                         ` Nick Piggin
2009-04-15 10:46                     ` Andrea Arcangeli
2009-04-15 10:46                       ` Andrea Arcangeli
2009-04-15 11:39                       ` KOSAKI Motohiro
2009-04-15 11:39                         ` KOSAKI Motohiro
2009-04-15 11:39                         ` KOSAKI Motohiro
2009-04-15 11:41                         ` Andrea Arcangeli
2009-04-15 11:41                           ` Andrea Arcangeli
2009-04-15 11:41                           ` Andrea Arcangeli
2009-04-15 11:53                           ` KOSAKI Motohiro
2009-04-15 11:53                             ` KOSAKI Motohiro
2009-04-19 12:37                             ` KOSAKI Motohiro
2009-04-19 12:37                               ` KOSAKI Motohiro
2009-04-14 14:38   ` Andrea Arcangeli
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:18   ` KOSAKI Motohiro
2009-04-14  6:25   ` KOSAKI Motohiro
2009-04-14  6:25     ` KOSAKI Motohiro
2009-04-14 16:45     ` Jeff Moyer
2009-04-14 16:45       ` Jeff Moyer
2009-04-14 17:51       ` Andrea Arcangeli
2009-04-14 17:51         ` Andrea Arcangeli
2009-04-14 18:10         ` Jeff Moyer
2009-04-14 18:10           ` Jeff Moyer
2009-04-14 19:48           ` Andrea Arcangeli
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  6:19   ` KOSAKI Motohiro
2009-04-14 16:48   ` Jeff Moyer
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  6:20   ` KOSAKI Motohiro
2009-04-14 13:41   ` Andrea Arcangeli
2009-04-14 13:41     ` Andrea Arcangeli
2009-04-14 16:01   ` Jeff Moyer
2009-04-14 16:01     ` Jeff Moyer
2009-04-15  0:56     ` KOSAKI Motohiro
2009-04-15  0:56       ` KOSAKI Motohiro
2009-04-15  2:44       ` Jeff Moyer
2009-04-15  2:44         ` Jeff Moyer
2009-04-15  3:00         ` KOSAKI Motohiro
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:21   ` 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:23   ` KOSAKI Motohiro
2009-04-14  6:56   ` Nick Piggin
2009-04-14  6:56     ` Nick Piggin
2009-04-14  6:58     ` KOSAKI Motohiro
2009-04-14  6:58       ` KOSAKI Motohiro
2009-04-15  8:48       ` KOSAKI Motohiro
2009-04-15  8:48         ` KOSAKI Motohiro
2009-04-17 15:07         ` Sosnowski, Maciej
2009-04-17 15:07           ` Sosnowski, Maciej
2009-04-19 12:37           ` KOSAKI Motohiro
2009-04-19 12:37             ` KOSAKI Motohiro
2009-04-23 12:48             ` Sosnowski, Maciej
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  8:41   ` Nick Piggin
2009-04-14  9:19   ` KOSAKI Motohiro
2009-04-14  9:19     ` KOSAKI Motohiro
2009-04-14  9:37     ` Nick Piggin
2009-04-14  9:37       ` Nick Piggin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.