[PATCH 13/15] perf tools: Add support to dynamically get cacheline size

From: Jiri Olsa
Date: Mon Jun 09 2014 - 16:05:16 EST


From: Don Zickus <dzickus@xxxxxxxxxx>

Different arches may have different cacheline sizes. Look it up and set
a global variable for reference.

Signed-off-by: Don Zickus <dzickus@xxxxxxxxxx>
Link: http://lkml.kernel.org/r/1401480605-97442-1-git-send-email-dzickus@xxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/perf.c | 1 +
tools/perf/util/util.c | 1 +
tools/perf/util/util.h | 1 +
3 files changed, 3 insertions(+)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 78f7b92..95c58fc 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -458,6 +458,7 @@ int main(int argc, const char **argv)

/* The page_size is placed in util object. */
page_size = sysconf(_SC_PAGE_SIZE);
+ cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);

cmd = perf_extract_argv0_path(argv[0]);
if (!cmd)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 7fff6be..95aefa7 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -17,6 +17,7 @@
* XXX We need to find a better place for these things...
*/
unsigned int page_size;
+int cacheline_size;

bool test_attr__enabled;

diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index b03da44..6686436 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -304,6 +304,7 @@ char *rtrim(char *s);
void dump_stack(void);

extern unsigned int page_size;
+extern int cacheline_size;

void get_term_dimensions(struct winsize *ws);

--
1.8.3.1

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