Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4751271pxv; Tue, 6 Jul 2021 08:18:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylIRVLUHtybx5rlSHVaYvoJS/seTrkuP8rx74ItiP/96ogY9Zfl+EPL8h+9rw0k7eR6Alm X-Received: by 2002:a05:6e02:1d86:: with SMTP id h6mr486714ila.159.1625584736413; Tue, 06 Jul 2021 08:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625584736; cv=none; d=google.com; s=arc-20160816; b=eIdG/j71TLrkayeFAz1ffmxXXfOU61nj1gcs+AkY3WbqtbXV4PED6s9fWfYdX7gSho N3DAot619qE5VmfNsYjZsUUob45ZpELDg9DU3/L/wNBTEfbSsiCHq55vcB2I7ajOaCCO Zne128u9N8jjfDwGdIS+ysUJb4POLqKtX8lTksfrbxl1slKlfqj6yZMBkiuE+5xp5vXP OeZ8JhvUjNo7IpWT8mK1WJe1DmiLDDgAxqkppdpgSHCmNJdoakJj/zG/jGAHOiOD82NU JjN0UR3pOw3wj1LxkUkeS9KCawyYb2zdniDLw6P+A162BHqyDny2G3dlONdlYILwVhZL GtmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tOpmQlI5h4Fk2I5eFc58+NXtZElRb7F5uumjvKfZx3U=; b=QCACraXzwIqxjmRc6mh/59io9jZGr1i53pyyU1ogYoFS2K4T4NRDsa5lxJTfxcxUMR BrTtm+TLoWc9bA5NQsUZ3jyGHVdCzEPQ7cMtwZ9hlkoe+/6l5MPZet8ZUSvEVbPWvyw/ aBE1HimD2pA86UOYUU8hMqqNO3zWbiQb+AlNK3pE8ynAV3Ir5lzO3u/u6TwFvstzi/nt +AXvyND5Fg6EmLZeC65/oEIeB7qfMWtF/TCD+TPruyM4+dl380u3y3ZlaA5rZIzGA/jd 8kOP7UvcVgT/kNWiQB6VfStdKH3zP7l/peg+eJ97lgOqh+pR9rxvOw3/4luOh8l8Fcv8 GDyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AqRMRJ2S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si9650798iow.18.2021.07.06.08.18.45; Tue, 06 Jul 2021 08:18:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AqRMRJ2S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232715AbhGFPU2 (ORCPT + 99 others); Tue, 6 Jul 2021 11:20:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59380 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232741AbhGFPUY (ORCPT ); Tue, 6 Jul 2021 11:20:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625584665; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tOpmQlI5h4Fk2I5eFc58+NXtZElRb7F5uumjvKfZx3U=; b=AqRMRJ2SUdPjB1480qVwSeTjJwS/WhDGK5rvNiGJJEq4Y6lXMtqgR2YaT61eOGFYp7DWFs uNY/xXZs7uGHLRePRFoiiuGjHivMyZxuDlsReObMDHWiK+ZKP+bG6nn6Mf9QSL1RCE/axf Y2GClgY+piJsY63J85K8JrcecmuLHcc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-341-kYfdQf_yMQaHjmRxfbQJEw-1; Tue, 06 Jul 2021 11:17:44 -0400 X-MC-Unique: kYfdQf_yMQaHjmRxfbQJEw-1 Received: by mail-wr1-f72.google.com with SMTP id z2-20020a5d4d020000b0290130e19b0ddbso3657009wrt.17 for ; Tue, 06 Jul 2021 08:17:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tOpmQlI5h4Fk2I5eFc58+NXtZElRb7F5uumjvKfZx3U=; b=n0zIPJMBiDX5BAXgaswPuQzJjV+HhzepttY7q4eBTmDRm6PDnUnvqM5eb81pMFwp38 26tBbBnqOkLpN95DWwx3+NmqDbmcUqARfNgmSbvWFNZXiXktvSDJ/1ZmQiP31Vl1+kzA W6gQ5TeRJq0+rEfTyAYXXewQNUBHhfUZ/dN2JvcS028skArpac/64Ja9X1UlxWYoW95X AmXnLXTiWvfDAlZ5eLSPwsrK0cAGMVZquEq4SJk76Dla7bXQn8GY+flzPWDBKLtC3j5D ZUalljlBgFgAEmD0/STXUQlXCUv7Z60cuig6VxuDJIVI3++8/lZ6Gd+/jKiT/fjnKv/F lOsA== X-Gm-Message-State: AOAM533w6zkovGBn6uCn65sFvpOVGGHZYjKUQrdcCp1wUhKH1ihZB/ta ErQS/d4dompOtokzg/+6BT30sTpOVMhRLriOF/jH6Zk7LVI89vA4CeyH/Ee7jngw7Fd6zJ/h36c tcS5pmGhfwMuW4rlP6qxr7+yU X-Received: by 2002:adf:b605:: with SMTP id f5mr22556352wre.419.1625584663831; Tue, 06 Jul 2021 08:17:43 -0700 (PDT) X-Received: by 2002:adf:b605:: with SMTP id f5mr22556334wre.419.1625584663684; Tue, 06 Jul 2021 08:17:43 -0700 (PDT) Received: from krava.redhat.com ([185.153.78.55]) by smtp.gmail.com with ESMTPSA id d24sm3151612wmb.42.2021.07.06.08.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 08:17:43 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Ian Rogers , nakamura.shun@fujitsu.com, linux-perf-users@vger.kernel.org Subject: [PATCH 5/7] libperf: Add perf_evlist__set_leader function Date: Tue, 6 Jul 2021 17:17:02 +0200 Message-Id: <20210706151704.73662-6-jolsa@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210706151704.73662-1-jolsa@kernel.org> References: <20210706151704.73662-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moving the implementation of evlist__set_leader under the new libperf perf_evlist__set_leader function with the same functionality and as exported API. Signed-off-by: Jiri Olsa --- tools/lib/perf/evlist.c | 21 +++++++++++++++++++++ tools/lib/perf/include/internal/evlist.h | 1 + tools/lib/perf/include/perf/evlist.h | 1 + tools/lib/perf/libperf.map | 1 + tools/perf/util/evlist.c | 19 +------------------ tools/perf/util/evlist.h | 1 - tools/perf/util/parse-events.c | 2 +- 7 files changed, 26 insertions(+), 20 deletions(-) diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index 68b90bbf0ffb..e37dfad31383 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -642,3 +642,24 @@ perf_evlist__next_mmap(struct perf_evlist *evlist, struct perf_mmap *map, return overwrite ? evlist->mmap_ovw_first : evlist->mmap_first; } + +void __perf_evlist__set_leader(struct list_head *list) +{ + struct perf_evsel *evsel, *leader; + + leader = list_entry(list->next, struct perf_evsel, node); + evsel = list_entry(list->prev, struct perf_evsel, node); + + leader->nr_members = evsel->idx - leader->idx + 1; + + __perf_evlist__for_each_entry(list, evsel) + evsel->leader = leader; +} + +void perf_evlist__set_leader(struct perf_evlist *evlist) +{ + if (evlist->nr_entries) { + evlist->nr_groups = evlist->nr_entries > 1 ? 1 : 0; + __perf_evlist__set_leader(&evlist->entries); + } +} diff --git a/tools/lib/perf/include/internal/evlist.h b/tools/lib/perf/include/internal/evlist.h index f16fa9877d27..f366dbad6a88 100644 --- a/tools/lib/perf/include/internal/evlist.h +++ b/tools/lib/perf/include/internal/evlist.h @@ -127,4 +127,5 @@ int perf_evlist__id_add_fd(struct perf_evlist *evlist, void perf_evlist__reset_id_hash(struct perf_evlist *evlist); +void __perf_evlist__set_leader(struct list_head *list); #endif /* __LIBPERF_INTERNAL_EVLIST_H */ diff --git a/tools/lib/perf/include/perf/evlist.h b/tools/lib/perf/include/perf/evlist.h index 0a7479dc13bf..9ca399d49bb4 100644 --- a/tools/lib/perf/include/perf/evlist.h +++ b/tools/lib/perf/include/perf/evlist.h @@ -46,4 +46,5 @@ LIBPERF_API struct perf_mmap *perf_evlist__next_mmap(struct perf_evlist *evlist, (pos) != NULL; \ (pos) = perf_evlist__next_mmap((evlist), (pos), overwrite)) +LIBPERF_API void perf_evlist__set_leader(struct perf_evlist *evlist); #endif /* __LIBPERF_EVLIST_H */ diff --git a/tools/lib/perf/libperf.map b/tools/lib/perf/libperf.map index c0c7ceb11060..71468606e8a7 100644 --- a/tools/lib/perf/libperf.map +++ b/tools/lib/perf/libperf.map @@ -45,6 +45,7 @@ LIBPERF_0.0.1 { perf_evlist__munmap; perf_evlist__filter_pollfd; perf_evlist__next_mmap; + perf_evlist__set_leader; perf_mmap__consume; perf_mmap__read_init; perf_mmap__read_done; diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 752f64afd622..47581a237c7a 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -223,26 +223,9 @@ int __evlist__set_tracepoints_handlers(struct evlist *evlist, return err; } -void __evlist__set_leader(struct list_head *list) -{ - struct evsel *evsel, *leader; - - leader = list_entry(list->next, struct evsel, core.node); - evsel = list_entry(list->prev, struct evsel, core.node); - - leader->core.nr_members = evsel->core.idx - leader->core.idx + 1; - - __evlist__for_each_entry(list, evsel) { - evsel->core.leader = &leader->core; - } -} - void evlist__set_leader(struct evlist *evlist) { - if (evlist->core.nr_entries) { - evlist->core.nr_groups = evlist->core.nr_entries > 1 ? 1 : 0; - __evlist__set_leader(&evlist->core.entries); - } + perf_evlist__set_leader(&evlist->core); } int __evlist__add_default(struct evlist *evlist, bool precise) diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index cb2bf5f4866a..5c22383489ae 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -201,7 +201,6 @@ void evlist__set_selected(struct evlist *evlist, struct evsel *evsel); int evlist__create_maps(struct evlist *evlist, struct target *target); int evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel); -void __evlist__set_leader(struct list_head *list); void evlist__set_leader(struct evlist *evlist); u64 __evlist__combined_sample_type(struct evlist *evlist); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index f6d77cb44007..e5eae23cfceb 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1833,7 +1833,7 @@ void parse_events__set_leader(char *name, struct list_head *list, if (parse_events__set_leader_for_uncore_aliase(name, list, parse_state)) return; - __evlist__set_leader(list); + __perf_evlist__set_leader(list); leader = list_entry(list->next, struct evsel, core.node); leader->group_name = name ? strdup(name) : NULL; } -- 2.31.1