[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20150327140117.GF23123@twins.programming.kicks-ass.net>
Date: Fri, 27 Mar 2015 15:01:17 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Stephane Eranian <eranian@...gle.com>
Cc: linux-kernel@...r.kernel.org, acme@...hat.com, mingo@...e.hu,
ak@...ux.intel.com, jolsa@...hat.com, namhyung@...nel.org,
cel@...ibm.com, sukadev@...ux.vnet.ibm.com, sonnyrao@...omium.org,
johnmccutchan@...gle.com, dsahern@...il.com,
adrian.hunter@...el.com, pawel.moll@....com
Subject: Re: [PATCH v5 4/4] perf tools: add JVMTI agent library
On Thu, Mar 26, 2015 at 08:17:09PM +0100, Stephane Eranian wrote:
> This version of the JVMTI agent is using Pawel Moll's CLOCK_MONOTONIC
> perf clock patch posted here:
> https://lkml.org/lkml/2015/1/21/711
Seeing how we just merged its replacement:
http://git.kernel.org/tip/34f439278cef7b1177f8ce24f9fc81dfc6221d3b
how about something like this to make it work?
Completely not been near a compiler at all. I'll go do the regular perf
userspace part now I suppose -- I had somewhat forgotten about that.
---
--- a/tools/perf/jvmti/jvmti_agent.c
+++ b/tools/perf/jvmti/jvmti_agent.c
@@ -36,6 +36,8 @@
#include <syscall.h> /* for gettid() */
#include <err.h>
+#include "perf-sys.h"
+
#include "jvmti_agent.h"
#include "../util/jitdump.h"
@@ -92,37 +94,44 @@ static int get_e_machine(struct jitheade
return ret;
}
-#define NSEC_PER_SEC 1000000000
-static int perf_clk_id;
-static int
-perf_get_clock_id(void)
-{
- FILE *fp;
- int ret;
-
- fp = fopen("/proc/sys/kernel/perf_sample_time_clk_id", "r");
- if (!fp)
- return -1;
- ret = fscanf(fp, "%d", &perf_clk_id);
+static clockid_t jit_clockid = CLOCK_MONOTONIC_RAW;
- fclose(fp);
-
- return ret == 1 ? 0 : -1;
-}
+#define NSEC_PER_SEC 1000000000
static int
perf_open_timestamp(void)
{
+ struct perf_event_attr perf_attr = {
+ .type = PERF_TYPE_SOFTWARE,
+ .config = PERF_COUNT_SW_DUMMY,
+ .exclude_kernel = 1,
+ .use_clockid = 1,
+ };
struct timespec ts;
+ char *clk;
int ret;
- if (perf_get_clock_id())
- return -1;
+ clk = getenv("JITCLOCKID");
+ if (clk) {
+ ret = sscanf(clk, "%d", &jit_clockid);
+ if (ret != 1)
+ return -1;
+ }
+
/*
- * check if clock_id is actually available
+ * check if jit_clockid is actually available
*/
- ret = clock_gettime(perf_clk_id, &ts);
- return ret ? -1 : 0;
+ ret = clock_gettime(jit_clockid, &ts);
+ if (ret)
+ return ret;
+
+ perf_attr.clockid = jit_clockid;
+ ret = sys_perf_event_open(&perf_attr, 0, -1, -1, 0);
+ if (ret < 0)
+ return ret;
+
+ close(ret);
+ return 0;
}
static inline uint64_t
@@ -137,7 +146,7 @@ perf_get_timestamp(void)
struct timespec ts;
int ret;
- ret = clock_gettime(perf_clk_id, &ts);
+ ret = clock_gettime(jit_clockid, &ts);
if (ret)
return 0;
@@ -242,7 +251,7 @@ void *jvmti_open(void)
FILE *fp;
if (perf_open_timestamp())
- warnx("jvmti: kernel does not support %d clock id", perf_clk_id);
+ warnx("jvmti: kernel does not support %d clock id", jit_clockid);
memset(&header, 0, sizeof(header));
--
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