Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp278913pxb; Sat, 21 Aug 2021 02:22:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwu1dQn1B5kt4dlKMpv+8RtormDIjeNYs8AwyoU85njUmG6qHf+FsDEPPLRVJLn1xjd1znC X-Received: by 2002:a92:d94c:: with SMTP id l12mr16269231ilq.101.1629537778612; Sat, 21 Aug 2021 02:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629537778; cv=none; d=google.com; s=arc-20160816; b=P+3/AcdmyToHIpbfDbZ17VJgrwf2m5b+RIpNf6f3LkkaXdZkFDqbhc+G6oM28I6m/Q +3/7tpMtn8VL6uQHy0SOBH9XPPN7zGi0hyRoBXldYQ7yF8uPv+2j7zwqjodWHTjiGzDe 9xWKtFUCfKZdxlwDkqw5HAyom3keXYXYLbWehcGcIYJhXf13rTIfVYjhD2cafTWyN46y n/PvBjwRPqlfJ22zkTgUZZQ8E57YFfAQMkpSyxLd0MzYxteJcXMXNcpyCT0P9my67tcP q25JXDZQWzgkx3FUZIbbE1s6LZtV/KXRRX1l1ZMKnqI2LUxhVH178svzdhHb1IMvsZUM G1Tg== 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=2DKoXbLqb5JEZfckQbGfo0eY1oqTs4gsyzCuCjXFWuM=; b=eiONzX+nU7TcFAJ0Mn+CM7TD5mXoYf6v13Vi44tPFlIqiC2R+v3rA/DX1eJOwtY6j0 EpLq/Wyp5CDhEhJbYzojdTgfi57Esxt1Oe5vK4JC7hhkWNLEIzrvhscgmVmIOdkvm9FN 1jqkWk2iroi08OuAmjRbaTgCVtfazFBXXC/CtO6kh0CDmV3PY62f5PBKhRjR3V9oeono r57iE5MiOmxqxq6Cwfa1aE+/WVNO0JH6MOjHgyoz9gvnnXTDtWe+ws8+ic7JKhuqOPWA SJdBWM29i3gI9/DrFArnJYTwX/Wk6bb1tgVSXidXOgPoKQv2q8T6FeY4MNYk1jifCM8V qRIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=goOtNRcc; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r131si6496669ior.19.2021.08.21.02.22.47; Sat, 21 Aug 2021 02:22:58 -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=@gmail.com header.s=20161025 header.b=goOtNRcc; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240835AbhHUJWQ (ORCPT + 99 others); Sat, 21 Aug 2021 05:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234017AbhHUJVj (ORCPT ); Sat, 21 Aug 2021 05:21:39 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76E89C0611C2; Sat, 21 Aug 2021 02:20:17 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id bo19so17595501edb.9; Sat, 21 Aug 2021 02:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2DKoXbLqb5JEZfckQbGfo0eY1oqTs4gsyzCuCjXFWuM=; b=goOtNRccV4Ca5TUodnLlBiWwZbJJo4TWXbcTtsYNzoCukYgdjdCx6uHLXg7h/LJgv2 hpvzqKh1Y90enpyN442g5a02CC7kxb3+1ZZr3s3UUWs5P6Ff5Nb3S3RKom7p9B8LaWtN a2cvV78I+6Gfmyxot7CJZ1rX5XInkZIPFu0IcYrDd2UvA8aNhQXtLmJNyPIUuhUrcV0+ Hnrwlw3WnPCb7bVevf8eYsyqZaNfb98SvFcbZtuU6fBba42PnnUlMsxBCPvWBCpecezw tBqJawlPnEfMQwPsRiTXvYoFnkX5JBlNjI9zAcTtTnw8kWHaLj+Ent6B961Cxb4/2eNU iU+Q== 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=2DKoXbLqb5JEZfckQbGfo0eY1oqTs4gsyzCuCjXFWuM=; b=lvmzHL/3T6Jm+fgDI4sjVLinIbqGCOTTaWa9gGvSQLVJtYSNCUnDcQdUw+7QZTwNMJ ZbWG/isQRzZ9IChEcPD0S53a41NHVUg1vyoiyEDB5vW7MAnsFxs2md1+tGRisZpXpHa7 SVeI8rpEokze/32l7C2izMq9kwL7rM0hjR5EHFhkqApEowKKC9uvNKD3ZQEFFlZQDWVm Bcy4jJ54JEmgo1wF372ieQblHm0NKKOhpsNnW/IgPC9i3+bqPWFYLNApRAiWFmZgmERO K5f9E4/PTuyzQRi/uPWQ+3oaa+mwmvtvhAMaoPfPhVIvzmzU57GVhbXSudfuPX/re3je 0zGg== X-Gm-Message-State: AOAM5320LRb8BCLCdpPKwOacw5rD4MM3615KVpGZppdpOMZwH8VwXCGT u8I2d1DQWqXLEp6N9P6jpEQ= X-Received: by 2002:a05:6402:214d:: with SMTP id bq13mr26632573edb.263.1629537615955; Sat, 21 Aug 2021 02:20:15 -0700 (PDT) Received: from honeypot.. (mob-176-243-254-204.net.vodafone.it. [176.243.254.204]) by smtp.googlemail.com with ESMTPSA id a25sm4003878ejv.91.2021.08.21.02.20.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 02:20:15 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Riccardo Mancini Subject: [RFC PATCH v1 22/37] perf evsel: move test_attr__open to success path in evsel__open_cpu Date: Sat, 21 Aug 2021 11:19:28 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org test_attr__open ignores the fd if -1, therefore it is safe to move it to the success path (fd >= 0). Signed-off-by: Riccardo Mancini --- tools/perf/util/evsel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index a1a88607fd59efcb..d2b0391569286080 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2011,11 +2011,6 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, bpf_counter__install_pe(evsel, cpu, fd); - if (unlikely(test_attr__enabled)) { - test_attr__open(&evsel->core.attr, pid, cpus->map[cpu], - fd, group_fd, evsel->open_flags); - } - if (fd < 0) { err = -errno; @@ -2024,6 +2019,11 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, goto try_fallback; } + if (unlikely(test_attr__enabled)) { + test_attr__open(&evsel->core.attr, pid, cpus->map[cpu], + fd, group_fd, evsel->open_flags); + } + pr_debug2_peo(" = %d\n", fd); if (evsel->bpf_fd >= 0) { -- 2.31.1