linux/fs/proc
Joe Korty 7c88db0cb5 proc: fix vma display mismatch between /proc/pid/{maps,smaps}
Commit 4752c36978 aka
"maps4: simplify interdependence of maps and smaps" broke /proc/pid/smaps,
causing it to display some vmas twice and other vmas not at all.  For example:

    grep .- /proc/1/smaps >/tmp/smaps; diff /proc/1/maps /tmp/smaps

    1  25d24
    2  < 7fd7e23aa000-7fd7e23ac000 rw-p 7fd7e23aa000 00:00 0
    3  28a28
    4  > ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0  [vsyscall]

The bug has something to do with setting m->version before all the
seq_printf's have been performed.  show_map was doing this correctly,
but show_smap was doing this in the middle of its seq_printf sequence.
This patch arranges things so that the setting of m->version in show_smap
is also done at the end of its seq_printf sequence.

Testing: in addition to the above grep test, for each process I summed
up the 'Rss' fields of /proc/pid/smaps and compared that to the 'VmRSS'
field of /proc/pid/status.  All matched except for Xorg (which has a
/dev/mem mapping which Rss accounts for but VmRSS does not).  This result
gives us some confidence that neither /proc/pid/maps nor /proc/pid/smaps
are any longer skipping or double-counting vmas.

Signed-off-by: Joe Korty <joe.korty@ccur.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
2008-10-23 13:21:29 +04:00
..
Kconfig proc: move PROC_PAGE_MONITOR to fs/proc/Kconfig 2008-10-10 04:18:57 +04:00
Makefile [NET]: Make /proc/net per network namespace 2007-10-10 16:49:06 -07:00
array.c Merge branches 'timers/clocksource', 'timers/hrtimers', 'timers/nohz', 'timers/ntp', 'timers/posixtimers' and 'timers/debug' into v28-timers-for-linus 2008-10-20 13:14:06 +02:00
base.c proc: remove kernel.maps_protect 2008-10-10 04:24:51 +04:00
generic.c proc: more debugging for "already registered" case 2008-09-13 14:41:50 -07:00
inode-alloc.txt
inode.c proc: fix return value of proc_reg_open() in "too late" case 2008-10-10 04:18:54 +04:00
internal.h proc: remove kernel.maps_protect 2008-10-10 04:24:51 +04:00
kcore.c elf: use ELF_CORE_EFLAGS for kcore ELF header flags 2008-07-25 10:53:42 -07:00
kmsg.c move proc_kmsg_operations to fs/proc/internal.h 2008-07-25 10:53:44 -07:00
mmu.c fs/proc/mmu.c: headers butchery 2007-10-17 08:42:48 -07:00
nommu.c /proc/self/maps doesn't display the real file offset 2008-08-20 15:40:30 -07:00
proc_devtree.c [POWERPC] Make struct property's value a void * 2007-04-13 03:55:18 +10:00
proc_misc.c Merge branch 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-20 13:23:01 -07:00
proc_net.c netns: make get_proc_net() static 2008-07-22 14:19:19 -07:00
proc_sysctl.c proc: make grab_header() static 2008-10-10 04:18:56 +04:00
proc_tty.c tty: Ldisc revamp 2008-07-20 17:12:34 -07:00
root.c proc: introduce proc_create_data to setup de->data 2008-04-29 08:06:20 -07:00
task_mmu.c proc: fix vma display mismatch between /proc/pid/{maps,smaps} 2008-10-23 13:21:29 +04:00
task_nommu.c proc: remove kernel.maps_protect 2008-10-10 04:24:51 +04:00
vmcore.c kdump: add is_vmcore_usable() and vmcore_unusable() 2008-10-20 08:52:40 -07:00