Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1303201 > unrolled thread

[PATCH v4 2/5] perf tools: Separate hpp->sort callback for dynamic sort keys

Started byNamhyung Kim <namhyung@kernel.org>
First post2016-01-07 01:20 +0100
Last post2016-01-07 01:20 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v4 2/5] perf tools: Separate hpp->sort callback for dynamic sort keys Namhyung Kim <namhyung@kernel.org> - 2016-01-07 01:20 +0100

#1303201 — [PATCH v4 2/5] perf tools: Separate hpp->sort callback for dynamic sort keys

FromNamhyung Kim <namhyung@kernel.org>
Date2016-01-07 01:20 +0100
Subject[PATCH v4 2/5] perf tools: Separate hpp->sort callback for dynamic sort keys
Message-ID<qO6t4-5O-15@gated-at.bofh.it>
The ->sort callback is used for final output sorting.  As it's called
after processing all hist entries, it doesn't need to update dynamic
length anymore.  Also it needs additional handling to sort them
properly (which is the topic of next patch).

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/sort.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 425097d2a1cd..e8a5cdee3f0d 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1798,6 +1798,30 @@ static int64_t __sort__hde_cmp(struct perf_hpp_fmt *fmt,
 	return memcmp(b->raw_data + offset, a->raw_data + offset, size);
 }
 
+static int64_t __sort__hde_sort(struct perf_hpp_fmt *fmt,
+				struct hist_entry *a, struct hist_entry *b)
+{
+	struct hpp_dynamic_entry *hde;
+	struct format_field *field;
+	unsigned offset, size;
+
+	hde = container_of(fmt, struct hpp_dynamic_entry, hpp);
+
+	field = hde->field;
+	if (field->flags & FIELD_IS_DYNAMIC) {
+		unsigned long long dyn;
+
+		pevent_read_number_field(field, a->raw_data, &dyn);
+		offset = dyn & 0xffff;
+		size = (dyn >> 16) & 0xffff;
+	} else {
+		offset = field->offset;
+		size = field->size;
+	}
+
+	return memcmp(b->raw_data + offset, a->raw_data + offset, size);
+}
+
 bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *fmt)
 {
 	return fmt->cmp == __sort__hde_cmp;
@@ -1826,7 +1850,7 @@ __alloc_dynamic_entry(struct perf_evsel *evsel, struct format_field *field)
 
 	hde->hpp.cmp = __sort__hde_cmp;
 	hde->hpp.collapse = __sort__hde_cmp;
-	hde->hpp.sort = __sort__hde_cmp;
+	hde->hpp.sort = __sort__hde_sort;
 
 	INIT_LIST_HEAD(&hde->hpp.list);
 	INIT_LIST_HEAD(&hde->hpp.sort_list);
-- 
2.6.4

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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web