diff options
author | David Howells <dhowells@redhat.com> | 2007-03-22 04:11:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-03-22 22:39:06 -0400 |
commit | 165b239270be610a1e3999cb0d2e4e2c1f2a8fd4 (patch) | |
tree | 3ae32cc616047b3960d1fe33b0583faa3094b82c | |
parent | d56e03cd275486eb8141116a7af2df7457cb0115 (diff) |
[PATCH] NOMMU: make SYSV SHM nattch work correctly
Make the SYSV SHM nattch counter work correctly by forcing multiple VMAs to
be produced to represent MAP_SHARED segments, even if they overlap exactly.
Using this test program:
http://people.redhat.com/~dhowells/doshm.c
Run as:
doshm sysv
I can see nattch going from one before the patch:
# /doshm sysv
Command: sysv
shmid: 65536
memory: 0xc3700000
c0b00000-c0b04000 rw-p 00000000 00:00 0
c0bb0000-c0bba788 r-xs 00000000 00:0b 14582157 /lib/ld-uClibc-0.9.28.so
c3180000-c31dede4 r-xs 00000000 00:0b 14582179 /lib/libuClibc-0.9.28.so
c3520000-c352278c rw-p 00000000 00:0b 13763417 /doshm
c3584000-c35865e8 r-xs 00000000 00:0b 13763417 /doshm
c3588000-c358aa00 rw-p 00008000 00:0b 14582157 /lib/ld-uClibc-0.9.28.so
c3590000-c359b6c0 rw-p 00000000 00:00 0
c3620000-c3640000 rwxp 00000000 00:00 0
c3700000-c37fa000 rw-S 00000000 00:06 1411 /SYSV00000000 (deleted)
c3700000-c37fa000 rw-S 00000000 00:06 1411 /SYSV00000000 (deleted)
nattch 1
To two after the patch:
# /doshm sysv
Command: sysv
shmid: 0
memory: 0xc3700000
c0bb0000-c0bba788 r-xs 00000000 00:0b 14582157 /lib/ld-uClibc-0.9.28.so
c3180000-c31dede4 r-xs 00000000 00:0b 14582179 /lib/libuClibc-0.9.28.so
c3320000-c3340000 rwxp 00000000 00:00 0
c3530000-c35325e8 r-xs 00000000 00:0b 13763417 /doshm
c3534000-c353678c rw-p 00000000 00:0b 13763417 /doshm
c3538000-c353aa00 rw-p 00008000 00:0b 14582157 /lib/ld-uClibc-0.9.28.so
c3590000-c359b6c0 rw-p 00000000 00:00 0
c35a4000-c35a8000 rw-p 00000000 00:00 0
c3700000-c37fa000 rw-S 00000000 00:06 1369 /SYSV00000000 (deleted)
c3700000-c37fa000 rw-S 00000000 00:06 1369 /SYSV00000000 (deleted)
nattch 2
That's +1 to nattch for each shmat() made.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/nommu.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index ba6df4d29979..cbbc13774819 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -826,6 +826,11 @@ unsigned long do_mmap_pgoff(struct file *file, | |||
826 | unsigned long pglen = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; | 826 | unsigned long pglen = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; |
827 | unsigned long vmpglen; | 827 | unsigned long vmpglen; |
828 | 828 | ||
829 | /* suppress VMA sharing for shared regions */ | ||
830 | if (vm_flags & VM_SHARED && | ||
831 | capabilities & BDI_CAP_MAP_DIRECT) | ||
832 | goto dont_share_VMAs; | ||
833 | |||
829 | for (rb = rb_first(&nommu_vma_tree); rb; rb = rb_next(rb)) { | 834 | for (rb = rb_first(&nommu_vma_tree); rb; rb = rb_next(rb)) { |
830 | vma = rb_entry(rb, struct vm_area_struct, vm_rb); | 835 | vma = rb_entry(rb, struct vm_area_struct, vm_rb); |
831 | 836 | ||
@@ -859,6 +864,7 @@ unsigned long do_mmap_pgoff(struct file *file, | |||
859 | goto shared; | 864 | goto shared; |
860 | } | 865 | } |
861 | 866 | ||
867 | dont_share_VMAs: | ||
862 | vma = NULL; | 868 | vma = NULL; |
863 | 869 | ||
864 | /* obtain the address at which to make a shared mapping | 870 | /* obtain the address at which to make a shared mapping |