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:	Sun,  2 Feb 2014 22:38:51 +0100
From:	Jiri Olsa <jolsa@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Jiri Olsa <jolsa@...hat.com>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...e.hu>,
	Namhyung Kim <namhyung@...nel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	David Ahern <dsahern@...il.com>
Subject: [PATCH 03/22] perf tools: Add idx sort entry

Adding idx sort entry to have a way sort entries
the way they are stored in the data file.

Signed-off-by: Jiri Olsa <jolsa@...hat.com>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: David Ahern <dsahern@...il.com>
---
 tools/perf/util/hist.c |  2 ++
 tools/perf/util/hist.h |  1 +
 tools/perf/util/sort.c | 23 +++++++++++++++++++++++
 tools/perf/util/sort.h |  2 ++
 4 files changed, 28 insertions(+)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index cf7d7e0..2ecb976 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -438,6 +438,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
 				      u64 period, u64 weight, u64 transaction,
 				      u64 t, bool sample_self)
 {
+	static u64 idx;
 	struct hist_entry entry = {
 		.thread	= al->thread,
 		.comm = thread__comm(al->thread),
@@ -460,6 +461,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
 		.mem_info = mi,
 		.transaction = transaction,
 		.time = t,
+		.idx  = idx++,
 	};
 
 	return add_hist_entry(hists, &entry, al, sample_self);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 851beef..ae403a6 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -70,6 +70,7 @@ enum hist_column {
 	HISTC_MEM_SNOOP,
 	HISTC_TRANSACTION,
 	HISTC_TIME,
+	HISTC_IDX,
 	HISTC_NR_COLS, /* Last entry */
 };
 
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 9438617..5607edb 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -55,6 +55,28 @@ static int64_t cmp_null(const void *l, const void *r)
 		return 1;
 }
 
+/* --sort idx */
+
+static int64_t
+sort__idx_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+	return right->idx - left->idx;
+}
+
+static int hist_entry__idx_snprintf(struct hist_entry *he, char *bf,
+				    size_t size, unsigned int width)
+{
+	return repsep_snprintf(bf, size, "%*lu", width, he->idx);
+}
+
+struct sort_entry sort_idx = {
+	.se_header	= "Idx",
+	.se_cmp		= sort__idx_cmp,
+	.se_snprintf	= hist_entry__idx_snprintf,
+	.se_width_idx	= HISTC_IDX,
+};
+
+
 /* --sort time */
 
 static int64_t
@@ -1048,6 +1070,7 @@ static struct sort_dimension common_sort_dimensions[] = {
 	DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight),
 	DIM(SORT_TRANSACTION, "transaction", sort_transaction),
 	DIM(SORT_TIME, "time", sort_time),
+	DIM(SORT_IDX, "idx", sort_idx),
 };
 
 #undef DIM
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 4eb684e..666bf0b 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -89,6 +89,7 @@ struct hist_entry {
 	u64			transaction;
 	s32			cpu;
 	u64			time;
+	u64			idx;
 
 	struct hist_entry_diff	diff;
 
@@ -165,6 +166,7 @@ enum sort_type {
 	SORT_GLOBAL_WEIGHT,
 	SORT_TRANSACTION,
 	SORT_TIME,
+	SORT_IDX,
 
 	/* branch stack specific sort keys */
 	__SORT_BRANCH_STACK,
-- 
1.8.3.1

--
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