Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1785878pxb; Fri, 25 Mar 2022 05:44:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUDQ7h9pYzF76OCQ7eeTunNWvcbG1JWLSR/JSHIXHfuAmB6wMC98d2rXf36ZLfQyzV1zq/ X-Received: by 2002:a17:903:244e:b0:155:e4a0:bbf1 with SMTP id l14-20020a170903244e00b00155e4a0bbf1mr171541pls.47.1648212240834; Fri, 25 Mar 2022 05:44:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648212240; cv=none; d=google.com; s=arc-20160816; b=DdLsFdG7kbtGNJK0Qw19H2zqOWSUPeTMzwv5sfakbZHN31QdVI4Fo2mFLd1ELmKjej XoYR9307YMbFLHu8SYS6tj+q/e0stXomBdw8ikAAvaCgat9vdoBnaubooyhVAhFFsYUU SDmvTvYaJTsxsGRfxXI56HzcFBs/8o5RL57voNKrDDVgBvTgk+JzRJciy8R8JiNKZ9Z2 bEmYUBPwHh8mMRc1HI089dxkHj52qHN3Q6/nET30JsSlpGThlUgMUTCWA3KFzasEyDVF BsUD7DCkMzW5uXNue8E/a7y2CJEMrbFLWvtk/Ubj2S47ncMaEzF9qY0imOFa788N01Du rvSg== 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; bh=QCzcLNaWkM29zGdCrr4tOkDbqo+v+2tBHynq8iUrMpA=; b=olHKIIZOuhdcpT4f99c+q1bCAMjlcPQ3PMlV9IhXC9W/ChXqqhB3ePV8CTMMxQ0e5x fWBl1J+qG1Jbduv8s9liO35UF0CswclVSsD+RkkyXnehD26egCSGacuE8jN/XQ+wUjQn Ao1DyaB/TxGr9o/oje8V/NF0e+EQn9XEE0yfqsE+nWjtDs/Irqp8RkZO9HZ2zfUVNzfH GTeLtMnOxhOq1ZQ9k2b5brQ1X/N2eDvqAHnZuVahCzSpRhbl1txPxvotGwygaVxXRtR8 blukC6WZDlMzfL5ENkpkS6NVq8EATAXVn19HH8yzakmu1PTOawpQgWeBL/0kA/Bwm3Fo hYNA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z26-20020a65665a000000b003816043f026si2373398pgv.539.2022.03.25.05.43.47; Fri, 25 Mar 2022 05:44:00 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358267AbiCYEpF (ORCPT + 99 others); Fri, 25 Mar 2022 00:45:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244039AbiCYEpD (ORCPT ); Fri, 25 Mar 2022 00:45:03 -0400 Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97DAE6006B; Thu, 24 Mar 2022 21:43:20 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6200,9189,10296"; a="46962355" X-IronPort-AV: E=Sophos;i="5.90,209,1643641200"; d="scan'208";a="46962355" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP; 25 Mar 2022 13:43:16 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 91002CD6C0; Fri, 25 Mar 2022 13:43:17 +0900 (JST) Received: from oym-om3.fujitsu.com (oym-om3.o.css.fujitsu.com [10.85.58.163]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id A8927D975A; Fri, 25 Mar 2022 13:43:16 +0900 (JST) Received: from localhost.localdomain (bakeccha.fct.css.fujitsu.com [10.126.195.136]) by oym-om3.fujitsu.com (Postfix) with ESMTP id 659F2403F02E4; Fri, 25 Mar 2022 13:43:16 +0900 (JST) From: Shunsuke Nakamura To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [RFC PATCH v2 2/7] libperf: Move 'open_flags' from tools/perf to evsel::open_flags Date: Fri, 25 Mar 2022 13:38:24 +0900 Message-Id: <20220325043829.224045-3-nakamura.shun@fujitsu.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220325043829.224045-1-nakamura.shun@fujitsu.com> References: <20220325043829.224045-1-nakamura.shun@fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Move evsel::open_flags to perf_evsel::open_flags, so we can move the open_flags interface to libperf. Signed-off-by: Shunsuke Nakamura --- tools/lib/perf/evsel.c | 3 ++- tools/lib/perf/include/internal/evsel.h | 2 ++ tools/perf/util/evsel.c | 16 +++++++++------- tools/perf/util/evsel.h | 1 - 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c index 210ea7c06ce8..6640a333e6d9 100644 --- a/tools/lib/perf/evsel.c +++ b/tools/lib/perf/evsel.c @@ -26,6 +26,7 @@ void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr, evsel->attr = *attr; evsel->idx = idx; evsel->leader = evsel; + evsel->open_flags = 0; } struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr) @@ -158,7 +159,7 @@ int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus, fd = sys_perf_event_open(&evsel->attr, threads->map[thread].pid, - cpu, group_fd, 0); + cpu, group_fd, evsel->open_flags); if (fd < 0) return -errno; diff --git a/tools/lib/perf/include/internal/evsel.h b/tools/lib/perf/include/internal/evsel.h index cfc9ebd7968e..37a99cf261b3 100644 --- a/tools/lib/perf/include/internal/evsel.h +++ b/tools/lib/perf/include/internal/evsel.h @@ -51,6 +51,8 @@ struct perf_evsel { int nr_members; bool system_wide; int idx; + + unsigned long open_flags; }; void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr, diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 22d3267ce294..52c34552ee76 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1794,9 +1794,9 @@ static int __evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus, perf_evsel__alloc_fd(&evsel->core, perf_cpu_map__nr(cpus), nthreads) < 0) return -ENOMEM; - evsel->open_flags = PERF_FLAG_FD_CLOEXEC; + evsel->core.open_flags = PERF_FLAG_FD_CLOEXEC; if (evsel->cgrp) - evsel->open_flags |= PERF_FLAG_PID_CGROUP; + evsel->core.open_flags |= PERF_FLAG_PID_CGROUP; return 0; } @@ -1814,7 +1814,7 @@ static void evsel__disable_missing_features(struct evsel *evsel) evsel->core.attr.clockid = 0; } if (perf_missing_features.cloexec) - evsel->open_flags &= ~(unsigned long)PERF_FLAG_FD_CLOEXEC; + evsel->core.open_flags &= ~(unsigned long)PERF_FLAG_FD_CLOEXEC; if (perf_missing_features.mmap2) evsel->core.attr.mmap2 = 0; if (evsel->pmu && evsel->pmu->missing_features.exclude_guest) @@ -1902,7 +1902,8 @@ bool evsel__detect_missing_features(struct evsel *evsel) perf_missing_features.clockid = true; pr_debug2_peo("switching off use_clockid\n"); return true; - } else if (!perf_missing_features.cloexec && (evsel->open_flags & PERF_FLAG_FD_CLOEXEC)) { + } else if (!perf_missing_features.cloexec && + (evsel->core.open_flags & PERF_FLAG_FD_CLOEXEC)) { perf_missing_features.cloexec = true; pr_debug2_peo("switching off cloexec flag\n"); return true; @@ -2029,11 +2030,12 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, test_attr__ready(); pr_debug2_peo("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx", - pid, perf_cpu_map__cpu(cpus, idx).cpu, group_fd, evsel->open_flags); + pid, perf_cpu_map__cpu(cpus, idx).cpu, group_fd, + evsel->core.open_flags); fd = sys_perf_event_open(&evsel->core.attr, pid, perf_cpu_map__cpu(cpus, idx).cpu, - group_fd, evsel->open_flags); + group_fd, evsel->core.open_flags); FD(evsel, idx, thread) = fd; @@ -2050,7 +2052,7 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, if (unlikely(test_attr__enabled)) { test_attr__open(&evsel->core.attr, pid, perf_cpu_map__cpu(cpus, idx), - fd, group_fd, evsel->open_flags); + fd, group_fd, evsel->core.open_flags); } pr_debug2_peo(" = %d\n", fd); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 041b42d33bf5..8a545954eec7 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -152,7 +152,6 @@ struct evsel { struct bperf_leader_bpf *leader_skel; struct bperf_follower_bpf *follower_skel; }; - unsigned long open_flags; int precise_ip_original; /* for missing_features */ -- 2.25.1