From: Vasily Averin <vvs@virtuozzo.com>
To: linux-kernel@vger.kernel.org,
Hari Bathini <hbathini@linux.vnet.ibm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH] memory leaks triggered by perf --namespace
Date: Wed, 15 Nov 2017 08:47:02 +0300 [thread overview]
Message-ID: <c510711b-3904-e5e1-d296-61273d21118d@virtuozzo.com> (raw)
perf with --namespace key leaks various memory objects including namespaces
# uname -r
4.14.0+
# perf record -q --namespace unshare -n -U -p --fork true
# grep namespace /proc/slabinfo
pid_namespace 1 12 2568 12 8
user_namespace 1 39 824 39 8
net_namespace 1 5 6272 5 8
This happen because perf_fill_ns_link_info() struct patch ns_path:
during initialization ns_path incremented counters on related mnt and dentry,
but without lost path_put nobody decremented them back.
Leaked dentry is name of related namespace,
and its leak does not allow to free unused namespace.
Fixes: commit e422267322cd ("perf: Add PERF_RECORD_NAMESPACES to include namespaces related info")
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
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);
}
}
--
2.7.4
next reply other threads:[~2017-11-15 5:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 5:47 Vasily Averin [this message]
2017-11-15 8:51 ` [tip:perf/urgent] perf/core: Fix memory leak " tip-bot for Vasily Averin
2017-11-29 6:15 ` tip-bot for Vasily Averin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c510711b-3904-e5e1-d296-61273d21118d@virtuozzo.com \
--to=vvs@virtuozzo.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=hbathini@linux.vnet.ibm.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®