Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp279791pxb; Sat, 21 Aug 2021 02:24:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx945yOxcgkMPcclvqWbnNCTMbAOmHkIndLHphKdvQDXau+RsMUVwpHcajZ08eMpU6FNB8z X-Received: by 2002:a05:6e02:1094:: with SMTP id r20mr16146556ilj.55.1629537869541; Sat, 21 Aug 2021 02:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629537869; cv=none; d=google.com; s=arc-20160816; b=Mu8mZ6d6Ko+1EYOJqIxEb8ZO8Joaz653xRGOvWxEZ7P4PVFlPImYBVXNHKI6Cl5E/H pzWJD/3AlGGANq+tRVhIMMGJ4X00hUkDqx7sWkjLqprTzfgoe0fjkwBJ+X+db5NolHFq vVh4L3jFVTncI7vhjGv+xi/b3lRS6XTUX+sl62935tutdxyqd4laQ9FS8FHMhAH7PtTY ktwqZc9rtOpGLDukx1wBMwJ4DV24HkYePdI6wE+rzjk+GJkc3j5QAOGDBRorXzJlSu+E rwrWwlixDAwOpNZEza48jh0K9+T6Hybot7nLiMva5MtDR+FM/SNXzNnnqo/oscYdEvEr nz8Q== 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=54GMaFeo+0ii7XXdVN7OyGxlbAq4Jcyh9p53ycXRCvY=; b=HPOEo/ntwSczJTFVBcOFCaBC69g4rAUREdwMLb2rkKiam0U7NrvBr3+yiqnuY3t/cf WO4dJqbz92NQAEkZSFGpuCJi44SYgK9ij6YmZdav+GCTi9fVV59pym/ls8Vd+13JC+dB nW/Y9mnxbfm3z+F3VNqjO08dP9Lhb27c2agINvjFdPe3mcAXt0QtSeejPf2DSX3jxhAN lx1AgLLAGX76dKyhzzyBj8o9O7+TxmSr23JYcPLv1b/eoFmBOSgaGVlWNmcPCmu27VO6 aszB3xxDxaHPl0lL0RmkEibUAF+SMvUCVhXYwAQhBZ6FwUsEjG1yRiPa34nss+ObK8pz sIJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f6FvLaET; 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 s15si8170678jaj.78.2021.08.21.02.24.18; Sat, 21 Aug 2021 02:24:29 -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=f6FvLaET; 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 S234989AbhHUJWj (ORCPT + 99 others); Sat, 21 Aug 2021 05:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235333AbhHUJV6 (ORCPT ); Sat, 21 Aug 2021 05:21:58 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85E1FC061144; Sat, 21 Aug 2021 02:20:22 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id q3so17661996edt.5; Sat, 21 Aug 2021 02:20:22 -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=54GMaFeo+0ii7XXdVN7OyGxlbAq4Jcyh9p53ycXRCvY=; b=f6FvLaETibhXox2YQ39Lc+SJfu9Vo/EqS1NZyGo8hGRMUepgc8jNljcjcnctclfV65 SEDKK3ceXA4XW5N1Md5F8CFFKCrgmG3w1qsawwaYtri3Axe9qMWh163cTfGxcsnZENAA phtuhTyJgI7MW0QJeiKsmEcdFG6PfAflcTQjeXRdl/J7sCH5LPF3ccLftuywVbFMVES/ QohdcKu4wyKM3YNrNny1mSSjeCe0BALohSzT77mbIq7jn1gwox5PKdoqvdUT3f9VS1/o Dbi7bBt7LkWPdEQWy8T3Qf4PGHKS2p/YMC6R2brwd77Pi72wM8FI3AdmCAj9uhCJJ99W k+fw== 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=54GMaFeo+0ii7XXdVN7OyGxlbAq4Jcyh9p53ycXRCvY=; b=iyTVp0oMo3BdcTz/LDMgoV5vGusRhfY7ql2WVtnhJOUwLoNksl19mu1lgylxat3DUO h+9fufJejPnMF5eaU3a7LcYQB543SP4asklI2AvpzOl0LYIBi2ndkeSbTooZP//hTBCT yY+TyPbLmcfrt9F8HB/+dqI+WEchDcWUNSl+q+W1KjRinZl2fAZcCTJ262lfgvhi3IbR c6tkuV0r1exgy5VGyYeY4ryr/jCCNTpp/GiTBPg+hho+avY045t5bbB909mc5/pTYIB5 UeXBN1eImJ0Q4Am7zf/Nx1QICLZtZZkQcVbBL6igUAfAiNEMkM7lAzFpLw6h/62gOWov /bsQ== X-Gm-Message-State: AOAM5319RfDxBJ495+9JUsnGHmzA8ubxRcBaC99MJW41WnkN3GIjHVwz esfjTKxbb7I5nPXK/P7gRNs= X-Received: by 2002:aa7:db8b:: with SMTP id u11mr26503283edt.362.1629537621120; Sat, 21 Aug 2021 02:20:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 02:20:20 -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 26/37] perf evsel: add evsel__open_per_cpu_no_fallback function Date: Sat, 21 Aug 2021 11:19:32 +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 This function is equivalent to evsel__open, but without any fallback mechanism, which should be handled separately. It is also possible to a starting thread to be able to resume a previous failing evsel__open_per_cpu_no_fallback. Signed-off-by: Riccardo Mancini --- tools/perf/util/evsel.c | 44 +++++++++++++++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 9 +++++++++ 2 files changed, 53 insertions(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e41f55a7a70ea630..74aad07f3c1102cb 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2021,6 +2021,50 @@ static struct perf_event_open_result perf_event_open(struct evsel *evsel, return res; } +struct evsel_open_result evsel__open_per_cpu_no_fallback(struct evsel *evsel, + struct perf_cpu_map *cpus, + struct perf_thread_map *threads, + int cpu, int start_thread) +{ + int thread, nthreads, pid = -1; + struct evsel_open_result res = { .thread = start_thread }; + + if (cpus == NULL) + cpus = empty_cpu_map; + + if (threads == NULL) + threads = empty_thread_map; + + if (evsel->core.system_wide) + nthreads = 1; + else + nthreads = threads->nr; + + if (evsel->cgrp) + pid = evsel->cgrp->fd; + + display_attr(&evsel->core.attr); + + + for (thread = start_thread; thread < nthreads; thread++) { + res.peo_res = perf_event_open(evsel, pid, cpu, thread, cpus, + threads); + + switch (res.peo_res.err) { + case PEO_SUCCESS: + continue; + case PEO_FALLBACK: + goto out; + default: + case PEO_ERROR: + goto out; + } + } +out: + res.thread = thread; + return res; +} + static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, struct perf_thread_map *threads, int start_cpu, int end_cpu) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 8c9827a93ac001a7..fa0d732d0a088016 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -294,10 +294,19 @@ struct perf_event_open_result { int fd; }; +struct evsel_open_result { + int thread; + struct perf_event_open_result peo_res; +}; + int evsel__open_per_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, int cpu); int evsel__open_per_thread(struct evsel *evsel, struct perf_thread_map *threads); int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, struct perf_thread_map *threads); +struct evsel_open_result evsel__open_per_cpu_no_fallback(struct evsel *evsel, + struct perf_cpu_map *cpus, + struct perf_thread_map *threads, + int cpu, int start_thread); void evsel__close(struct evsel *evsel); int evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus, struct perf_thread_map *threads); -- 2.31.1