[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <51b38c17-4cb7-467b-8606-fae51f629802@linaro.org>
Date: Wed, 24 Dec 2025 10:39:18 +0000
From: James Clark <james.clark@...aro.org>
To: Haoxiang Li <lihaoxiang@...c.iscas.ac.cn>
Cc: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
namhyung@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org, irogers@...gle.com,
adrian.hunter@...el.com, yuzhuo@...gle.com
Subject: Re: [PATCH] perf jit: close agent in Agent_OnLoad()
On 24/12/2025 3:56 am, Haoxiang Li wrote:
> close agent on error paths in Agent_OnLoad().
>
> Signed-off-by: Haoxiang Li <lihaoxiang@...c.iscas.ac.cn>
> ---
> tools/perf/jvmti/libjvmti.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/jvmti/libjvmti.c b/tools/perf/jvmti/libjvmti.c
> index 82514e6532b8..fd7efae40102 100644
> --- a/tools/perf/jvmti/libjvmti.c
> +++ b/tools/perf/jvmti/libjvmti.c
> @@ -355,7 +355,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved __maybe_unused)
> ret = (*jvm)->GetEnv(jvm, (void *)&jvmti, JVMTI_VERSION_1);
> if (ret != JNI_OK) {
> warnx("jvmti: jvmti version 1 not supported");
> - return -1;
> + goto close_agent;
> }
>
> /*
> @@ -368,7 +368,7 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved __maybe_unused)
> ret = (*jvmti)->AddCapabilities(jvmti, &caps1);
> if (ret != JVMTI_ERROR_NONE) {
> print_error(jvmti, "AddCapabilities", ret);
> - return -1;
> + goto close_agent;
> }
> ret = (*jvmti)->GetJLocationFormat(jvmti, &format);
> if (ret == JVMTI_ERROR_NONE && format == JVMTI_JLOCATION_JVMBCI) {
> @@ -390,23 +390,27 @@ Agent_OnLoad(JavaVM *jvm, char *options, void *reserved __maybe_unused)
> ret = (*jvmti)->SetEventCallbacks(jvmti, &cb, sizeof(cb));
> if (ret != JVMTI_ERROR_NONE) {
> print_error(jvmti, "SetEventCallbacks", ret);
> - return -1;
> + goto close_agent;
> }
>
> ret = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
> JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL);
> if (ret != JVMTI_ERROR_NONE) {
> print_error(jvmti, "SetEventNotificationMode(METHOD_LOAD)", ret);
> - return -1;
> + goto close_agent;
> }
>
> ret = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
> JVMTI_EVENT_DYNAMIC_CODE_GENERATED, NULL);
> if (ret != JVMTI_ERROR_NONE) {
> print_error(jvmti, "SetEventNotificationMode(CODE_GENERATED)", ret);
> - return -1;
> + goto close_agent;
> }
> return 0;
> +
> +close_agent:
> + jvmti_close(jvmti_agent);
Does this actually do anything? jvmti_close() is already called in
Agent_OnUnload().
The commit message is lacking any details about how this was found or
what the effect is.
> + return -1;
> }
>
> JNIEXPORT void JNICALL
Powered by blists - more mailing lists