LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Jan Kara <jack@suse.cz>
Cc: Souptick Joarder <jrdr.linux@gmail.com>,
	viro@zeniv.linux.org.uk, mawilcox@microsoft.com,
	ross.zwisler@linux.intel.com, akpm@linux-foundation.org,
	dan.j.williams@intel.com, mhocko@suse.com,
	kirill.shutemov@linux.intel.com, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] fs: dax: Adding new return type vm_fault_t
Date: Sun, 22 Apr 2018 19:25:05 -0700	[thread overview]
Message-ID: <20180423022505.GA2308@bombadil.infradead.org> (raw)
In-Reply-To: <20180422230948.2mvimlf3zspry4ji@quack2.suse.cz>

On Mon, Apr 23, 2018 at 01:09:48AM +0200, Jan Kara wrote:
> > -int vm_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr,
> > -			pfn_t pfn)
> > +vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma,
> > +		unsigned long addr, pfn_t pfn)
> >  {
> > -	return __vm_insert_mixed(vma, addr, pfn, true);
> > +	int err;
> > +
> > +	err =  __vm_insert_mixed(vma, addr, pfn, true);
> > +	if (err == -ENOMEM)
> > +		return VM_FAULT_OOM;
> > +	if (err < 0 && err != -EBUSY)
> > +		return VM_FAULT_SIGBUS;
> > +	return VM_FAULT_NOPAGE;
> >  }
> > -EXPORT_SYMBOL(vm_insert_mixed_mkwrite);
> > +EXPORT_SYMBOL(vmf_insert_mixed_mkwrite);
> 
> So are we sure that all the callers of this function (and also of
> vmf_insert_mixed()) are OK with EBUSY? Because especially in the
> vmf_insert_mixed() case other page than the caller provided is in page
> tables and thus possibly the caller needs to do some error recovery (such
> as drop page refcount) in such case...

I went through all the users and didn't find any that did anything
with -EBUSY other than turn it into VM_FAULT_NOPAGE.  I agree that it's
possible that there might have been someone who wanted to do that, but
we tend to rely on mapcount (through rmap) rather than refcount (ie we
use refcount to mean the number of kernel references to the page and then
use mapcount for the number of times it's mapped into a process' address
space).  All the drivers I audited would allocagte the page first, store
it in their own data structures, then try to insert it into the virtual
address space.  So an EBUSY always meant "the same page was inserted".

If we did want to support "This happened already" in the future, we
could define a VM_FAULT flag for that.

  reply	other threads:[~2018-04-23  2:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-21 21:05 Souptick Joarder
2018-04-21 21:34 ` Matthew Wilcox
2018-04-21 21:54   ` Souptick Joarder
2018-04-21 23:56     ` Dan Williams
2018-04-22 23:09 ` Jan Kara
2018-04-23  2:25   ` Matthew Wilcox [this message]
2018-04-23 13:59     ` Jan Kara
2018-04-23 16:12       ` Souptick Joarder
2018-04-23 17:28         ` Matthew Wilcox

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=20180423022505.GA2308@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=jack@suse.cz \
    --cc=jrdr.linux@gmail.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawilcox@microsoft.com \
    --cc=mhocko@suse.com \
    --cc=ross.zwisler@linux.intel.com \
    --cc=viro@zeniv.linux.org.uk \
    --subject='Re: [PATCH v3] fs: dax: Adding new return type vm_fault_t' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).