Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp672463pxa; Thu, 27 Aug 2020 12:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI6fY/+/dbmc7iLuzcGWw9qRBAUDVGksq75SKBDlopBEN0EvF5aiu1FLNNFSACv0fwi6Uf X-Received: by 2002:aa7:cf08:: with SMTP id a8mr7556201edy.98.1598556795253; Thu, 27 Aug 2020 12:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598556795; cv=none; d=google.com; s=arc-20160816; b=GXiMc0ac6NkXuLQ1HrCE0e4yQH6GXa0Y0x+TRJFFodrtBjQSgb3UWWEIUmcfYgaj4s GJC9c8vZoAQqlGb5n4VcLXuJrmuNVSJinjm60MKFwlzarM2vije7sEuz08w0uW453mMc y6qmFEHo4nTbXBfzwDWXcUSmpwqw5Ib3k3Vw+ergXh/ZlqNrUiA6zU4qdZmveUGT6SFh uNwyBN8gButujDM88FixVM1AgiTaagy1J9mh2TJHke66OTqIKXcpoRs+Fx2J0dN5jfiA ejNmDUqyMGRCfDTlRpqEo0Cfb6VDUxZHGm483SjGYhCSXQuHNjzub38su2BaPHrjnqrH H28g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=/9xAmTgJVfsiCYeKazNzgThAXMURwu5yzaqgwbV0E6Y=; b=wGxJf1wPJHaL3T9anTig7LTHSKrKXlzvlqN04J2VXJKdjaC+SG2ugVV+oMraiMOC+4 TQHsQEGIdSaOnJ7R8NNaszMkGyZTGcz0m3lhdrvPM9JeP+W2tAunfHPtNLaM6Fne8g3G k0VhLYTlz1cGDEt0BC3VyBz846OCpKbBIoMz9SlT16BHxZnJMrK0YNWkgpFxhnT3LOde UIw7MPVz0Gt5DBfy5HBEUsHS0S97napWGQFPDI9wZIz8yXNNV7JeAGo+CqeIdgRcA1IL znzuvnsKVTaPhdS3nkQzjZzAI29VfyiFUUDszk8jUtT29CVonZmqjVVEB/iNpOAVBNaj mwXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ahin3CTi; 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 l2si1973024ejg.403.2020.08.27.12.32.53; Thu, 27 Aug 2020 12:33:15 -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=Ahin3CTi; 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 S1726912AbgH0TcR (ORCPT + 99 others); Thu, 27 Aug 2020 15:32:17 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42053 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726197AbgH0TcP (ORCPT ); Thu, 27 Aug 2020 15:32:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598556733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/9xAmTgJVfsiCYeKazNzgThAXMURwu5yzaqgwbV0E6Y=; b=Ahin3CTi5mDpj5isbXg+RJhVJR0LPYWeolvwIfIRNGDvvbxdOTm6XMsfQD+c5DLA9A2AZd grd4Z2Aw8eT3A/OKVM6/sQW7fs21XdrG+S+bcvJVUjhHVEq3DYNCQ77/d8+9CwYGGOMziL 7AvO7MyxtULec7jwMNp4hsIVGWmERe8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-110-JYC_s1ssP6ue45qGYdp3KA-1; Thu, 27 Aug 2020 15:32:08 -0400 X-MC-Unique: JYC_s1ssP6ue45qGYdp3KA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 488FA807337; Thu, 27 Aug 2020 19:32:07 +0000 (UTC) Received: from krava (unknown [10.40.192.67]) by smtp.corp.redhat.com (Postfix) with SMTP id 26B075D9E8; Thu, 27 Aug 2020 19:32:02 +0000 (UTC) Date: Thu, 27 Aug 2020 21:32:01 +0200 From: Jiri Olsa To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Ian Rogers Subject: [PATCHv2] perf tools: Call test_attr__open directly Message-ID: <20200827193201.GB127372@krava> References: <20200827134830.126721-1-jolsa@kernel.org> <20200827134830.126721-2-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200827134830.126721-2-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org nack.. forgot python header change :-\ v2 attached thanks, jirka --- There's no longer need to have test_attr__open inside sys_perf_event_open call, because both record and stat call evsel__open_cpu, so we can call it directly from there and not polute perf-sys.h header. Signed-off-by: Jiri Olsa --- tools/perf/perf-sys.h | 22 ++-------------------- tools/perf/tests/attr.c | 2 +- tools/perf/util/evsel.c | 5 +++++ tools/perf/util/python.c | 2 +- tools/perf/util/util.h | 6 ++++++ 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h index 15e458e150bd..7a2264e1e4e1 100644 --- a/tools/perf/perf-sys.h +++ b/tools/perf/perf-sys.h @@ -9,31 +9,13 @@ struct perf_event_attr; -extern bool test_attr__enabled; -void test_attr__ready(void); -void test_attr__init(void); -void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, - int fd, int group_fd, unsigned long flags); - -#ifndef HAVE_ATTR_TEST -#define HAVE_ATTR_TEST 1 -#endif - static inline int sys_perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, int group_fd, unsigned long flags) { - int fd; - - fd = syscall(__NR_perf_event_open, attr, pid, cpu, - group_fd, flags); - -#if HAVE_ATTR_TEST - if (unlikely(test_attr__enabled)) - test_attr__open(attr, pid, cpu, fd, group_fd, flags); -#endif - return fd; + return syscall(__NR_perf_event_open, attr, pid, cpu, + group_fd, flags); } #endif /* _PERF_SYS_H */ diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index a9599ab8c471..ec972e0892ab 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -30,9 +30,9 @@ #include #include #include -#include "../perf-sys.h" #include #include "event.h" +#include "util.h" #include "tests.h" #define ENV "PERF_TEST_ATTR" diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index fd865002cbbd..6f0e23105cf8 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1680,6 +1680,11 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, FD(evsel, cpu, thread) = fd; + if (unlikely(test_attr__enabled)) { + test_attr__open(&evsel->core.attr, pid, cpus->map[cpu], + fd, group_fd, flags); + } + if (fd < 0) { err = -errno; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 75a9b1d62bba..74f85948d101 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -17,7 +17,7 @@ #include "mmap.h" #include "util/env.h" #include -#include "../perf-sys.h" +#include "util.h" #if PY_MAJOR_VERSION < 3 #define _PyUnicode_FromString(arg) \ diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index f486fdd3a538..ad737052e597 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -62,4 +62,10 @@ char *perf_exe(char *buf, int len); #endif #endif +extern bool test_attr__enabled; +void test_attr__ready(void); +void test_attr__init(void); +struct perf_event_attr; +void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, + int fd, int group_fd, unsigned long flags); #endif /* GIT_COMPAT_UTIL_H */ -- 2.26.2