lkml.org 
[lkml]   [2014]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5] mm: softdirty: enable write notifications on VMAs after VM_SOFTDIRTY cleared
On Tue, Aug 26, 2014 at 06:19:14PM +0400, Cyrill Gorcunov wrote:
> On Tue, Aug 26, 2014 at 05:04:19PM +0300, Kirill A. Shutemov wrote:
> > > >
> > > > But now I'm realizing that if this is the _only_ place which modifies
> > > > vm_flags with down_read, then it's "probably" safe. I've a vague
> > > > feeling that this was discussed before - is that so, Cyrill?
> > >
> > > Well, as far as I remember we were not talking before about vm_flags
> > > and read-lock in this function, maybe it was on some unrelated lkml thread
> > > without me CC'ed? Until I miss something obvious using read-lock here
> > > for vm_flags modification should be safe, since the only thing which is
> > > important (in context of vma-softdirty) is the vma's presence. Hugh,
> > > mind to refresh my memory, how long ago the discussion took place?
> >
> > It seems safe in vma-softdirty context. But if somebody else will decide that
> > it's fine to modify vm_flags without down_write (in their context), we
> > will get trouble. Sasha will come with weird bug report one day ;)
> >
> > At least vm_flags must be updated atomically to avoid race in middle of
> > load-modify-store.
>
> Which race you mean here? Two concurrent clear-refs?

Two concurent clear-refs is fine. But if somebody else will exploit the
same approch to set/clear other VM_FOO and it will race with clear-refs
we get trouble: some modifications can be lost.

Basically, it's safe if only soft-dirty is allowed to modify vm_flags
without down_write(). But why is soft-dirty so special?

Should we consider moving protection of some vma fields under per-vma lock
rather use over-loaded mmap_sem?

--
Kirill A. Shutemov


\
 
 \ /
  Last update: 2014-08-26 17:21    [W:0.069 / U:0.564 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site