linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jan Kara <jack@suse.cz>, Dan Williams <dan.j.williams@intel.com>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Linux API <linux-api@vger.kernel.org>,
	linux-xfs <linux-xfs@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>, Andy Lutomirski <luto@kernel.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v9 1/6] mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags
Date: Mon, 16 Oct 2017 09:56:55 +0200	[thread overview]
Message-ID: <20171016075655.GE32738@quack2.suse.cz> (raw)
In-Reply-To: <CA+55aFyy-nz99c6erFh=aeyCOzsk0td5wHaVLpwBNA-sWNDZkA@mail.gmail.com>

On Thu 12-10-17 09:32:17, Linus Torvalds wrote:
> On Thu, Oct 12, 2017 at 6:51 AM, Jan Kara <jack@suse.cz> wrote:
> >
> > When thinking a bit more about this I've realized one problem: Currently
> > user can call mmap() with MAP_SHARED type and MAP_SYNC or MAP_DIRECT flags
> > and he will get the new semantics (if the kernel happens to support it).  I
> > think that is undesirable [..]
> 
> Why?
> 
> If you have a performance preference for MAP_DIRECT or something like
> that, but you don't want to *enforce* it, you'd use just plain
> MAP_SHARED with it.
> 
> Ie there may well be "I want this to work, possibly with downsides" issues.
> 
> So it seems to be a reasonable model, and disallowing it seems to
> limit people and not really help anything.

I have two concerns:

1) IMHO it supports sloppy programming from userspace - if application asks
e.g. for MAP_DIRECT and doesn't know whether it gets it or not, it would
have to be very careful not to assume anything about that in its code. And
frankly I think the most likely scenario is that a programmer will just use
MAP_SHARED | MAP_DIRECT, *assume* he will get the MAP_DIRECT semantics if
the call does not fail and then complain when his application breaks.

2) In theory there could be an application that inadvertedly sets some high
flag bits and now it would get confused by getting different mmap(2)
semantics. But I agree this is mostly theoretical.

Overall I think the benefit of being able to say "do MAP_DIRECT if you can"
does not outweight the risk of bugs in userspace applications. Especially
since userspace can easily implement the same semantics by retrying the
mmap(2) call without MAP_SHARED_VALIDATE | MAP_DIRECT.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  parent reply	other threads:[~2017-10-16  7:56 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12  0:47 [PATCH v9 0/6] MAP_DIRECT for DAX userspace flush Dan Williams
     [not found] ` <150776922692.9144.16963640112710410217.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-10-12  0:47   ` [PATCH v9 1/6] mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags Dan Williams
     [not found]     ` <150776923320.9144.6119113178052262946.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-10-12 13:51       ` Jan Kara
2017-10-12 16:32         ` Linus Torvalds
2017-10-16  7:38           ` Christoph Hellwig
2017-10-16  7:56           ` Jan Kara [this message]
2017-10-12  0:47   ` [PATCH v9 2/6] fs, mm: pass fd to ->mmap_validate() Dan Williams
     [not found]     ` <150776923838.9144.15727770472447035032.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-10-12  1:21       ` Al Viro
     [not found]         ` <20171012012131.GD21978-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2017-10-12  1:28           ` Dan Williams
     [not found]             ` <CAPcyv4jr4atxCqFW_337Sguu8LswVgjsJVOd65n4RODttX9cxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-12  2:17               ` Dan Williams
     [not found]                 ` <CAPcyv4ij9E9tXPLqp6cUAY3dJzh7OS+yPsVDME50xSvQPLpStA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-12  3:44                   ` Dan Williams
2017-10-12  0:47   ` [PATCH v9 3/6] fs: MAP_DIRECT core Dan Williams
2017-10-12  0:47   ` [PATCH v9 4/6] xfs: prepare xfs_break_layouts() for reuse with MAP_DIRECT Dan Williams
2017-10-12  0:47   ` [PATCH v9 5/6] fs, xfs, iomap: introduce break_layout_nowait() Dan Williams
2017-10-12  0:47   ` [PATCH v9 6/6] xfs: wire up MAP_DIRECT Dan Williams
2017-10-12 14:23   ` [PATCH v9 0/6] MAP_DIRECT for DAX userspace flush Christoph Hellwig
2017-10-12 17:41     ` Dan Williams
2017-10-13  6:57       ` Christoph Hellwig
     [not found]         ` <20171013065716.GB26461-jcswGhMUV9g@public.gmane.org>
2017-10-13 15:14           ` Dan Williams
     [not found]             ` <CAPcyv4gaLBBefOU+8f7_ypYnCTjSMk+9nq8NfCqBHAE+NbUusw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-13 16:38               ` Jason Gunthorpe
     [not found]                 ` <20171013163822.GA17411-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-10-13 17:01                   ` Dan Williams
     [not found]                     ` <CAPcyv4jDHp8z2VgVfyRK1WwMzixYVQnh54LZoPD57HB3yqSPPQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-13 17:31                       ` Jason Gunthorpe
     [not found]                         ` <20171013173145.GA18702-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-10-13 18:22                           ` Dan Williams
     [not found]                             ` <CAPcyv4jZJRto1jwmNU--pqH_6dOVMyj=68ZwEjAmmkgX=mRk7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-14  1:57                               ` Jason Gunthorpe
2017-10-16 12:02                                 ` Sagi Grimberg
     [not found]                                   ` <e29eb9ed-2d87-cde8-4efa-50de1fff0c04-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-10-19  6:02                                     ` Jason Gunthorpe
2017-10-16  7:30                               ` Christoph Hellwig
2017-10-16  7:26                           ` Christoph Hellwig
     [not found]                             ` <20171016072644.GB28270-jcswGhMUV9g@public.gmane.org>
2017-10-16 12:07                               ` Sagi Grimberg
2017-10-16 17:43                               ` Dan Williams
2017-10-16 19:44                                 ` Dan Williams
     [not found]                                   ` <CAPcyv4gtnZu7obG7UwaBq1-fwRZj06HCa=mjBfDKKgfp97nYaw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-10-17  6:46                                     ` Christoph Hellwig
2017-10-16  7:22                   ` Christoph Hellwig

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=20171016075655.GE32738@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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 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).