2017-11-08 02:33:35

by Andrei Vagin

[permalink] [raw]
Subject: Re: lost path_put in perf_fill_ns_link_info

On Tue, Nov 07, 2017 at 11:03:18AM -0800, Andrei Vagin wrote:
> Hi Vasily and all,
>
> The patch looks correct for me. I tried to reproduce this issue and
> checked that this patch fixes it. Bellow you can find my test program
> and a command line to run it. The problem still exists even with this patch.
>
> $ cat test.c
> #define _GNU_SOURCE
> #include <sched.h>
>
> int main(int argc, char **argv)
> {
> while (1)
> unshare(CLONE_NEWUTS);
> return 0;
> }
>
> $ gcc -o test_unshare test.c
> $ for i in `seq 10000`; do perf trace -o log unshare -u true; done &
> [5] 28766
> $ for i in `seq 10000`; do perf trace -o log unshare -u true; done &
> [6] 28840
>
> $ echo 3 > /proc/sys/vm/drop_caches | cat /proc/slabinfo | grep dentry
> dentry 74848 78660 224 18 1 : tunables 0 0 0 : slabdata 4370 4370 0
>
> $ sleep 10
> $ echo 3 > /proc/sys/vm/drop_caches | cat /proc/slabinfo | grep dentry
> dentry 75145 79002 224 18 1 : tunables 0 0 0 : slabdata 4389 4389 0
>
> $ sleep 10
> $ echo 3 > /proc/sys/vm/drop_caches | cat /proc/slabinfo | grep dentry
> dentry 75921 79776 224 18 1 : tunables 0 0 0 : slabdata 4432 4432 0

Actually here is another issue, and it is reproduced by another script:

for i in `seq 10000`; do perf trace -o /dev/null unshare -u true; done &

And it is due to files what perf creates in /tmp

//tmp/perf-vdso.so-84wDCZ
//tmp/perf-vdso.so-YDfUuX
//tmp/perf-vdso.so-KkTBfU
//tmp/perf-vdso.so-srXfvU
//tmp/perf-vdso.so-QrPscR
//tmp/perf-vdso.so-wlxIZO
//tmp/perf-vdso.so-ur4fBP
//tmp/perf-vdso.so-gBMExN
//tmp/perf-vdso.so-6sCehK
//tmp/perf-vdso.so-cZ4GDK
//tmp/perf-vdso.so-ImQLoH
//tmp/perf-vdso.so-y4rMuF
//tmp/perf-vdso.so-Wx1qIG
//tmp/perf-vdso.so-g5mYOD
...

Do we really need all these files? They all are identical.

[root@fc24 ~]# diff -up /tmp/perf-vdso.so-fnVcRz /tmp/perf-vdso.so-FQGYzh
[root@fc24 ~]# echo $?
0
> $ git log --pretty=oneline | head -n 2
> c83bceb10b36cef895def4b2dfe0aff6ca7c9784 lost path_put in perf_fill_ns_link_info
> 8b82a8a7ab53ee1a065ac69c835737a701f46b2e Add linux-next specific files for 20171107
>
> Thanks,
> Andrei
>
> On Mon, Nov 06, 2017 at 09:22:18AM +0300, Vasily Averin wrote:
> > Fixes: commit e422267322cd ("perf: Add PERF_RECORD_NAMESPACES to include namespaces related info")
> > Signed-off-by: Vasily Averin <[email protected]>
> > ---
> > kernel/events/core.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index 10cdb9c..ab5ac84 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -6756,6 +6756,7 @@ static void perf_fill_ns_link_info(struct perf_ns_link_info *ns_link_info,
> > ns_inode = ns_path.dentry->d_inode;
> > ns_link_info->dev = new_encode_dev(ns_inode->i_sb->s_dev);
> > ns_link_info->ino = ns_inode->i_ino;
> > + path_put(&ns_path);
> > }
> > }
> >

From 1583463138892775043@xxx Wed Nov 08 02:28:46 +0000 2017
X-GM-THRID: 1583296720926435526
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread