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, 28 Nov 2012 14:52:49 +0100
From:	Jiri Olsa <jolsa@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Jiri Olsa <jolsa@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Ingo Molnar <mingo@...e.hu>, Paul Mackerras <paulus@...ba.org>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Namhyung Kim <namhyung@...nel.org>
Subject: [PATCH 14/14] perf diff: Add generic order option for compute sorting

Adding option 'o' to allow sorting based on the
input file number.

Signed-off-by: Jiri Olsa <jolsa@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/Documentation/perf-diff.txt |  4 +++
 tools/perf/builtin-diff.c              | 53 +++++++++++++++-------------------
 2 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
index ab5b79e..1402e14 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -91,6 +91,10 @@ OPTIONS
 --formula::
         Show formula for given computation.
 
+-o::
+--order::
+       Specify compute sorting column number.
+
 COMPARISON
 ----------
 The comparison is governed by the baseline file. The baseline perf.data
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index b801d0c..1f98786 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -65,7 +65,7 @@ static bool show_displacement;
 static bool show_period;
 static bool show_formula;
 static bool show_baseline_only;
-static bool sort_compute;
+static unsigned int sort_compute;
 
 static s64 compute_wdiff_w1;
 static s64 compute_wdiff_w2;
@@ -191,13 +191,6 @@ static int setup_compute(const struct option *opt, const char *str,
 		return 0;
 	}
 
-	if (*str == '+') {
-		sort_compute = true;
-		cstr = (char *) ++str;
-		if (!*str)
-			return 0;
-	}
-
 	option = strchr(str, ':');
 	if (option) {
 		unsigned len = option++ - str;
@@ -533,31 +526,27 @@ static int64_t
 hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,
 			int c)
 {
-	int i;
+	struct hist_entry **pairs_left  = left->pairs;
+	struct hist_entry **pairs_right = right->pairs;
+	struct hist_entry *p_right, *p_left;
+	static int64_t cmp;
 
-	for (i = 0; i < data_cnt; i++) {
-		struct hist_entry **pairs_left  = left->pairs;
-		struct hist_entry **pairs_right = right->pairs;
-		struct hist_entry *p_right, *p_left;
-		static int64_t cmp;
+	if (!pairs_left || !pairs_right)
+		return pairs_left ? -1 : 1;
 
-		if (!pairs_left || !pairs_right)
-			return pairs_right - pairs_left;
+	p_right = pairs_right[sort_compute];
+	p_left  = pairs_left[sort_compute];
 
-		p_right = pairs_right[i];
-		p_left  = pairs_left[i];
+	if (!p_left || !p_right)
+		return p_left ? -1 : 1;
 
-		if (!p_left || !p_right)
-			return p_right - p_left;
-
-		/*
-		 * If we differ, we are done, otherwise continue until all
-		 * is processed or we find a difference.
-		 */
-		cmp = __hist_entry__cmp_compute(p_left, p_right, c);
-		if (cmp)
-			return cmp;
-	}
+	/*
+	 * If we differ, we are done, otherwise continue until all
+	 * is processed or we find a difference.
+	 */
+	cmp = __hist_entry__cmp_compute(p_left, p_right, c);
+	if (cmp)
+		return cmp;
 
 	return 0;
 }
@@ -759,6 +748,7 @@ static const struct option options[] = {
 		   "columns '.' is reserved."),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
 		    "Look for files with symbols relative to this directory"),
+	OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."),
 	OPT_END()
 };
 
@@ -1087,6 +1077,11 @@ static int data_init(int argc, const char **argv)
 		d->idx  = i;
 	}
 
+	if (sort_compute >= (unsigned int) data_cnt) {
+		pr_err("Order option out of limit.\n");
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
-- 
1.7.11.7

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