From: Jamie Lokier <jamie@shareable.org>
To: James Bottomley <James.Bottomley@steeleye.com>
Cc: Linus Torvalds <torvalds@osdl.org>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fix remap of shared read only mappings
Date: Thu, 4 Sep 2003 22:48:10 +0100 [thread overview]
Message-ID: <20030904214810.GG31590@mail.jlokier.co.uk> (raw)
In-Reply-To: <1062686960.1829.11.camel@mulgrave>
James Bottomley wrote:
> When mmap MAP_SHARED is done on a file, it gets marked with VM_MAYSHARE
> and, if it's read/write, VM_SHARED. However, if it is remapped with
> mremap(), the MAP_SHARED is only passed into the new mapping based on
> VM_SHARED. This means that remapped read only MAP_SHARED mappings lose
> VM_MAYSHARE. This is causing us a problem on parisc because we have to
> align all shared mappings carefully to mitigate cache aliasing problems.
>
> The fix is to key passing the MAP_SHARED flag back into the remapped are
> off VM_MAYSHARE not VM_SHARED.
At first I disagreed with your patch. I was thinking that special
alignment is only really needed to avoid aliasing problems for
_writable_ shared mappings, and VM_SHARED is right for that. (Which
would indicate that mmap is faulty, not mremap).
But after some thought, I agree with you.
A read-only mapping of a shared segment must be coherent with other,
possibly writable mappings, so far as the architecture can guarantee
that.
That coherence should not disappear if the file handle used for the
mapping was opened O_RDONLY.
One last thought: this is what PROT_SEM is for. Linux doesn't use
this in any useful way. But, technically, mmap with MAP_SHARED ad
PROT_SEM should enable cache coherence, and that might include
aligning the address. Without PROT_SEM an application should not rely
on cache coherence.
-- Jamie
next prev parent reply other threads:[~2003-09-04 21:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-04 14:49 James Bottomley
2003-09-04 21:48 ` Jamie Lokier [this message]
2003-09-04 22:33 ` James Bottomley
2003-09-04 22:56 ` Jamie Lokier
2003-09-04 23:23 ` James Bottomley
2003-09-04 23:40 ` Jamie Lokier
2003-09-05 0:49 ` Daniel Phillips
2003-09-05 0:49 ` Linus Torvalds
2003-09-05 1:07 ` Alan Cox
2003-09-05 1:31 ` Daniel Phillips
2003-09-05 4:35 ` Linus Torvalds
2003-09-05 0:52 ` James Bottomley
2003-09-05 1:21 ` Daniel Phillips
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=20030904214810.GG31590@mail.jlokier.co.uk \
--to=jamie@shareable.org \
--cc=James.Bottomley@steeleye.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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®