Skip to contentSkip to conversation

Interprocess shared memory .... but file backed?

DISCUSSION Christopher Quinn 4 participants 5 messages Mar 8, 2002

lore
Share & tools
lore
#0 lore raw

Hello,

I know that a combination of mmap/shmem can be used to achieve interprocess shared memory (notably Ralf Engelschall's MM library).
However as far as I can tell this is anonymous memory only.
Are there any options if one initially maps a disk file via mmap (in particular MAP_PRIVATE) for sharing that vm, such that any access by a member of the sharing process group will fault in the relevant file data page after which writes to it are seen by all?

Of course clone(2) will give the necessary sharing of page tables but my ideal is for sharing only of specified areas of vm, not everything.

Anyone know of a way of doing this?

Thanks,
Chris Quinn

PS. I'm not subscribed! please ensure you CC. me!!

#1 lore raw
Quoted 3 lines

However as far as I can tell this is anonymous memory only. Are there any options if one initially maps a disk file via mmap (in particular MAP_PRIVATE) for sharing that vm, such

well MAP_PRIVATE is "dont share" so not with that 8) Use MAP_SHARED and you'll get what you want

#2 lore raw
Quoted 8 lines · Alan Cox
Quoted 3 lines

However as far as I can tell this is anonymous memory only.
Are there any options if one initially maps a disk file via mmap (in particular MAP_PRIVATE) for sharing that vm, such

well MAP_PRIVATE is "dont share" so not with that 8) Use MAP_SHARED and you'll get what you want

Certainly true! But MAP_SHARED gives uncontrolled flush of dirty data - so that's out for me. I only want 'privacy' to extend to the right to make changes permanent at my own discretion.

Chris Q.

Signature · 2 lines
rgrds,
Chris Quinn
#3 lore raw
In reply to Alan Cox
Followup to:  <[email protected]>
By author:    Christopher Quinn <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 9 lines
Quoted 4 lines

well MAP_PRIVATE is "dont share" so not with that 8) Use MAP_SHARED and you'll get what you want

Certainly true! But MAP_SHARED gives uncontrolled flush of dirty data - so that's out for me. I only want 'privacy' to extend to the right to make changes permanent at my own discretion.

I actually have this issue as well, in order to make LPSM sharable it would be greatly beneficial to have something that would allow multiple processes to see the same mmap, but for writes not to hit the backing store file.

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt	<[email protected]>
#4 lore raw
In reply to Christopher Quinn
Quoted 11 lines · Christopher Quinn

Hello,

I know that a combination of mmap/shmem can be used to achieve interprocess shared memory (notably Ralf Engelschall's MM library).
However as far as I can tell this is anonymous memory only. Are there any options if one initially maps a disk file via mmap (in particular MAP_PRIVATE) for sharing that vm, such that any access by a member of the sharing process group will fault in the relevant file data page after which writes to it are seen by all?

Hmmm. You want MAP_SHARED, but you insist upon using MAP_PRIVATE? MAP_SHARED makes your mmapped pages visible to all, complete with any updates by any or all tasks accessing it.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.18 on an i686 machine (799.53 BogoMips).

Bill Gates? Who?