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


Groups > linux.kernel > #1166305

[PATCH 05/10] perf tools: Introduce xyarray__reset function

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 05/10] perf tools: Introduce xyarray__reset function
Date 2015-06-16 20:30 +0200
Message-ID <pC3Mu-22f-13@gated-at.bofh.it> (permalink)
References <pC3Mu-22f-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Jiri Olsa <jolsa@kernel.org>

To zero all the xyarray contents. It will be used in following patches.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1434269985-521-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/xyarray.c | 8 ++++++++
 tools/perf/util/xyarray.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/tools/perf/util/xyarray.c b/tools/perf/util/xyarray.c
index 22afbf6c536a..c10ba41ef3f6 100644
--- a/tools/perf/util/xyarray.c
+++ b/tools/perf/util/xyarray.c
@@ -9,11 +9,19 @@ struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size)
 	if (xy != NULL) {
 		xy->entry_size = entry_size;
 		xy->row_size   = row_size;
+		xy->entries    = xlen * ylen;
 	}
 
 	return xy;
 }
 
+void xyarray__reset(struct xyarray *xy)
+{
+	size_t n = xy->entries * xy->entry_size;
+
+	memset(xy->contents, 0, n);
+}
+
 void xyarray__delete(struct xyarray *xy)
 {
 	free(xy);
diff --git a/tools/perf/util/xyarray.h b/tools/perf/util/xyarray.h
index c488a07275dd..7f30af371b7e 100644
--- a/tools/perf/util/xyarray.h
+++ b/tools/perf/util/xyarray.h
@@ -6,11 +6,13 @@
 struct xyarray {
 	size_t row_size;
 	size_t entry_size;
+	size_t entries;
 	char contents[];
 };
 
 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
 void xyarray__delete(struct xyarray *xy);
+void xyarray__reset(struct xyarray *xy);
 
 static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
 {
-- 
2.1.0

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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200
  [PATCH 02/10] perf tools: Replace map->referenced & maps->removed_maps with map->refcnt Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200
  [PATCH 05/10] perf tools: Introduce xyarray__reset function Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200
  [PATCH 08/10] perf stat: Introduce perf_counts__(new|delete|reset) functions Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200
  [PATCH 10/10] perf probe: Fix to return error if no probe is added Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200
  [PATCH 09/10] perf unwind: Fix a compile error Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200
  [PATCH 01/10] perf probe: Cut off the gcc optimization postfixes from function name Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200
  [PATCH 03/10] tools lib traceevent: Fix python/perf.so compiling error Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200
  [PATCH 07/10] perf tools: Move perf_evsel__(alloc|free|reset)_counts into stat object Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-06-16 20:30 +0200

csiph-web