Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp480402pxa; Thu, 27 Aug 2020 07:33:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS03q4KtgcJbiT4avkoqI+MWHXMWYRJf4gzzeSG8QoyNtEGYuVUqMLFZfZDuj/O/vR/7sn X-Received: by 2002:a17:906:7856:: with SMTP id p22mr20676146ejm.262.1598538807061; Thu, 27 Aug 2020 07:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598538807; cv=none; d=google.com; s=arc-20160816; b=QYx1PF8zkPVhe83ZTtcOaDmBisknxQvCh2/OTr2svLmZyoElJrQHZpHbp2ObNCeqxY v0IwKxXQZmDPjv1nOecUrYQF7EGWjHlECis93q6Sc90ctqVtORJJ1uUuklEtT62AGQqk yGwUGU8v2yvs9H6vkiuJkd07DlCevqSyELSr2ALVwGNpKUcMqXwf9RyfCIei27/2rJ8g i35JmgMJSaO1RIL/hQjjUqYRnk5a40SKMWrvdj3h3AIKomiHVSNuoieZaVuti3UbiFfJ 3d+Wy1NbPqlykinucpcLtGn2m/JNptNQtu9ck+b3r61HZ+wFBqNw2CT/OosQbwmQ/zAP PJvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9geIEdrsIi3MaEY++3YoQxcbMQfmZi4B7Ocukjkg+3c=; b=ulVhlgpIQuss8RdUAEflzQ1qHHDpc4iCgJFE3xTpOwlsa54ecoB+NiQcJugSVDJm88 lU8/Bn2Ma3j8XWN3+UhZNPdlUAu6MzbIyC9TEKj64tC23azadWFICRMiTQ91AujT61Bb Y1WVzVmvLg9q9i0D1nq/xLeP8550qcnnVk4Vb+26MFL8gZQjk7WIeC8vz6C+IImm82Gu xVjPaRN19iOdaK2Q2PrPt0rcAkIZ1Ut2ecHAw40ysLc13bNiy+Xc0BE7VZSpqAUBHFfN ajDyWosUClu1ZgTqv8S80zMF24eufKHNesuxo2c6Irk+JS/Nfu3AblXA6Y4woNRChZRR 67Lw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si1608381eds.21.2020.08.27.07.33.03; Thu, 27 Aug 2020 07:33:27 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgH0ObU convert rfc822-to-8bit (ORCPT + 99 others); Thu, 27 Aug 2020 10:31:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40302 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727864AbgH0OXz (ORCPT ); Thu, 27 Aug 2020 10:23:55 -0400 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-46-8yj2RV4cM1isgEhjcUsosg-1; Thu, 27 Aug 2020 09:48:37 -0400 X-MC-Unique: 8yj2RV4cM1isgEhjcUsosg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B4AF10506E1; Thu, 27 Aug 2020 13:48:36 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.195.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DF32702E7; Thu, 27 Aug 2020 13:48:34 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Ian Rogers Subject: [PATCH 2/2] perf tools: Call test_attr__open directly Date: Thu, 27 Aug 2020 15:48:30 +0200 Message-Id: <20200827134830.126721-2-jolsa@kernel.org> In-Reply-To: <20200827134830.126721-1-jolsa@kernel.org> References: <20200827134830.126721-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: kernel.org Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/util.h | 6 ++++++ 4 files changed, 14 insertions(+), 21 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/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