From patchwork Wed Mar 8 22:59:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 66495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp623624wrd; Wed, 8 Mar 2023 15:03:34 -0800 (PST) X-Google-Smtp-Source: AK7set8odfU+wWTIOf71kcqNJ0yKLPkAUbMY2EumO2r/SaRQSzTJ2y3ZLfMr4o7NJlFVnHeySbDm X-Received: by 2002:a17:902:ce8a:b0:19c:f698:8564 with SMTP id f10-20020a170902ce8a00b0019cf6988564mr25347062plg.17.1678316614168; Wed, 08 Mar 2023 15:03:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678316614; cv=none; d=google.com; s=arc-20160816; b=jlqGmCLMAqpDZnSYvGf2aFak5kApzx2g67HmZG2VPqLNKhKzbdhtdi9XARADttT6Mv Xs1cRNdYo40XDx5OVeS8lIBjx3FmH5+oxYXxGIBwQ0OflANMFAjsTUqV3QLK4Zyf/A+R sUKrICuCSi36xkStEXS1/QdrswULNUFUv+1ZMwit6YGhtY+6BzlQ3JqMxmJGTAKn92g7 WV30n4mqQdtVKxEIhEiukS5j9minDN20N1Ws85avNjFXRNijktgHKk1Q2VBH8TD8t93j pbbWHBpErrTD7wkD6vYewynNjL1S98UFzP/qX/O8iPZG7NSpEsqN5K9mIeBPuXpTh03e 3L9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=mSc6zWu+gp18coqfyQ+Fs9l1x/Sawfb5L2ZQMm92/Ks=; b=H41riuEesDTP2F58zlT4ztWUfLai2xv1UrUGUFP/KDg1C9i57JQJqN+ZG3CmOgcMuM 6D2+KhpBNgQlzW0qQOP9NXQyvn3aEMUYiO4MPShCbZ36fJk8ST/ThPGAD3B9zPC8jk7b mAAaQ4cuu4ns8Fqd+O8+Sf3wZo9+QBdEvKWchBHT0fzWuF9+bWYqCDxBk+2kXarpx8Bp Nck2k5STFJLE0pG/4jIe75lNSSQwi+0VOO8jFAbeleaac/26xkwdj2an5bcb2mGpFQPq 87eQ5faXai+lv5NzWfAzmqqHV1UhRQdk/KN9yOvsNsoTadG+i0oQCaFyyi17X1dwyv8Q jCcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cZ1RkdbK; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w38-20020a634926000000b00502e3a1e8bdsi14640822pga.280.2023.03.08.15.03.11; Wed, 08 Mar 2023 15:03:34 -0800 (PST) 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=20210112 header.b=cZ1RkdbK; 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 S230147AbjCHXA2 (ORCPT + 99 others); Wed, 8 Mar 2023 18:00:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229970AbjCHXAM (ORCPT ); Wed, 8 Mar 2023 18:00:12 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4740D2925 for ; Wed, 8 Mar 2023 14:59:59 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id n139-20020a25d691000000b00b1f2dad8a21so241611ybg.10 for ; Wed, 08 Mar 2023 14:59:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678316399; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mSc6zWu+gp18coqfyQ+Fs9l1x/Sawfb5L2ZQMm92/Ks=; b=cZ1RkdbKHiQp8iMzmHZSmHN7kF686F5RFHncPOAulqbFLk/uhkfBFby2QgkyclXSPv 7ZBNaJvLwhpnIbBGUillqyhQJSqOlE8aCOP7AO234mDx3bTyNJRaJl0k5NiHWCHi8fPl vLiQbMCfJXVvSUMhVygJX7OATIF9KGdSMJ5sTvUtU/DWfjI6H4uCvnwMhwVIA9773yE5 b8JnshUYlXGTYvQEHBxe6ZUcKAa1VI3klTdxbJ5Vl11Im4MVFOmCbh/bPHnXRUNUYQ5M WIvGLcSJndZQBNrlny0Vwrz2h/qY8yJ8BMRoGG2ti/a0RBHBIKq2iV/9/W3m+xxxknE+ uqaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678316399; h=cc: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=mSc6zWu+gp18coqfyQ+Fs9l1x/Sawfb5L2ZQMm92/Ks=; b=4+5vR2cmQk+RXuhnuIZgcRtaljsnLrVBXRdD3HoPCGdiM4UqQUbNkONuCktHFT7Ekk 8Z1GCPkaOkI0oIJ62k8kVtTs08n68AwPiFjsC/1g490q5tpIyLGdUMV58ECv44dVCdvu kTOSn9Ikj+7JyObj+mw5zkTQptz+cp1qmKekkIW87UbP4Q7fg3XlhBS8KsEoFsWST9da Mo46TcK3g3Z+QQfU5EyDAG11Z5BEG/LNuSWVwezpsNDePlg4JZHP+DbzU9nDQYLC8s2+ jWODBMGU835U0jRDIwF3b7FAJXMewck6bGWfGYdXMhSWN4JsoyX/TUuN1FhN0fCBvLcD 9Z0w== X-Gm-Message-State: AO0yUKWHy8say5ZJXB2ffngsuNHkZwICuVXwVBhZgNjpBQPtiycL8xhn VRtugFyyjIAIAdH7cc0uZnI1u1tuTAQb X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:5292:ba14:c261:246a]) (user=irogers job=sendgmr) by 2002:a5b:38d:0:b0:8ea:3d09:b125 with SMTP id k13-20020a5b038d000000b008ea3d09b125mr9627359ybp.0.1678316399079; Wed, 08 Mar 2023 14:59:59 -0800 (PST) Date: Wed, 8 Mar 2023 14:59:06 -0800 In-Reply-To: <20230308225912.1960990-1-irogers@google.com> Message-Id: <20230308225912.1960990-6-irogers@google.com> Mime-Version: 1.0 References: <20230308225912.1960990-1-irogers@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Subject: [PATCH v4 05/11] perf evsel: Allow const evsel for certain accesses From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Mark Rutland , Adrian Hunter , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Kan Liang , Zhengjun Xing , Ravi Bangoria , "Steinar H. Gunderson" , Kim Phillips , Florian Fischer , James Clark , Suzuki Poulouse , Sean Christopherson , Leo Yan , John Garry , Kajol Jain , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers 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,USER_IN_DEF_DKIM_WL autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759842522407949144?= X-GMAIL-MSGID: =?utf-8?q?1759842522407949144?= List sorting, added later to evlist, passes const elements requiring helper functions to also be const. Make the argument to evsel__find_pmu, evsel__is_aux_event and evsel__leader const. Signed-off-by: Ian Rogers --- tools/perf/util/evsel.c | 2 +- tools/perf/util/evsel.h | 6 +++--- tools/perf/util/pmu.c | 6 +++--- tools/perf/util/python.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 51e8ce6edddc..2dc2c24252bb 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3139,7 +3139,7 @@ bool evsel__is_hybrid(const struct evsel *evsel) return evsel->pmu_name && perf_pmu__is_hybrid(evsel->pmu_name); } -struct evsel *evsel__leader(struct evsel *evsel) +struct evsel *evsel__leader(const struct evsel *evsel) { return container_of(evsel->core.leader, struct evsel, core); } diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 814a49ebb7e3..676c499323e9 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -212,8 +212,8 @@ int evsel__object_config(size_t object_size, int (*init)(struct evsel *evsel), void (*fini)(struct evsel *evsel)); -struct perf_pmu *evsel__find_pmu(struct evsel *evsel); -bool evsel__is_aux_event(struct evsel *evsel); +struct perf_pmu *evsel__find_pmu(const struct evsel *evsel); +bool evsel__is_aux_event(const struct evsel *evsel); struct evsel *evsel__new_idx(struct perf_event_attr *attr, int idx); @@ -505,7 +505,7 @@ int evsel__store_ids(struct evsel *evsel, struct evlist *evlist); void evsel__zero_per_pkg(struct evsel *evsel); bool evsel__is_hybrid(const struct evsel *evsel); -struct evsel *evsel__leader(struct evsel *evsel); +struct evsel *evsel__leader(const struct evsel *evsel); bool evsel__has_leader(struct evsel *evsel, struct evsel *leader); bool evsel__is_leader(struct evsel *evsel); void evsel__set_leader(struct evsel *evsel, struct evsel *leader); diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 43b6182d96b7..45d9b8e28e16 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -988,7 +988,7 @@ struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu) return NULL; } -struct perf_pmu *evsel__find_pmu(struct evsel *evsel) +struct perf_pmu *evsel__find_pmu(const struct evsel *evsel) { struct perf_pmu *pmu = NULL; @@ -1000,11 +1000,11 @@ struct perf_pmu *evsel__find_pmu(struct evsel *evsel) break; } - evsel->pmu = pmu; + ((struct evsel *)evsel)->pmu = pmu; return pmu; } -bool evsel__is_aux_event(struct evsel *evsel) +bool evsel__is_aux_event(const struct evsel *evsel) { struct perf_pmu *pmu = evsel__find_pmu(evsel); diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 42e8b813d010..ab48ffbb6448 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -83,7 +83,7 @@ const char *perf_env__arch(struct perf_env *env __maybe_unused) * far, for the perf python binding known usecases, revisit if this become * necessary. */ -struct perf_pmu *evsel__find_pmu(struct evsel *evsel __maybe_unused) +struct perf_pmu *evsel__find_pmu(const struct evsel *evsel __maybe_unused) { return NULL; }