lkml.org 
[lkml]   [2014]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH -next] mm,vmacache: also flush cache for VM_CLONE
On 03/13, Linus Torvalds wrote:
>
> On Mar 13, 2014 8:11 AM, "Oleg Nesterov" <oleg@redhat.com> wrote:
> >
> > Suppose that a kernel thread T does, say,
> >
> > use_mm(foreign_mm);
> > get_user(...);
> > unuse_mm();
>
> That would be a major bug. Kernel threads cannot access use memory.

Unless a kernel thread does use_mm() ;)

> Has
> somebody added anything that crazy?

Hmm. aio no longer uses use_mm()... But there are other users:

drivers/usb/gadget/inode.c 582 use_mm(mm);
drivers/vhost/vhost.c 211 use_mm(dev->mm);
virt/kvm/async_pf.c 68 use_mm(mm);

And yes, they do copy_to/from_user().

Hmm, but at first glance async_pf_execute() doesn't need use_mm() at all.
And perhaps other callers can use get_user_pages() too.

> The kernel thread "use_mm" is to avoid unnecessary context switches of the
> tlb when switching to a kennel thread, exactly *because* a kernel thread is
> never supposed to access use space, so it cannot care what user memory is
> attached.

It seems that you are talking about switch_mm-like things or I misunderstood.
use_mm() actually changes ->mm, not only ->active_mm.

> So I object vet much to making kernel threads special on this context,
> unless the "special" bit is some VM_BUG_ON() or similar.

See above. Perhaps we can kill use_mm() (personally I don't think we should),
but until then vmacache needs this check afaics.

Oleg.



\
 
 \ /
  Last update: 2014-03-13 18:21    [W:0.097 / U:1.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site