mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Isaacson <adi@hexapodia.org>
To: Robert Love <rml@novell.com>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	linux-kernel@vger.kernel.org
Subject: Re: wrong madvise(MADV_DONTNEED) semantic
Date: Tue, 28 Jun 2005 11:53:00 -0700	[thread overview]
Message-ID: <20050628185300.GB30079@hexapodia.org> (raw)
In-Reply-To: <1119983300.6745.1.camel@betsy>

On Tue, Jun 28, 2005 at 02:28:20PM -0400, Robert Love wrote:
> On Tue, 2005-06-28 at 11:16 -0700, Andy Isaacson wrote:
> > Besides, if you read the documentation closely, it does not say what you
> > think it says.
> > 
> >        MADV_DONTNEED
> > 	      Do not expect access in the near future.  (For the time
> > 	      being, the application is finished with the given range,
> > 	      so the kernel can free resources associated with it.)
> > 	      Subsequent accesses of pages in this range will succeed,
> > 	      but will result either in reloading of the memory contents
> > 	      from the underlying mapped file (see mmap) or
> > 	      zero-fill-on-demand pages for mappings without an
> > 	      underlying file.
> > 
> > You seem to think that "reloading ... from the underlying mapped file"
> > means that changes are lost, but that's not implied.
> 
> This wording _does_ imply that changes are lost

I contest your interpretation of the manpage; while it could be read
the way you suggest, I claim that because Linux mmap is inherently
coherent (as opposed to, for example, AIX 4.1 mmap) then the "underlying
file" already contains the updated contents, and ergo msync is not
required for correct MAP_SHARED semantics on Linux, and the manpage as
it stands is (misleading, but) both accurate to the 2.6.11
implementation and compliant with the POSIX description posted earlier.

> if the file is mapped writable and not mysnc'ed

This is the case that my posted example code exercises, and I did not
see any problems.  Is there some additional circumstance that is
necessary to cause it to break?  (I tested on 2.6.11-rc5 or something
close to that.)

> or if the memory mapping is anonymous.
>
> In the latter case, the data is dropped and the pages are
> zero-filled on access.

Yes, MAP_ANONYMOUS is a more interesting case.  Somebody else will have
to write the testcase for that...

I think the correct docs fix is to simply delete the misleading parts of
madvise.2 so that it reads

        MADV_DONTNEED
 	      Do not expect access in the near future.  (For the time
 	      being, the application is finished with the given range,
 	      so the kernel can free resources associated with it.)

and remove the erroneous parenthetical in the first paragraph.

... unless, of course, someone can actually demonstrate a case where
madvise results in differing semantics...

-andy

  reply	other threads:[~2005-06-28 18:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-28 13:43 Samuel Thibault
2005-06-28 14:38 ` [Patch] Hotfix for " Jörn Engel
2005-06-28 18:16 ` Andy Isaacson
2005-06-28 18:28   ` Robert Love
2005-06-28 18:53     ` Andy Isaacson [this message]
2005-06-28 19:23       ` Robert Love
2005-06-28 19:41         ` Samuel Thibault
2005-06-28 20:03           ` Jörn Engel
2005-06-28 20:05             ` Robert Love
2005-06-28 20:17               ` Jörn Engel
2005-06-28 20:20                 ` Samuel Thibault
2005-06-28 20:30                   ` Jörn Engel
2005-06-28 20:37                   ` Andy Isaacson
2005-07-05 23:39                 ` Darren Hart
2005-06-29 16:53         ` wrong madvise(MADV DONTNEED) semantic Michael Kerrisk
2005-06-29 17:22           ` Jamie Lokier
2005-06-29 16:34     ` Michael Kerrisk
2005-06-28 18:54   ` wrong madvise(MADV_DONTNEED) semantic Samuel Thibault

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=20050628185300.GB30079@hexapodia.org \
    --to=adi@hexapodia.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rml@novell.com \
    --cc=samuel.thibault@ens-lyon.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

all inboxes | Powered by JetHome®