From nobody Sun Feb 8 21:46:47 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 163E5C7EE23 for ; Fri, 26 May 2023 18:34:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243069AbjEZSei (ORCPT ); Fri, 26 May 2023 14:34:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242608AbjEZSeZ (ORCPT ); Fri, 26 May 2023 14:34:25 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 108A6134 for ; Fri, 26 May 2023 11:34:20 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1ae7eea1d5dso8281765ad.1 for ; Fri, 26 May 2023 11:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685126059; x=1687718059; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=tJmwLfRRVr3ODHBN7zQ2hUxxptOi1p92mYZclHdiN44=; b=ebkX03X6J7UXTqGhZi7TZ5tKSwDb5GlMRiV4qte2YYdvtTDfUDJZMnnIeCZRKUL3jp b1IDDwyvTFTNgUsTeKE7Vf5/Q5wOKad7bGRsNgXfHaFe5wjlDnhdIg+pqIJ7nCoLVZ43 JXLgblf3SuR+iklvswplYjUli+LWd7aABOaCTNHShXdVPRBPuWAJRFyYD5KC3zVMh4I6 HdV5u0QmREQ7ub/VfuZiKGcboRmX2BrZ+G5lhrUgz9qVUCcDWix+D1YJX3mvA7gMEJ47 yOUHoM1N67qPM3C7sEJGxzsGtk8EPOK6U2y41Hv1+YrfycJXskuXonn0tOaIkjlTZ8Jt jH0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685126059; x=1687718059; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tJmwLfRRVr3ODHBN7zQ2hUxxptOi1p92mYZclHdiN44=; b=dNvQQHSiGknHRgL19Iq3SGky8GqsNjDrkeE/qXXpizhbHpKB5+NajYKRzlLDVbm7KY qBNXN9n3Ka3gnZpw/aitZjgUpoM9o/GbN2Dq0R4a5V170mic6SASUJi6nmDp+ccPbsuU FtWrq2AICBilv2rnJkbxGVEa8Pa05OyrtwgmQ7xzkCaIDQIV5ASAkQ28tVnI4Lw1Vwiu rL0fNpfaOB3sel6N7CtF/UVfmQHhOlBGTFgL2XIyLD5f0HjO+y+NbjyJkUYqfBd2OquN +luyt73Ujzy1ZIucTCDSf3SsdJBxNBzHEdC1aTPTSpbKQO512AU3W/rukREtVtzf0lHk nD7A== X-Gm-Message-State: AC+VfDyVM6H+W1bKKMluWvhYlOt2DhIVK6semWk4DGbTQue0YlQUVrz0 YxVr/Fe7/dOrmaJdiPTsg0+0EM6GqwdK X-Google-Smtp-Source: ACHHUZ66XVs9uuYY7Z8yFza1YhbpP/n+i9VBRWqOvdwvNtok78qODw9ody70xKdsTuJwZFl/tMHcBbWcFr8T X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a17:903:2683:b0:1ae:531f:366a with SMTP id jf3-20020a170903268300b001ae531f366amr691371plb.5.1685126059551; Fri, 26 May 2023 11:34:19 -0700 (PDT) Date: Fri, 26 May 2023 11:33:49 -0700 In-Reply-To: <20230526183401.2326121-1-irogers@google.com> Message-Id: <20230526183401.2326121-5-irogers@google.com> Mime-Version: 1.0 References: <20230526183401.2326121-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v2 04/16] perf trace: Make some large static arrays const From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , "Masami Hiramatsu (Google)" , "Steven Rostedt (Google)" , Ross Zwisler , Leo Yan , Tiezhu Yang , Yang Jihong , Andi Kleen , Kan Liang , Ravi Bangoria , Sean Christopherson , K Prateek Nayak , Paolo Bonzini , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allows the movement of 33,128 bytes from .data to .data.rel.ro. Signed-off-by: Ian Rogers --- tools/perf/builtin-trace.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index b49d3abb1203..62c7c99a0fe4 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -914,7 +914,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(ch= ar *bf, size_t size, #include "trace/beauty/socket_type.c" #include "trace/beauty/waitid_options.c" =20 -static struct syscall_fmt syscall_fmts[] =3D { +static const struct syscall_fmt syscall_fmts[] =3D { { .name =3D "access", .arg =3D { [1] =3D { .scnprintf =3D SCA_ACCMODE, /* mode */ }, }, }, { .name =3D "arch_prctl", @@ -1176,18 +1176,21 @@ static int syscall_fmt__cmp(const void *name, const= void *fmtp) return strcmp(name, fmt->name); } =20 -static struct syscall_fmt *__syscall_fmt__find(struct syscall_fmt *fmts, c= onst int nmemb, const char *name) +static const struct syscall_fmt *__syscall_fmt__find(const struct syscall_= fmt *fmts, + const int nmemb, + const char *name) { return bsearch(name, fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt= __cmp); } =20 -static struct syscall_fmt *syscall_fmt__find(const char *name) +static const struct syscall_fmt *syscall_fmt__find(const char *name) { const int nmemb =3D ARRAY_SIZE(syscall_fmts); return __syscall_fmt__find(syscall_fmts, nmemb, name); } =20 -static struct syscall_fmt *__syscall_fmt__find_by_alias(struct syscall_fmt= *fmts, const int nmemb, const char *alias) +static const struct syscall_fmt *__syscall_fmt__find_by_alias(const struct= syscall_fmt *fmts, + const int nmemb, const char *alias) { int i; =20 @@ -1199,7 +1202,7 @@ static struct syscall_fmt *__syscall_fmt__find_by_ali= as(struct syscall_fmt *fmts return NULL; } =20 -static struct syscall_fmt *syscall_fmt__find_by_alias(const char *alias) +static const struct syscall_fmt *syscall_fmt__find_by_alias(const char *al= ias) { const int nmemb =3D ARRAY_SIZE(syscall_fmts); return __syscall_fmt__find_by_alias(syscall_fmts, nmemb, alias); @@ -1224,7 +1227,7 @@ struct syscall { bool nonexistent; struct tep_format_field *args; const char *name; - struct syscall_fmt *fmt; + const struct syscall_fmt *fmt; struct syscall_arg_fmt *arg_fmt; }; =20 @@ -1673,7 +1676,7 @@ static int syscall__alloc_arg_fmts(struct syscall *sc= , int nr_args) return 0; } =20 -static struct syscall_arg_fmt syscall_arg_fmts__by_name[] =3D { +static const struct syscall_arg_fmt syscall_arg_fmts__by_name[] =3D { { .name =3D "msr", .scnprintf =3D SCA_X86_MSR, .strtoul =3D STUL_X86_MS= R, }, { .name =3D "vector", .scnprintf =3D SCA_X86_IRQ_VECTORS, .strtoul =3D ST= UL_X86_IRQ_VECTORS, }, }; @@ -1684,13 +1687,14 @@ static int syscall_arg_fmt__cmp(const void *name, c= onst void *fmtp) return strcmp(name, fmt->name); } =20 -static struct syscall_arg_fmt * -__syscall_arg_fmt__find_by_name(struct syscall_arg_fmt *fmts, const int nm= emb, const char *name) +static const struct syscall_arg_fmt * +__syscall_arg_fmt__find_by_name(const struct syscall_arg_fmt *fmts, const = int nmemb, + const char *name) { return bsearch(name, fmts, nmemb, sizeof(struct syscall_arg_fmt), s= yscall_arg_fmt__cmp); } =20 -static struct syscall_arg_fmt *syscall_arg_fmt__find_by_name(const char *n= ame) +static const struct syscall_arg_fmt *syscall_arg_fmt__find_by_name(const c= har *name) { const int nmemb =3D ARRAY_SIZE(syscall_arg_fmts__by_name); return __syscall_arg_fmt__find_by_name(syscall_arg_fmts__by_name, n= memb, name); @@ -1735,8 +1739,9 @@ syscall_arg_fmt__init_array(struct syscall_arg_fmt *a= rg, struct tep_format_field * 7 unsigned long */ arg->scnprintf =3D SCA_FD; - } else { - struct syscall_arg_fmt *fmt =3D syscall_arg_fmt__find_by_name(field->na= me); + } else { + const struct syscall_arg_fmt *fmt =3D + syscall_arg_fmt__find_by_name(field->name); =20 if (fmt) { arg->scnprintf =3D fmt->scnprintf; @@ -4458,7 +4463,7 @@ static void evsel__set_syscall_arg_fmt(struct evsel *= evsel, const char *name) struct syscall_arg_fmt *fmt =3D evsel__syscall_arg_fmt(evsel); =20 if (fmt) { - struct syscall_fmt *scfmt =3D syscall_fmt__find(name); + const struct syscall_fmt *scfmt =3D syscall_fmt__find(name); =20 if (scfmt) { int skip =3D 0; @@ -4525,7 +4530,7 @@ static int trace__parse_events_option(const struct op= tion *opt, const char *str, int len =3D strlen(str) + 1, err =3D -1, list, idx; char *strace_groups_dir =3D system_path(STRACE_GROUPS_DIR); char group_name[PATH_MAX]; - struct syscall_fmt *fmt; + const struct syscall_fmt *fmt; =20 if (strace_groups_dir =3D=3D NULL) return -1; --=20 2.41.0.rc0.172.g3f132b7071-goog