lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 09 Dec 2015 11:10:57 +0900
From:	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Adrian Hunter <adrian.hunter@...el.com>,
	linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
	Ingo Molnar <mingo@...hat.com>,
	Namhyung Kim <namhyung@...nel.org>,
	Jiri Olsa <jolsa@...hat.com>
Subject: [PATCH perf/core 04/22] perf refcnt: refcnt shows summary per object

Report refcnt per object(class) summary numbers if
any leaks exist, not only the total number.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
---
 tools/perf/util/refcnt.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/tools/perf/util/refcnt.c b/tools/perf/util/refcnt.c
index e83e9a8..5348406 100644
--- a/tools/perf/util/refcnt.c
+++ b/tools/perf/util/refcnt.c
@@ -157,8 +157,48 @@ static void pr_refcnt_object(struct refcnt_object *ref)
 		pr_refcnt_buffer(buf);
 }
 
+#define REFCNT_STAT_NUM	16
+static struct refcnt_stat_entry {
+	int counter;
+	const char *name;
+} stat_entry[REFCNT_STAT_NUM] = { {.name = "(others)"}, };
+
+static struct refcnt_stat_entry *refcnt_stat__find_entry(const char *name)
+{
+	int i;
+
+	if (!name)
+		goto last;
+
+	for (i = 1; i < REFCNT_STAT_NUM; i++)
+		if (stat_entry[i].name) {
+			if (strcmp(stat_entry[i].name, name) == 0)
+				return &stat_entry[i];
+		} else {
+			stat_entry[i].name = name;
+			return &stat_entry[i];
+		}
+last:
+	/* Here, it shorts the slot, let it fold to others */
+	return &stat_entry[0];
+}
+
+static void pr_refcnt_stat(void)
+{
+	int i;
+
+	for (i = 1; i < REFCNT_STAT_NUM && stat_entry[i].name; i++)
+		pr_warning("  \"%s\" leaks %d objects\n",
+			   stat_entry[i].name, stat_entry[i].counter);
+
+	if (stat_entry[0].counter)
+		pr_warning("  And others leak %d objects\n",
+			stat_entry[0].counter);
+}
+
 static void  __attribute__((destructor)) refcnt__dump_unreclaimed(void)
 {
+	struct refcnt_stat_entry *ent;
 	struct refcnt_object *ref, *n;
 	int h, i = 0;
 
@@ -174,11 +214,15 @@ found:
 				pr_debug("==== [%d] ====\n", i);
 				pr_refcnt_object(ref);
 			}
+			ent = refcnt_stat__find_entry(ref->name);
+			if (ent)
+				ent->counter++;
 			refcnt_object__delete(ref);
 			i++;
 		}
 
 	pr_warning("REFCNT: Total %d objects are not reclaimed.\n", i);
+	pr_refcnt_stat();
 	if (!verbose)
 		pr_warning("   To see all backtraces, rerun with -v option\n");
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ