Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2825894rwd; Fri, 26 May 2023 11:50:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EuZQtvGDXbpaZqQccf5l0JpOr2XURcSmwvODuNs0/GEKnZXelpYwwmdVlZvvXBAjN6lnK X-Received: by 2002:a17:903:230f:b0:1af:bb27:f55f with SMTP id d15-20020a170903230f00b001afbb27f55fmr4032194plh.55.1685127003255; Fri, 26 May 2023 11:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685127003; cv=none; d=google.com; s=arc-20160816; b=iN9dTFQFlj1vmnXpVyrndISH42X0bm4aZG+gc6RIDGX79PnVg8ER93CogtRICXjgWB uckZhEnDyH0PNMDWC9vrWjNB+L7uLqRUU+MoJa2/TA1gJ/f/Mk3IADFxguAuQCpv4A+8 DaTY22ihOqVtkLz5Ok+MhdAsJWfYxdUASy7bj8UpkNwfMqgeVPWFRYC+Md2SLRWcXbjC xWoOaQzOwoPIeFDD7sierHeI0zKSUOQs+paets6ulCpwlfxwxCx+kj0NH2JVLjOqNnnY hCxE0W1nTDoaKg8SkTT678LM3YinXf/R2hh71hO7uZsQSbGTxrBxEP6eeHwvGJiK4u38 GF7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=tJmwLfRRVr3ODHBN7zQ2hUxxptOi1p92mYZclHdiN44=; b=RAnNlE5+9wVLgEzvI3K4WXq+56ekMnnFUJcJ/kznty5BVEhhHZy/pos76bHYPF4Nhy bQ+stjFOt5SjiJ2XGDNLda3RdB2qav+4XHSa1CSdYb6iVZSNbDE05KgTViqPUYWtpr2g 8rFa8/ykryZ11RRUSsWdMvPZs/MGjNwiEgYMDmr1F1hSLKq6Vf3mJTISFiq2SvKKJe7G 2KIZMlJpHbArPBCbIKW4jJklB1mTa4QWsdjBCfZubvyNBHRGONtgy7uHyK1qawq4CSWq +BJITEv6yrQtc+hkU4I37sleAAiiCDc5gVUgWZx4QyfzURN+qxJagF8E24aZtVmagtfn KsGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ebkX03X6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij25-20020a170902ab5900b001afc602cd55si4345137plb.21.2023.05.26.11.49.50; Fri, 26 May 2023 11:50:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ebkX03X6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243067AbjEZSef (ORCPT + 99 others); Fri, 26 May 2023 14:34:35 -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-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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(char *bf, size_t size, #include "trace/beauty/socket_type.c" #include "trace/beauty/waitid_options.c" -static struct syscall_fmt syscall_fmts[] = { +static const struct syscall_fmt syscall_fmts[] = { { .name = "access", .arg = { [1] = { .scnprintf = SCA_ACCMODE, /* mode */ }, }, }, { .name = "arch_prctl", @@ -1176,18 +1176,21 @@ static int syscall_fmt__cmp(const void *name, const void *fmtp) return strcmp(name, fmt->name); } -static struct syscall_fmt *__syscall_fmt__find(struct syscall_fmt *fmts, const 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); } -static struct syscall_fmt *syscall_fmt__find(const char *name) +static const struct syscall_fmt *syscall_fmt__find(const char *name) { const int nmemb = ARRAY_SIZE(syscall_fmts); return __syscall_fmt__find(syscall_fmts, nmemb, name); } -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; @@ -1199,7 +1202,7 @@ static struct syscall_fmt *__syscall_fmt__find_by_alias(struct syscall_fmt *fmts return NULL; } -static struct syscall_fmt *syscall_fmt__find_by_alias(const char *alias) +static const struct syscall_fmt *syscall_fmt__find_by_alias(const char *alias) { const int nmemb = 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; }; @@ -1673,7 +1676,7 @@ static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args) return 0; } -static struct syscall_arg_fmt syscall_arg_fmts__by_name[] = { +static const struct syscall_arg_fmt syscall_arg_fmts__by_name[] = { { .name = "msr", .scnprintf = SCA_X86_MSR, .strtoul = STUL_X86_MSR, }, { .name = "vector", .scnprintf = SCA_X86_IRQ_VECTORS, .strtoul = STUL_X86_IRQ_VECTORS, }, }; @@ -1684,13 +1687,14 @@ static int syscall_arg_fmt__cmp(const void *name, const void *fmtp) return strcmp(name, fmt->name); } -static struct syscall_arg_fmt * -__syscall_arg_fmt__find_by_name(struct syscall_arg_fmt *fmts, const int nmemb, 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), syscall_arg_fmt__cmp); } -static struct syscall_arg_fmt *syscall_arg_fmt__find_by_name(const char *name) +static const struct syscall_arg_fmt *syscall_arg_fmt__find_by_name(const char *name) { const int nmemb = ARRAY_SIZE(syscall_arg_fmts__by_name); return __syscall_arg_fmt__find_by_name(syscall_arg_fmts__by_name, nmemb, name); @@ -1735,8 +1739,9 @@ syscall_arg_fmt__init_array(struct syscall_arg_fmt *arg, struct tep_format_field * 7 unsigned long */ arg->scnprintf = SCA_FD; - } else { - struct syscall_arg_fmt *fmt = syscall_arg_fmt__find_by_name(field->name); + } else { + const struct syscall_arg_fmt *fmt = + syscall_arg_fmt__find_by_name(field->name); if (fmt) { arg->scnprintf = fmt->scnprintf; @@ -4458,7 +4463,7 @@ static void evsel__set_syscall_arg_fmt(struct evsel *evsel, const char *name) struct syscall_arg_fmt *fmt = evsel__syscall_arg_fmt(evsel); if (fmt) { - struct syscall_fmt *scfmt = syscall_fmt__find(name); + const struct syscall_fmt *scfmt = syscall_fmt__find(name); if (scfmt) { int skip = 0; @@ -4525,7 +4530,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str, int len = strlen(str) + 1, err = -1, list, idx; char *strace_groups_dir = system_path(STRACE_GROUPS_DIR); char group_name[PATH_MAX]; - struct syscall_fmt *fmt; + const struct syscall_fmt *fmt; if (strace_groups_dir == NULL) return -1; -- 2.41.0.rc0.172.g3f132b7071-goog