From nobody Sat May 18 17:15:50 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4F2BC07E9D for ; Sun, 25 Sep 2022 02:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229589AbiIYC7T (ORCPT ); Sat, 24 Sep 2022 22:59:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbiIYC7M (ORCPT ); Sat, 24 Sep 2022 22:59:12 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D097243639 for ; Sat, 24 Sep 2022 19:59:11 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id p14so826864pjd.3 for ; Sat, 24 Sep 2022 19:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=OS4UYZ8DIUkJDvQP5tRmIq0ewNPcm5dr1beINkDXglI=; b=pMsNwRcTsrUwx4709l7bBQopVh9p8cTyUX4+N6zn0nGWfJ8aUJeAL6mO0gTX6Fasms v6I78Uu9UXJKgF9koM9Gqx2WiZ9DClMxdqnvUt/Qo2o2CF6QPdvNcnnS1J68fBRHlbAw 1ELy3Qr8uuE/wKvYsVvHYLnEmfvYXtu//PF3eBf37gXTqz9SdeNH0Qt8Rf5LoVmeECOG E1eJmnL8Ko/RY4KPHkoIGJVVSUbb0CHJ0Zk0ZMs01k4+9bKxesewUk4QsDCjk40Ih3q9 W5daZ9pOk/mE+CjCMPmT+2PpcxG/n3BcT6VvlGFxksLSc3bYw/U2+ptcBKiw1MCgLIbM PP5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=OS4UYZ8DIUkJDvQP5tRmIq0ewNPcm5dr1beINkDXglI=; b=QqmVeAZVD+sd40fSYpyN9GvH5Wf3g4QAgrcLh78D7RUZUyFqY6+DgEWhxMbMuNBFJ8 lnSGXjtqPZ8l4pFN3Cf9B1dbB4BN+pm4lM17eNj8Eg8qVe51H8y8JC4bmveyyacq39Aa Zi9/KCXrTmCXNxfl/7nyrbDYLbq/LsPJdqwRJAvybkchjyMQn7EcQiO9H7dKnT9irmEZ p2iTLIiWnCzlkSfVC296NAFljHtZxzcaxmuOWyG/VXTQxPQ/aMiMgIchHD5HjVbPCsO5 5vT2XbaPgharl8MIKFPVDajITULjazptEfSQGj9CWwTsYGixCh70j/1sFImMwv9F08Vo L97g== X-Gm-Message-State: ACrzQf1XjMHFGwgyue574FGl4Qs7BSb+tDaa/jpgHnj3hhToxokv+0RC R0xc0Ndv6mzBRcXSzYdtjMfHZg== X-Google-Smtp-Source: AMsMyM5joIJtYlA+twvlOzLjCdbWpan9i8/RzhsZZqMGnmVHxEZzaYDb9ZC1IigVr9ymwVaW1/gj5w== X-Received: by 2002:a17:90a:1b6e:b0:1f5:1902:af92 with SMTP id q101-20020a17090a1b6e00b001f51902af92mr29852232pjq.238.1664074751300; Sat, 24 Sep 2022 19:59:11 -0700 (PDT) Received: from leoy-huanghe.lan ([137.184.34.254]) by smtp.gmail.com with ESMTPSA id z11-20020a170903018b00b0016bf5557690sm8409198plg.4.2022.09.24.19.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 19:59:10 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v3 1/2] perf subcmd: Set environment variable "PREFIX" Date: Sun, 25 Sep 2022 10:58:34 +0800 Message-Id: <20220925025835.70364-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925025835.70364-1-leo.yan@linaro.org> References: <20220925025835.70364-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Set environment variable "PREFIX", it will be used by invoked shell script, e.g. the shell script uses it to find lib paths. Signed-off-by: Leo Yan --- tools/lib/subcmd/exec-cmd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/lib/subcmd/exec-cmd.c b/tools/lib/subcmd/exec-cmd.c index 33e94fb83986..5dbea456973e 100644 --- a/tools/lib/subcmd/exec-cmd.c +++ b/tools/lib/subcmd/exec-cmd.c @@ -24,6 +24,9 @@ void exec_cmd_init(const char *exec_name, const char *pre= fix, subcmd_config.prefix =3D prefix; subcmd_config.exec_path =3D exec_path; subcmd_config.exec_path_env =3D exec_path_env; + + /* Setup environment variable for invoked shell script. */ + setenv("PREFIX", prefix, 1); } =20 #define is_dir_sep(c) ((c) =3D=3D '/') --=20 2.34.1 From nobody Sat May 18 17:15:50 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A400BC07E9D for ; Sun, 25 Sep 2022 02:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229784AbiIYC7Z (ORCPT ); Sat, 24 Sep 2022 22:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbiIYC7S (ORCPT ); Sat, 24 Sep 2022 22:59:18 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA23E4454A for ; Sat, 24 Sep 2022 19:59:16 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id s14-20020a17090a6e4e00b0020057c70943so9420030pjm.1 for ; Sat, 24 Sep 2022 19:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=HwTvvHaQnXpVhdRORP97NwmhkzDfJTDDIupOGVxMbjo=; b=ZgBaza0msnPIVY09tayTWp+QQjlETTmQwJmOgr/CoS/qSoEXAQGJaYLH9aKt0W8XnK X8ypRlrYJQSviDFPkquHh3b1tnswjp4PiSrQP2CBgGCNZ0XcZHM0JqyXyO/59G9XYp9j nksqrEsSIa+5P6kL/7JoW7w+vBq1eNfkxIR55aahKhie0BVPPk7Xq+pCK4ERuO54Hf9H nNZC3/dtWP6LWaIqTSgH9P+jagKaByr9iR/bSDiSBXIaN9aIY37tXML+I9C8hT+J5NeN HnY7celDq/AtLnfWNs2G7HSUsJ8eb7eTZ1Rb7LHRhSzWXfQ7lpsEBVHwaMbbXKGUpZH7 UQYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HwTvvHaQnXpVhdRORP97NwmhkzDfJTDDIupOGVxMbjo=; b=DjA7lYTvkVsIIyLMIcEgTsursls/SttYnh2YUzka8Ksxw9uRPmst3S9UV8BotO9Q3J xvdxkE0SYUSMejaaE6ukFqyZ8x6DzUATaamp8mWnNPQTUG4JPeBg2X4AH4p0WH+lZx8G uJBvCxWtE9NB1UOR+D/CTOM39G3q078ePi6FwtCW826YsXEFh7WP5m8EhZ75r+KtUc+a QjVZ78rVUBWff0uO5cM/BEpmy+oxseU7FZ7pdGcx4Py1xQRlfBmUElQUIOPJT1wqSvbM c6jfsoDYUp12BbMdNKbbWYKpzqZV0gSSM9vxPbBLPRuwytWz+y+6vGBNrcCP0xujxzms 1a8Q== X-Gm-Message-State: ACrzQf2SNGQAolYURvZRlLQ3cZWY1T24obSIq4+fiMmwqXRpNBwgdJfF Bo9IwJ+5ap6CUhgXBd9rLhiBNw== X-Google-Smtp-Source: AMsMyM5lJ5Qlh7efWt9kQk8UedtdV39ouMD6V7ZF6S46Zp1jz8tt/NpLLrSnxcjhT9vtw/bU0Zx0Cw== X-Received: by 2002:a17:90a:ce82:b0:200:aca2:5a19 with SMTP id g2-20020a17090ace8200b00200aca25a19mr29655101pju.156.1664074756070; Sat, 24 Sep 2022 19:59:16 -0700 (PDT) Received: from leoy-huanghe.lan ([137.184.34.254]) by smtp.gmail.com with ESMTPSA id z11-20020a170903018b00b0016bf5557690sm8409198plg.4.2022.09.24.19.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Sep 2022 19:59:15 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Cc: Leo Yan Subject: [PATCH v3 2/2] perf test: Introduce script for java symbol testing Date: Sun, 25 Sep 2022 10:58:35 +0800 Message-Id: <20220925025835.70364-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925025835.70364-1-leo.yan@linaro.org> References: <20220925025835.70364-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This commit introduces a script for testing java symbols. The test records java program, inject samples with JIT samples, check specific JIT symbols in the report, the test will pass only when these two symbols are detected. Suggested-by: Ian Rogers Signed-off-by: Leo Yan --- tools/perf/tests/shell/test_java_symbol.sh | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 tools/perf/tests/shell/test_java_symbol.sh diff --git a/tools/perf/tests/shell/test_java_symbol.sh b/tools/perf/tests/= shell/test_java_symbol.sh new file mode 100755 index 000000000000..f221225808a3 --- /dev/null +++ b/tools/perf/tests/shell/test_java_symbol.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# Test java symbol + +# SPDX-License-Identifier: GPL-2.0 +# Leo Yan , 2022 + +# skip if there's no jshell +if ! [ -x "$(command -v jshell)" ]; then + echo "skip: no jshell, install JDK" + exit 2 +fi + +PERF_DATA=3D$(mktemp /tmp/__perf_test.perf.data.XXXXX) +PERF_INJ_DATA=3D$(mktemp /tmp/__perf_test.perf.data.inj.XXXXX) + +cleanup_files() +{ + echo "Cleaning up files..." + rm -f ${PERF_DATA} + rm -f ${PERF_INJ_DATA} +} + +trap cleanup_files exit term int + +if [ -e "$PWD/tools/perf/libperf-jvmti.so" ]; then + LIBJVMTI=3D$PWD/tools/perf/libperf-jvmti.so +elif [ -e "$PWD/libperf-jvmti.so" ]; then + LIBJVMTI=3D$PWD/libperf-jvmti.so +elif [ -e "$PREFIX/lib64/libperf-jvmti.so" ]; then + LIBJVMTI=3D$PREFIX/lib64/libperf-jvmti.so +elif [ -e "$PREFIX/lib/libperf-jvmti.so" ]; then + LIBJVMTI=3D$PREFIX/lib/libperf-jvmti.so +elif [ -e "/usr/lib/linux-tools-$(uname -a | awk '{ print $3 }' | sed -r '= s/-generic//')/libperf-jvmti.so" ]; then + LIBJVMTI=3D/usr/lib/linux-tools-$(uname -a | awk '{ print $3 }' | sed -r = 's/-generic//')/libperf-jvmti.so +else + echo "Fail to find libperf-jvmti.so" + # JVMTI is a build option, skip the test if fail to find lib + exit 2 +fi + +cat < 1 ? fib(x - 2) + fib(x - 1) : 1; +} + +int q =3D 0; + +for (int i =3D 0; i < 10; i++) + q +=3D fib(i); + +System.out.println(q); +EOF + +if [ $? -ne 0 ]; then + echo "Fail to record for java program" + exit 1 +fi + +if ! perf inject -i $PERF_DATA -o $PERF_INJ_DATA -j; then + echo "Fail to inject samples" + exit 1 +fi + +# Below is an example of the instruction samples reporting: +# 8.18% jshell jitted-50116-29.so [.] Interpreter +# 0.75% Thread-1 jitted-83602-1670.so [.] jdk.internal.jimage.= BasicImageReader.getString(int) +perf report --stdio -i ${PERF_INJ_DATA} 2>&1 | \ + egrep " +[0-9]+\.[0-9]+% .* (Interpreter|jdk\.internal).*" > /dev/null 2>= &1 + +if [ $? -ne 0 ]; then + echo "Fail to find java symbols" + exit 1 +fi + +exit 0 --=20 2.34.1