From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, acme@redhat.com, mingo@elte.hu,
ak@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org,
cel@us.ibm.com, sukadev@linux.vnet.ibm.com,
sonnyrao@chromium.org, johnmccutchan@google.com,
dsahern@gmail.com, adrian.hunter@intel.com, pawel.moll@arm.com
Subject: Re: [PATCH v5 4/4] perf tools: add JVMTI agent library
Date: Fri, 27 Mar 2015 15:01:17 +0100 [thread overview]
Message-ID: <20150327140117.GF23123@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1427397429-14808-5-git-send-email-eranian@google.com>
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));
prev parent reply other threads:[~2015-03-27 14:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 19:17 [PATCH v5 0/4] perf: add support for profiling jitted code Stephane Eranian
2015-03-26 19:17 ` [PATCH v5 1/4] perf: Use monotonic clock as a source for timestamps Stephane Eranian
2015-03-26 19:17 ` [PATCH v5 2/4] perf tools: add Java demangling support Stephane Eranian
2015-03-26 19:17 ` [PATCH v5 3/4] perf inject: add jitdump mmap injection support Stephane Eranian
2015-03-26 19:17 ` [PATCH v5 4/4] perf tools: add JVMTI agent library Stephane Eranian
2015-03-27 14:01 ` Peter Zijlstra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150327140117.GF23123@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=cel@us.ibm.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=johnmccutchan@google.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=namhyung@kernel.org \
--cc=pawel.moll@arm.com \
--cc=sonnyrao@chromium.org \
--cc=sukadev@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®