From nobody Sun Feb 8 05:34:49 2026 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 90E47C71153 for ; Sun, 3 Sep 2023 11:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236688AbjICLrk (ORCPT ); Sun, 3 Sep 2023 07:47:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236665AbjICLrj (ORCPT ); Sun, 3 Sep 2023 07:47:39 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23586126; Sun, 3 Sep 2023 04:47:36 -0700 (PDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 383Bd7FM023912; Sun, 3 Sep 2023 11:47:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=7/qzzqZDZY2en0Oo+RtwLKoDTLsxQP53D7wuM++KXGg=; b=USMeUKdUacQBZLYCT23qrFnNnpdz6Axz3NZKiughfFbUO08aoH6b3pUFoY+j0skfGJpe J32QckguxpuuFYS26DV19z90SkYVv+qKgagSzrpt1nt6rO8BCEFwfRad5NWEWkP1pl3m T7xLWIPgGpdPPEcvGkdK0i/tEsgSM8kZKSeTGh5F5AEZKIPDPxTFE/luOSwW87cY82C9 EhwuaS3dHqi4deVnopiOng6OjmhlFoxA2thGpNlayCFK9kkO8CCVxXXqqRNRs0bKrZx9 8VpNCHm/QDYk+COen8TVLeDqbKWI2UpT7180VqSL9/1vWjzOBQ+wxoMEtqG7k1jNwQmt nA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3svs7b884v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:31 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 383BdJWH024768; Sun, 3 Sep 2023 11:47:31 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3svs7b884u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:31 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3839p0gO021441; Sun, 3 Sep 2023 11:47:30 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3svfrxu5vf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:30 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 383BlRGr19202652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 3 Sep 2023 11:47:27 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 886332004B; Sun, 3 Sep 2023 11:47:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5996920043; Sun, 3 Sep 2023 11:47:25 +0000 (GMT) Received: from li-3c92a0cc-27cf-11b2-a85c-b804d9ca68fa.ibm.com.com (unknown [9.171.15.154]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Sun, 3 Sep 2023 11:47:25 +0000 (GMT) From: Aditya Gupta To: acme@kernel.org, jolsa@kernel.org, irogers@google.com, namhyung@kernel.org Cc: linux-perf-users@vger.kernel.org, maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com, kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] perf check: introduce check subcommand Date: Sun, 3 Sep 2023 17:17:18 +0530 Message-ID: <20230903114721.190733-2-adityag@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230903114721.190733-1-adityag@linux.ibm.com> References: <20230903114721.190733-1-adityag@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: t4ODsbb94TDq7fV9dLTNyMK_9_ZHKnVm X-Proofpoint-GUID: g_loMOxvW8P9dS_atuV3doF-mLNgrV9O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-03_09,2023-08-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 clxscore=1015 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309030108 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Currently the presence of a feature is checked with a combination of perf version --build-options and greps, such as: perf version --build-options | grep " on .* HAVE_FEATURE" Instead of this, introduce a subcommand "perf check --feature", with which scripts can test for presence of a feature, such as: perf check --feature HAVE_FEATURE 'perf check --feature' command is expected to have exit status of 1 if feat= ure is built-in, and 0 if not, -2 if feature is not known. A global array 'supported_features' has also been introduced that can be used by other commands like 'perf version --build-options', so that new features can be added in one place, with the array Signed-off-by: Aditya Gupta --- tools/perf/Build | 1 + tools/perf/Documentation/perf-check.txt | 53 ++++++++++++++ tools/perf/builtin-check.c | 95 +++++++++++++++++++++++++ tools/perf/builtin.h | 47 ++++++++++++ tools/perf/perf.c | 1 + 5 files changed, 197 insertions(+) create mode 100644 tools/perf/Documentation/perf-check.txt create mode 100644 tools/perf/builtin-check.c diff --git a/tools/perf/Build b/tools/perf/Build index aa7623622834..a55a797c1b5f 100644 --- a/tools/perf/Build +++ b/tools/perf/Build @@ -1,5 +1,6 @@ perf-y +=3D builtin-bench.o perf-y +=3D builtin-annotate.o +perf-y +=3D builtin-check.o perf-y +=3D builtin-config.o perf-y +=3D builtin-diff.o perf-y +=3D builtin-evlist.o diff --git a/tools/perf/Documentation/perf-check.txt b/tools/perf/Documenta= tion/perf-check.txt new file mode 100644 index 000000000000..ee4331838be5 --- /dev/null +++ b/tools/perf/Documentation/perf-check.txt @@ -0,0 +1,53 @@ +perf-check(1) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +NAME +---- +perf-check - check features in perf + +SYNOPSIS +-------- +'perf check' [--feature] + +DESCRIPTION +----------- +With no options given, the 'perf check' just prints the perf version +on the standard output. + +If the option '--feature' is given, then status of feature is printed +on the standard output, ie. whether it is compiled-in/built-in or not + +OPTIONS +------- +--feature:: + Print whether a feature is compiled-in or not. A feature name/macr= o is + required to be passed after this flag + + Example Usage: + perf check --feature libtraceevent + perf check --feature HAVE_LIBTRACEEVENT + + Supported feature names/macro: + dwarf / HAVE_DWARF_SUPPORT + dwarf_getlocations / HAVE_DWARF_GETLOCATIONS_SUPPORT + libaudit / HAVE_LIBAUDIT_SUPPORT + syscall_table / HAVE_SYSCALL_TABLE_SUPPORT + libbfd / HAVE_LIBBFD_SUPPORT + debuginfod / HAVE_DEBUGINFOD_SUPPORT + libelf / HAVE_LIBELF_SUPPORT + libnuma / HAVE_LIBNUMA_SUPPORT + numa_num_possible_cpus / HAVE_LIBNUMA_SUPPORT + libperl / HAVE_LIBPERL_SUPPORT + libpython / HAVE_LIBPYTHON_SUPPORT + libslang / HAVE_SLANG_SUPPORT + libcrypto / HAVE_LIBCRYPTO_SUPPORT + libunwind / HAVE_LIBUNWIND_SUPPORT + libdw-dwarf-unwind / HAVE_DWARF_SUPPORT + zlib / HAVE_ZLIB_SUPPORT + lzma / HAVE_LZMA_SUPPORT + get_cpuid / HAVE_AUXTRACE_SUPPORT + bpf / HAVE_LIBBPF_SUPPORT + aio / HAVE_AIO_SUPPORT + zstd / HAVE_ZSTD_SUPPORT + libpfm4 / HAVE_LIBPFM + libtraceevent / HAVE_LIBTRACEEVENT diff --git a/tools/perf/builtin-check.c b/tools/perf/builtin-check.c new file mode 100644 index 000000000000..3dee72426c30 --- /dev/null +++ b/tools/perf/builtin-check.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "builtin.h" +#include "color.h" +#include "util/debug.h" +#include "util/header.h" +#include +#include +#include +#include +#include + +struct check { + const char *feature; +}; + +static struct check check; + +static struct option check_options[] =3D { + OPT_STRING(0, "feature", &check.feature, NULL, "check if a feature is bui= lt in"), + OPT_END(), +}; + +static const char * const check_usage[] =3D { + "perf check []", + NULL +}; + +static void on_off_print(const char *status) +{ + printf("[ "); + + if (!strcmp(status, "OFF")) + color_fprintf(stdout, PERF_COLOR_RED, "%-3s", status); + else + color_fprintf(stdout, PERF_COLOR_GREEN, "%-3s", status); + + printf(" ]"); +} + +static void status_print(const char *name, const char *macro, + const char *status) +{ + printf("%22s: ", name); + on_off_print(status); + printf(" # %s\n", macro); +} + +#define STATUS(feature) \ +do { \ + if (feature.is_builtin) \ + status_print(feature.name, feature.macro, "on"); \ + else \ + status_print(feature.name, feature.macro, "OFF"); \ +} while (0) + +/** + * check whether "feature" is built-in with perf + * returns: + * -1: Feature not known + * 0: Built-in + * 1: NOT Built in + */ +static int has_support(const char *feature) +{ + int res =3D -1; + + for (int i =3D 0; supported_features[i].name; ++i) { + if ((strcmp(feature, supported_features[i].name) =3D=3D 0) || + (strcmp(feature, supported_features[i].macro) =3D=3D 0)) { + res =3D supported_features[i].is_builtin; + STATUS(supported_features[i]); + break; + } + } + + if (res =3D=3D -1) { + color_fprintf(stdout, PERF_COLOR_RED, "Feature not known: %s", feature); + return -2; + } + + return !res; +} + +int cmd_check(int argc, const char **argv) +{ + argc =3D parse_options(argc, argv, check_options, check_usage, + PARSE_OPT_STOP_AT_NON_OPTION); + + printf("perf check %s\n", perf_version_string); + + if (check.feature) + return has_support(check.feature); + + return 0; +} diff --git a/tools/perf/builtin.h b/tools/perf/builtin.h index f2ab5bae2150..6683ea6d3b60 100644 --- a/tools/perf/builtin.h +++ b/tools/perf/builtin.h @@ -2,6 +2,52 @@ #ifndef BUILTIN_H #define BUILTIN_H =20 +#include +#include +#include + +struct feature_support { + const char *name; + const char *macro; + int is_builtin; +}; + +#define FEATURE_SUPPORT(name_, macro_) { \ + .name =3D name_, \ + .macro =3D #macro_, \ + .is_builtin =3D IS_BUILTIN(macro_) } + +static struct feature_support supported_features[] __maybe_unused =3D { + FEATURE_SUPPORT("dwarf", HAVE_DWARF_SUPPORT), + FEATURE_SUPPORT("dwarf_getlocations", HAVE_DWARF_GETLOCATIONS_SUPPORT), +#ifndef HAVE_SYSCALL_TABLE_SUPPORT + FEATURE_SUPPORT("libaudit", HAVE_LIBAUDIT_SUPPORT), +#endif + FEATURE_SUPPORT("syscall_table", HAVE_SYSCALL_TABLE_SUPPORT), + FEATURE_SUPPORT("libbfd", HAVE_LIBBFD_SUPPORT), + FEATURE_SUPPORT("debuginfod", HAVE_DEBUGINFOD_SUPPORT), + FEATURE_SUPPORT("libelf", HAVE_LIBELF_SUPPORT), + FEATURE_SUPPORT("libnuma", HAVE_LIBNUMA_SUPPORT), + FEATURE_SUPPORT("numa_num_possible_cpus", HAVE_LIBNUMA_SUPPORT), + FEATURE_SUPPORT("libperl", HAVE_LIBPERL_SUPPORT), + FEATURE_SUPPORT("libpython", HAVE_LIBPYTHON_SUPPORT), + FEATURE_SUPPORT("libslang", HAVE_SLANG_SUPPORT), + FEATURE_SUPPORT("libcrypto", HAVE_LIBCRYPTO_SUPPORT), + FEATURE_SUPPORT("libunwind", HAVE_LIBUNWIND_SUPPORT), + FEATURE_SUPPORT("libdw-dwarf-unwind", HAVE_DWARF_SUPPORT), + FEATURE_SUPPORT("zlib", HAVE_ZLIB_SUPPORT), + FEATURE_SUPPORT("lzma", HAVE_LZMA_SUPPORT), + FEATURE_SUPPORT("get_cpuid", HAVE_AUXTRACE_SUPPORT), + FEATURE_SUPPORT("bpf", HAVE_LIBBPF_SUPPORT), + FEATURE_SUPPORT("aio", HAVE_AIO_SUPPORT), + FEATURE_SUPPORT("zstd", HAVE_ZSTD_SUPPORT), + FEATURE_SUPPORT("libpfm4", HAVE_LIBPFM), + FEATURE_SUPPORT("libtraceevent", HAVE_LIBTRACEEVENT), + + // this should remain at end, to know the array end + FEATURE_SUPPORT(NULL, _) +}; + void list_common_cmds_help(void); const char *help_unknown_cmd(const char *cmd); =20 @@ -9,6 +55,7 @@ int cmd_annotate(int argc, const char **argv); int cmd_bench(int argc, const char **argv); int cmd_buildid_cache(int argc, const char **argv); int cmd_buildid_list(int argc, const char **argv); +int cmd_check(int argc, const char **argv); int cmd_config(int argc, const char **argv); int cmd_c2c(int argc, const char **argv); int cmd_diff(int argc, const char **argv); diff --git a/tools/perf/perf.c b/tools/perf/perf.c index d3fc8090413c..83dc0ac42fdb 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -50,6 +50,7 @@ static struct cmd_struct commands[] =3D { { "archive", NULL, 0 }, { "buildid-cache", cmd_buildid_cache, 0 }, { "buildid-list", cmd_buildid_list, 0 }, + { "check", cmd_check, 0 }, { "config", cmd_config, 0 }, { "c2c", cmd_c2c, 0 }, { "diff", cmd_diff, 0 }, --=20 2.41.0 From nobody Sun Feb 8 05:34:49 2026 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 8F1AECA0FF3 for ; Sun, 3 Sep 2023 11:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236797AbjICLru (ORCPT ); Sun, 3 Sep 2023 07:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236756AbjICLrr (ORCPT ); Sun, 3 Sep 2023 07:47:47 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D06A133; Sun, 3 Sep 2023 04:47:43 -0700 (PDT) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 383BgVO8026465; Sun, 3 Sep 2023 11:47:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=xHviIjSIGtAjHbY83gxmWUsuMOT6BxdHNIbHYoS1Z48=; b=KoAJJIs+kL9tvLBad/nNRPoSqGgw2Q6LY36AIq+o2+MicDsX5fUA1JuExfBj+eyukO5D RZZ3unvqEvq1FqiGMo2I7trJgE4ZaheQWomSPczcir2zXQ+XoH3ZKy7oy4m83h3hnvca 57AaGAcF5raUU0jwfYB1zaWnsm1/1/rmk7u8/sAZ0/+0pzzYIr8f2+Dmmz0PeTl3W3v4 rD9/RyTMvckkwUkdjyAKjPPkxTw8tCL1vFbrPx3Hel0lN2q7fzO7FLf5aNt59XJMFnw+ 8UxSyKmJrIyQRU+CwA4hu068V5tBHql+rUk28UakdUVuzW8SroX3tb/Wk+0tD+ZhjqsF XQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3svsggg1re-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:34 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 383BlYqX007147; Sun, 3 Sep 2023 11:47:34 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3svsggg1ra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:33 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3839CNFr001610; Sun, 3 Sep 2023 11:47:33 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3svfcs3act-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:33 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 383BlUKh18350728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 3 Sep 2023 11:47:30 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EF5320040; Sun, 3 Sep 2023 11:47:30 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D948D2004B; Sun, 3 Sep 2023 11:47:27 +0000 (GMT) Received: from li-3c92a0cc-27cf-11b2-a85c-b804d9ca68fa.ibm.com.com (unknown [9.171.15.154]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Sun, 3 Sep 2023 11:47:27 +0000 (GMT) From: Aditya Gupta To: acme@kernel.org, jolsa@kernel.org, irogers@google.com, namhyung@kernel.org Cc: linux-perf-users@vger.kernel.org, maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com, kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] perf version: update --build-options to use 'supported_features' array Date: Sun, 3 Sep 2023 17:17:19 +0530 Message-ID: <20230903114721.190733-3-adityag@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230903114721.190733-1-adityag@linux.ibm.com> References: <20230903114721.190733-1-adityag@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: MBwsio2MM2ywfq0YxQlS7DaFzXHPUsPh X-Proofpoint-GUID: R2KcOeyCy2Z7_w0aAO1PdYWyw0qY2YFt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-03_09,2023-08-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 mlxlogscore=966 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 adultscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309030108 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Now that the feature list has been duplicated in a global 'supported_features' array, use that array instead of manually checking status of built-in features. This helps in being consistent with commands such as 'perf check --feature', so commands can use the same array, and any new feature can be added at one place, in the 'supported_features' array Signed-off-by: Aditya Gupta --- tools/perf/builtin-version.c | 39 ++++++++---------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c index e5859c70e195..e149d96c6dc5 100644 --- a/tools/perf/builtin-version.c +++ b/tools/perf/builtin-version.c @@ -46,41 +46,18 @@ static void status_print(const char *name, const char *= macro, printf(" # %s\n", macro); } =20 -#define STATUS(__d, __m) \ -do { \ - if (IS_BUILTIN(__d)) \ - status_print(#__m, #__d, "on"); \ - else \ - status_print(#__m, #__d, "OFF"); \ +#define STATUS(feature) \ +do { \ + if (feature.is_builtin) \ + status_print(feature.name, feature.macro, "on"); \ + else \ + status_print(feature.name, feature.macro, "OFF"); \ } while (0) =20 static void library_status(void) { - STATUS(HAVE_DWARF_SUPPORT, dwarf); - STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations); -#ifndef HAVE_SYSCALL_TABLE_SUPPORT - STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit); -#endif - STATUS(HAVE_SYSCALL_TABLE_SUPPORT, syscall_table); - STATUS(HAVE_LIBBFD_SUPPORT, libbfd); - STATUS(HAVE_DEBUGINFOD_SUPPORT, debuginfod); - STATUS(HAVE_LIBELF_SUPPORT, libelf); - STATUS(HAVE_LIBNUMA_SUPPORT, libnuma); - STATUS(HAVE_LIBNUMA_SUPPORT, numa_num_possible_cpus); - STATUS(HAVE_LIBPERL_SUPPORT, libperl); - STATUS(HAVE_LIBPYTHON_SUPPORT, libpython); - STATUS(HAVE_SLANG_SUPPORT, libslang); - STATUS(HAVE_LIBCRYPTO_SUPPORT, libcrypto); - STATUS(HAVE_LIBUNWIND_SUPPORT, libunwind); - STATUS(HAVE_DWARF_SUPPORT, libdw-dwarf-unwind); - STATUS(HAVE_ZLIB_SUPPORT, zlib); - STATUS(HAVE_LZMA_SUPPORT, lzma); - STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid); - STATUS(HAVE_LIBBPF_SUPPORT, bpf); - STATUS(HAVE_AIO_SUPPORT, aio); - STATUS(HAVE_ZSTD_SUPPORT, zstd); - STATUS(HAVE_LIBPFM, libpfm4); - STATUS(HAVE_LIBTRACEEVENT, libtraceevent); + for (int i =3D 0; supported_features[i].name; ++i) + STATUS(supported_features[i]); } =20 int cmd_version(int argc, const char **argv) --=20 2.41.0 From nobody Sun Feb 8 05:34:49 2026 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 3F40AC83F2C for ; Sun, 3 Sep 2023 11:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236747AbjICLrr (ORCPT ); Sun, 3 Sep 2023 07:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236729AbjICLro (ORCPT ); Sun, 3 Sep 2023 07:47:44 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29378124; Sun, 3 Sep 2023 04:47:40 -0700 (PDT) Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 383B8gsF014995; Sun, 3 Sep 2023 11:47:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=DCM3KgHZxIphPp1KSsPhGe1hX0uhMklqdqwEARfeQBc=; b=cE5Y/XA2avy7pLDUnL9/2jxzqaEnCV/Qwrgq8NYWdCdHXXfbVfgwoo3V+fNO/JLHA/Ju ue44SldGvUANAQUxdPAmnPH03kpqs3ta+8aDOCzMDiMmpwBhNYO4bVgHBdIFZCJKPRsF XghGCat/ur73YfOeFM5ZHxC8RquyqQZW+NgEVzC8fZUMhR72lLz9u2v8uGpNjfap/cJX J+7XaJxXs8SaRnTlvzKMfyelwdWZA7v3RL9lyTHjB5jCX8td2FodY5DIkSpWjobKd2fX /Z9nAxtunR0majHi4YQ65m1MiujHAXxJwxahFgG4c0ffw8WFv/68qp6IWFl2CQLEgzkA SA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3svrs2rnc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:36 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 383BjHhk019868; Sun, 3 Sep 2023 11:47:36 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3svrs2rnbw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:36 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3839P5dO011154; Sun, 3 Sep 2023 11:47:35 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3svj312chp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:35 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 383BlW5m42271462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 3 Sep 2023 11:47:32 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE3A520043; Sun, 3 Sep 2023 11:47:32 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7088C20040; Sun, 3 Sep 2023 11:47:30 +0000 (GMT) Received: from li-3c92a0cc-27cf-11b2-a85c-b804d9ca68fa.ibm.com.com (unknown [9.171.15.154]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Sun, 3 Sep 2023 11:47:30 +0000 (GMT) From: Aditya Gupta To: acme@kernel.org, jolsa@kernel.org, irogers@google.com, namhyung@kernel.org Cc: linux-perf-users@vger.kernel.org, maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com, kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] perf tests task_analyzer: use perf check for libtraceevent support Date: Sun, 3 Sep 2023 17:17:20 +0530 Message-ID: <20230903114721.190733-4-adityag@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230903114721.190733-1-adityag@linux.ibm.com> References: <20230903114721.190733-1-adityag@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: x2NUOCGwo1qA0UkTws0uM1S_mMRgHlOa X-Proofpoint-ORIG-GUID: yYVVqFMVWkZ4cOcbbZLHuraP2CPlSAAd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-03_09,2023-08-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 mlxlogscore=882 bulkscore=0 mlxscore=0 clxscore=1015 phishscore=0 priorityscore=1501 impostorscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309030108 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Currently we use output of 'perf version --build-options', to check whether perf was built with libtraceevent support. Instead, use 'perf check --feature libtraceevent' to check for libtraceevent support. Signed-off-by: Aditya Gupta --- tools/perf/tests/shell/test_task_analyzer.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/tests/shell/test_task_analyzer.sh b/tools/perf/test= s/shell/test_task_analyzer.sh index 92d15154ba79..8fbc33c95025 100755 --- a/tools/perf/tests/shell/test_task_analyzer.sh +++ b/tools/perf/tests/shell/test_task_analyzer.sh @@ -52,8 +52,8 @@ find_str_or_fail() { =20 # check if perf is compiled with libtraceevent support skip_no_probe_record_support() { - perf version --build-options | grep -q " OFF .* HAVE_LIBTRACEEVENT" && re= turn 2 - return 0 + perf check --feature libtraceevent >/dev/null && return 0 + return 2 } =20 prepare_perf_data() { --=20 2.41.0 From nobody Sun Feb 8 05:34:49 2026 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 1D741C71153 for ; Sun, 3 Sep 2023 11:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236768AbjICLrr (ORCPT ); Sun, 3 Sep 2023 07:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236692AbjICLrq (ORCPT ); Sun, 3 Sep 2023 07:47:46 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F318D131; Sun, 3 Sep 2023 04:47:42 -0700 (PDT) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 383BdBHv023934; Sun, 3 Sep 2023 11:47:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=hlRwXwO4xH9XWyy2GiSwAawXvItSa88KmfOn7JOezBQ=; b=lmugv4sC+kkk6lal3T1Q4K3SM83Jyf2HZGzuws1Cyi6fR+nwE7xU16EJG7T/imOHUdoN WnCubvNo97cy7PW4t919eEfqCNf3p12uKrdBxARrnru+zDgHlv7VoU34gDAd3RicESbv s5t9zF4fl/5Izkk9NTP+ti7Sm+Jgi2rq5WVhqCPsde6Ql3YrxUCKfdgUsxY2YHSuPi+J BLPyPY1V8T4k2iZpqyzDR3aQsUIkacfooIFUBwg4hnqAJJ5as+TRLfkvVAHUdcxqQyIK E9U3H4lF2IQ1WcLs64G8WHi6hG2XCNf1rVg51yceFXQJzfyze3Wrn/I9NP2c3vlvkIYG Jg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3svs7b8866-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:39 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 383BgU8Z003745; Sun, 3 Sep 2023 11:47:39 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3svs7b8861-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:39 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 383Ab4GV026775; Sun, 3 Sep 2023 11:47:38 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3svgcmtxvk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2023 11:47:38 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 383BlZcm44302750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 3 Sep 2023 11:47:35 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FA4420043; Sun, 3 Sep 2023 11:47:35 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C7E820040; Sun, 3 Sep 2023 11:47:33 +0000 (GMT) Received: from li-3c92a0cc-27cf-11b2-a85c-b804d9ca68fa.ibm.com.com (unknown [9.171.15.154]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Sun, 3 Sep 2023 11:47:32 +0000 (GMT) From: Aditya Gupta To: acme@kernel.org, jolsa@kernel.org, irogers@google.com, namhyung@kernel.org Cc: linux-perf-users@vger.kernel.org, maddy@linux.ibm.com, atrajeev@linux.vnet.ibm.com, kjain@linux.ibm.com, disgoel@linux.vnet.ibm.com, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] tools/perf/tests: Update probe_vfs_getname.sh script to use perf check --feature Date: Sun, 3 Sep 2023 17:17:21 +0530 Message-ID: <20230903114721.190733-5-adityag@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230903114721.190733-1-adityag@linux.ibm.com> References: <20230903114721.190733-1-adityag@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 7XNBAgOIvls_74cwixa0oeD__yIU3_vh X-Proofpoint-GUID: icuPHOE_FViuYH_JSGXdd17a5SNdGFhZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-03_09,2023-08-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 clxscore=1015 spamscore=0 mlxscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309030108 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Athira Rajeev In probe_vfs_getname.sh, current we use "perf record --dry-run" to check for libtraceevent and skip the test if perf is not build with libtraceevent. Change the check to use "perf check --feature" option Signed-off-by: Athira Rajeev --- tools/perf/tests/shell/lib/probe_vfs_getname.sh | 4 ++-- tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 5 ++++- tools/perf/tests/shell/record+script_probe_vfs_getname.sh | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/shell/lib/probe_vfs_getname.sh b/tools/perf/t= ests/shell/lib/probe_vfs_getname.sh index bf4c1fb71c4b..347106cc8988 100644 --- a/tools/perf/tests/shell/lib/probe_vfs_getname.sh +++ b/tools/perf/tests/shell/lib/probe_vfs_getname.sh @@ -27,7 +27,7 @@ skip_if_no_debuginfo() { # check if perf is compiled with libtraceevent support skip_no_probe_record_support() { if [ $had_vfs_getname -eq 1 ] ; then - perf record --dry-run -e $1 2>&1 | grep "libtraceevent is necessary for = tracepoint support" && return 2 - return 1 + perf check --feature libtraceevent >/dev/null && return 1 + return 2 fi } diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/= perf/tests/shell/record+probe_libc_inet_pton.sh index 89214a6d9951..0c00e94b83ff 100755 --- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh +++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh @@ -58,7 +58,10 @@ trace_libc_inet_pton_backtrace() { =20 # Check presence of libtraceevent support to run perf record skip_no_probe_record_support "$event_name/$eventattr/" - [ $? -eq 2 ] && return 2 + if [ $? -eq 2 ]; then + echo "WARN: Skipping test trace_libc_inet_pton_backtrace. No libtraceeve= nt support." + return 2 + fi =20 perf record -e $event_name/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /= dev/null 2>&1 # check if perf data file got created in above step. diff --git a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh b/to= ols/perf/tests/shell/record+script_probe_vfs_getname.sh index 7f664f1889d9..c7416d21fc92 100755 --- a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh +++ b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh @@ -19,7 +19,10 @@ record_open_file() { echo "Recording open file:" # Check presence of libtraceevent support to run perf record skip_no_probe_record_support "probe:vfs_getname*" - [ $? -eq 2 ] && return 2 + if [ $? -eq 2 ]; then + echo "WARN: Skipping test record_open_file. No libtraceevent support" + return 2 + fi perf record -o ${perfdata} -e probe:vfs_getname\* touch $file } =20 --=20 2.41.0