From: Richard Hansen <rhansen@bbn.com>
To: mtk.manpages@gmail.com
Cc: Steven Whitehouse <swhiteho@redhat.com>,
Christoph Hellwig <hch@infradead.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
lkml <linux-kernel@vger.kernel.org>,
Linux API <linux-api@vger.kernel.org>,
Greg Troxel <gdt@ir.bbn.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] mm: msync: require either MS_ASYNC or MS_SYNC
Date: Thu, 03 Apr 2014 16:23:51 -0400 [thread overview]
Message-ID: <533DC357.1080203@bbn.com> (raw)
In-Reply-To: <CAKgNAki8U+j0mvYCg99j7wJ2Z7ve-gxusVbM3zdog=hKGPdidQ@mail.gmail.com>
On 2014-04-03 04:25, Michael Kerrisk (man-pages) wrote:
> [CC += Peter Zijlstra]
> [CC += bug-readline@gnu.org -- maintainers, it _may_ be desirable to
> fix your msync() call]
I didn't see bug-readline@gnu.org in the CC list -- did you forget to
add them, or were they BCC'd?
>> * Clearer intentions. Looking at the existing code and the code
>> history, the fact that flags=0 behaves like flags=MS_ASYNC appears
>> to be a coincidence, not the result of an intentional choice.
>
> Maybe. You earlier asserted that the semantics when flags==0 may have
> been different, prior to Peter Zijstra's patch,
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=204ec841fbea3e5138168edbc3a76d46747cc987
> .
> It's not clear to me that that is the case. But, it would be wise to
> CC the developer, in case he has an insight.
Good idea, thanks.
> But, even if you could find and fix every application that misuses
> msync(), new kernels with your proposed changes would still break old
> binaries. Linus has made it clear on numerous occasions that kernel
> changes must not break user space. So, the change you suggest is never
> going to fly (and Christoph's NAK at least saves Linus yelling at you
> ;-).)
OK -- that's a good enough reason for me.
> I think the only reasonable solution is to better document existing
> behavior and what the programmer should do.
Greg mentioned the possibility of syslogging a warning the first time a
process uses msync() with neither flag set. Another alternative would
be to do this in userspace: modify the {g,u}libc shims to log a warning
to stderr.
And there's yet another alternative that's probably a bad idea but I'll
toss it out anyway: I'm not very familiar with the Linux kernel, but
the NetBSD kernel defines multiple versions of some syscalls for
backward-compatibility reasons. A new non-backward-compatible version
of an existing syscall gets a new syscall number. Programs compiled
against the latest headers use the new version of the syscall but old
binaries still get the old behavior. I imagine folks would frown upon
doing something like this in Linux for msync() (create a new version
that EINVALs if neither flag is specified), but it would be a way to
migrate toward a portability-friendly behavior while maintaining
compatibility with existing binaries. (Sloppy userspace programs would
still need to be fixed, so this would still "break userspace".)
> With that in mind, I've
> drafted the following text for the msync(2) man page:
>
> NOTES
> According to POSIX, exactly one of MS_SYNC and MS_ASYNC must be
> specified in flags. However, Linux permits a call to msync()
> that specifies neither of these flags, with semantics that are
> (currently) equivalent to specifying MS_ASYNC. (Since Linux
> 2.6.19, MS_ASYNC is in fact a no-op, since the kernel properly
> tracks dirty pages and flushes them to storage as necessary.)
> Notwithstanding the Linux behavior, portable, future-proof appli‐
> cations should ensure that they specify exactly one of MS_SYNC
> and MS_ASYNC in flags.
>
> Comments on this draft welcome.
I agree with Greg's reply to this note. How about this text instead:
Exactly one of MS_SYNC and MS_ASYNC must be specified in flags.
If neither flag is set, the behavior is unspecified.
I'll follow up with a new patch that explicitly defaults to MS_ASYNC (to
document the desire to maintain compaitibility and to prevent unexpected
problems if msync() is ever overhauled again).
Thanks,
Richard
--
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>
next prev parent reply other threads:[~2014-04-03 20:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 18:25 [PATCH] mm: msync: require either MS_ASYNC or MS_SYNC Richard Hansen
[not found] ` <533B04A9.6090405-A08e6c8yq/Q@public.gmane.org>
2014-04-01 19:32 ` Michael Kerrisk (man-pages)
2014-04-02 0:53 ` Richard Hansen
[not found] ` <533B1439.3010403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-04-02 10:45 ` chrubis-AlSwsSmVLrQ
2014-04-02 11:10 ` Christoph Hellwig
[not found] ` <20140402111032.GA27551-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-04-02 11:45 ` Steven Whitehouse
2014-04-02 23:44 ` Richard Hansen
2014-04-03 8:25 ` Michael Kerrisk (man-pages)
2014-04-03 11:51 ` Christopher Covington
2014-04-04 6:54 ` Michael Kerrisk (man-pages)
2014-04-03 12:57 ` Greg Troxel
2014-04-04 7:11 ` Michael Kerrisk (man-pages)
2014-04-03 20:23 ` Richard Hansen [this message]
2014-04-04 6:53 ` Christoph Hellwig
2014-04-04 7:12 ` [PATCH] mm: msync: require either MS_ASYNC or MS_SYNC [resend] Michael Kerrisk (man-pages)
2014-04-04 14:07 ` Peter Zijlstra
-- strict thread matches above, loose matches on Subject: below --
2013-09-01 19:58 [PATCH] mm: msync: require either MS_ASYNC or MS_SYNC Richard Hansen
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=533DC357.1080203@bbn.com \
--to=rhansen@bbn.com \
--cc=gdt@ir.bbn.com \
--cc=hch@infradead.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mtk.manpages@gmail.com \
--cc=peterz@infradead.org \
--cc=swhiteho@redhat.com \
/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).