Re: Posix Shared Mem patch

From: Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Posix Shared Mem patch
Date: 2012-06-28 14:06:08
Message-ID: CAKuK5J2F=jgJT=1Kt2xxDt07z8ES-6Jya-vb3LAZ9KCS8YsZeg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 28, 2012 at 8:57 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Thu, Jun 28, 2012 at 9:47 AM, Jon Nelson <jnelson+pgsql(at)jamponi(dot)net> wrote:
>> Why not just mmap /dev/zero (MAP_SHARED but not MAP_ANONYMOUS)?  I
>> seem to think that's what I did when I needed this functionality oh so
>> many moons ago.
>
> From the reading I've done on this topic, that seems to be a trick
> invented on Solaris that is considered grotty and awful by everyone
> else.  The thing is that you want the mapping to be shared with the
> processes that inherit the mapping from you.  You do *NOT* want the
> mapping to be shared with EVERYONE who has mapped that file for any
> reason, which is the usual meaning of MAP_SHARED on a file.  Maybe
> this happens to work correctly on some or all platforms, but I would
> want to have some convincing evidence that it's more widely supported
> (with the correct semantics) than MAP_ANON before relying on it.

When I did this (I admit, it was on Linux but it was a long time ago)
only the inherited file descriptor + mmap structure mattered -
modifications were private to the process and it's children - other
apps always saw their "own" /dev/zero. A quick google suggests that -
according to qnx, sco, and some others - mmap'ing /dev/zero retains
the expected privacy. Given how /dev/zero works I'd be very surprised
if it was otherwise.

I would love to see links that suggest that /dev/zero is nasty (or, in
fact, in any way fundamentally different than mmap'ing /dev/zero) -
feel free to send them to me privately to avoid polluting the list.

--
Jon

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-06-28 14:07:27 Re: Event Triggers reduced, v1
Previous Message Tom Lane 2012-06-28 13:59:38 Re: Posix Shared Mem patch