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 DB697C6FA8E for ; Thu, 2 Mar 2023 22:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbjCBV5h (ORCPT ); Thu, 2 Mar 2023 16:57:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbjCBV5C (ORCPT ); Thu, 2 Mar 2023 16:57:02 -0500 Received: from mail-oi1-x249.google.com (mail-oi1-x249.google.com [IPv6:2607:f8b0:4864:20::249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66E05F6F2 for ; Thu, 2 Mar 2023 13:56:55 -0800 (PST) Received: by mail-oi1-x249.google.com with SMTP id cb5-20020a056808320500b003848c5da32eso203337oib.7 for ; Thu, 02 Mar 2023 13:56:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677794215; 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=UIVqwK5jBbR0oRflZcHSzDAzwP72SoIRImEYiaWbClPHJPQlLnrvHoH/OO94ylhzhe 6jStH2U4CmVZdMbY2nXUwFAjOFf1jUrJZP0NZi+gz5RvO98zIqEtrT0E5fqR8zvomk8l guZ8OSCA1sahf2Av76kjQUDE6+50TBkBNwAe9Yp03Ab2EuckGVQeVZHAsXjHTSrItyOC YzBv+u/5aoisXBwQOycguap9/bzao4rlooFEEaBKbbYCXQS84lLIhMMq/gRtdHy/zNoq A7JFT/9RRB439SCRE1rsVq8xeMUscS6GWrujrF/x08HWuHymg2gmsLaYQzhEiqCwNFQL 9UFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677794215; 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=Pzpn4donHWXjRMkO4nCM3FOQJ03wrd64YwbiVtrCm0Q8H6UVU3IBRZI1pdmXWw0rpH Vhn/5y/LoP+zpDlNwy3bWKc2jnviK8EEJdmy/wMMFgLE06dNFh1nwli/YsZlQl87nGnS KHr9rBSEHbWZqrVs6Hd9I7eZzl7CZF5nDQvBmr6NGaSGKrfNt1KwRk0BWFRflaZwPYfd GLtznGvFv2bMx5698Nyjdmn1Uy0csYnOsVpW036ulXssKddl9W6ahETDhAnIv7lK1uNU l1bZ+6d4QIYXePO1RBvhAfxoxIhvcw32HjZXXyv7GUBq4w8Gm8IGAT6au4//3/wOt9B4 LhBA== X-Gm-Message-State: AO0yUKUVzGZEDI2MQPdPb0prEOnLipA+s8UQN606g4k4HQiFO9ZQwHeH B7GBEkQd03ZkDN8dtTmohdQp0MRt7A5V X-Google-Smtp-Source: AK7set8EG+2QHSnGl+SsrkplMEsrRkrZK6RrmEtHNWM0JmQIeq0WDAJIcmhe259f39B7PGTkhwzUnyILVerf X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:5f50:6ef4:b4d0:568e]) (user=irogers job=sendgmr) by 2002:a05:6902:343:b0:aa9:bd2e:3744 with SMTP id e3-20020a056902034300b00aa9bd2e3744mr5222936ybs.9.1677792387767; Thu, 02 Mar 2023 13:26:27 -0800 (PST) Date: Thu, 2 Mar 2023 13:25:26 -0800 In-Reply-To: <20230302212531.1043318-1-irogers@google.com> Message-Id: <20230302212531.1043318-6-irogers@google.com> Mime-Version: 1.0 References: <20230302212531.1043318-1-irogers@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Subject: [PATCH v2 05/10] perf evsel: Allow const evsel for certain accesses From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Kan Liang , Zhengjun Xing , Ravi Bangoria , Adrian Hunter , "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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.40.0.rc0.216.gc4246ad0f0-goog