All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Hugh Dickins <hughd@google.com>
Cc: Keno Fischer <keno@juliacomputing.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	torvalds@linux-foundation.org, gthelen@google.com,
	npiggin@gmail.com, w@1wt.eu, oleg@redhat.com,
	keescook@chromium.org, luto@kernel.org, mhocko@suse.com,
	rientjes@google.com
Subject: Re: [PATCH] mm: Respect FOLL_FORCE/FOLL_COW for thp
Date: Wed, 11 Jan 2017 14:35:15 +0300	[thread overview]
Message-ID: <20170111113515.GB4895@node.shutemov.name> (raw)
In-Reply-To: <alpine.LSU.2.11.1701102300001.2996@eggly.anvils>

On Tue, Jan 10, 2017 at 11:06:10PM -0800, Hugh Dickins wrote:
> On Tue, 10 Jan 2017, Hugh Dickins wrote:
> > On Thu, 5 Jan 2017, Kirill A. Shutemov wrote:
> > > On Thu, Jan 05, 2017 at 12:36:58AM -0500, Keno Fischer wrote:
> > > >  struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
> > > >  		pmd_t *pmd, int flags)
> > > >  {
> > > > @@ -783,7 +793,7 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
> > > >  
> > > >  	assert_spin_locked(pmd_lockptr(mm, pmd));
> > > >  
> > > > -	if (flags & FOLL_WRITE && !pmd_write(*pmd))
> > > > +	if (flags & FOLL_WRITE && !can_follow_write_pmd(*pmd, flags))
> > > >  		return NULL;
> > > 
> > > I don't think this part is needed: once we COW devmap PMD entry, we split
> > > it into PTE table, so IIUC we never get here with PMD.
> > 
> > Hi Kirill,
> > 
> > Would you mind double-checking that?  You certainly know devmap
> > better than me, but I feel safer with Keno's original as above.
> > 
> > I can see that fs/dax.c dax_iomap_pmd_fault() does
> > 
> > 	/* Fall back to PTEs if we're going to COW */
> > 	if (write && !(vma->vm_flags & VM_SHARED))
> > 		goto fallback;
> > 
> > But isn't there a case of O_RDWR fd, VM_SHARED PROT_READ mmap, and
> > FOLL_FORCE write to it, which does not COW (but relies on FOLL_COW)?
> 
> And now I think I'm wrong, but please double-check even so: I think that
> case gets ruled out by the !is_cow_mapping(vm_flags) check in mm/gup.c,
> where we used to have a WARN_ON_ONCE() for a while.

Right, !is_cow_mapping(vm_flags) will filter the case out.

Also there's no way we will get FOLL_COW set for file THP (dax or not): we
never return VM_FAULT_WRITE there.

-- 
 Kirill A. Shutemov

WARNING: multiple messages have this Message-ID (diff)
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Hugh Dickins <hughd@google.com>
Cc: Keno Fischer <keno@juliacomputing.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	torvalds@linux-foundation.org, gthelen@google.com,
	npiggin@gmail.com, w@1wt.eu, oleg@redhat.com,
	keescook@chromium.org, luto@kernel.org, mhocko@suse.com,
	rientjes@google.com
Subject: Re: [PATCH] mm: Respect FOLL_FORCE/FOLL_COW for thp
Date: Wed, 11 Jan 2017 14:35:15 +0300	[thread overview]
Message-ID: <20170111113515.GB4895@node.shutemov.name> (raw)
In-Reply-To: <alpine.LSU.2.11.1701102300001.2996@eggly.anvils>

On Tue, Jan 10, 2017 at 11:06:10PM -0800, Hugh Dickins wrote:
> On Tue, 10 Jan 2017, Hugh Dickins wrote:
> > On Thu, 5 Jan 2017, Kirill A. Shutemov wrote:
> > > On Thu, Jan 05, 2017 at 12:36:58AM -0500, Keno Fischer wrote:
> > > >  struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
> > > >  		pmd_t *pmd, int flags)
> > > >  {
> > > > @@ -783,7 +793,7 @@ struct page *follow_devmap_pmd(struct vm_area_struct *vma, unsigned long addr,
> > > >  
> > > >  	assert_spin_locked(pmd_lockptr(mm, pmd));
> > > >  
> > > > -	if (flags & FOLL_WRITE && !pmd_write(*pmd))
> > > > +	if (flags & FOLL_WRITE && !can_follow_write_pmd(*pmd, flags))
> > > >  		return NULL;
> > > 
> > > I don't think this part is needed: once we COW devmap PMD entry, we split
> > > it into PTE table, so IIUC we never get here with PMD.
> > 
> > Hi Kirill,
> > 
> > Would you mind double-checking that?  You certainly know devmap
> > better than me, but I feel safer with Keno's original as above.
> > 
> > I can see that fs/dax.c dax_iomap_pmd_fault() does
> > 
> > 	/* Fall back to PTEs if we're going to COW */
> > 	if (write && !(vma->vm_flags & VM_SHARED))
> > 		goto fallback;
> > 
> > But isn't there a case of O_RDWR fd, VM_SHARED PROT_READ mmap, and
> > FOLL_FORCE write to it, which does not COW (but relies on FOLL_COW)?
> 
> And now I think I'm wrong, but please double-check even so: I think that
> case gets ruled out by the !is_cow_mapping(vm_flags) check in mm/gup.c,
> where we used to have a WARN_ON_ONCE() for a while.

Right, !is_cow_mapping(vm_flags) will filter the case out.

Also there's no way we will get FOLL_COW set for file THP (dax or not): we
never return VM_FAULT_WRITE there.

-- 
 Kirill A. Shutemov

--
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>

  reply	other threads:[~2017-01-11 11:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05  5:36 [PATCH] mm: Respect FOLL_FORCE/FOLL_COW for thp Keno Fischer
2017-01-05  5:36 ` Keno Fischer
2017-01-05 15:05 ` Kirill A. Shutemov
2017-01-05 15:05   ` Kirill A. Shutemov
2017-01-05 21:06   ` Keno Fischer
2017-01-05 21:06     ` Keno Fischer
2017-01-11  5:41   ` Hugh Dickins
2017-01-11  5:41     ` Hugh Dickins
2017-01-11  7:06     ` Hugh Dickins
2017-01-11  7:06       ` Hugh Dickins
2017-01-11 11:35       ` Kirill A. Shutemov [this message]
2017-01-11 11:35         ` Kirill A. Shutemov

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=20170111113515.GB4895@node.shutemov.name \
    --to=kirill@shutemov.name \
    --cc=gthelen@google.com \
    --cc=hughd@google.com \
    --cc=keescook@chromium.org \
    --cc=keno@juliacomputing.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mhocko@suse.com \
    --cc=npiggin@gmail.com \
    --cc=oleg@redhat.com \
    --cc=rientjes@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=w@1wt.eu \
    /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 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.