Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4782007pxy; Tue, 27 Apr 2021 12:28:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxslQVo0fzpPoNe72RpSSp7LZ4uoNRGQ9ne3mq7TntbZosvIvST/Nrwmw7BEWe2WecU1ffi X-Received: by 2002:a17:906:17ca:: with SMTP id u10mr24395544eje.124.1619551721469; Tue, 27 Apr 2021 12:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619551721; cv=none; d=google.com; s=arc-20160816; b=Uusx8h9RAQswbk1EHMFKdcwg675yNGKK0s4JrLdR78twfVYdeQRYgKCavI4T6+OD5G BLE08CUTnFfQrP4asC+2SXzdB3X4k33deFBHq3+jyZUKrw6BCOOUoVIvVwp9FlseHjoY EXkwyseMFYBNqoUwZog/tQi+NPd1L4YbYw9T7oKF83MDweJv3DlVE5+94nRy5P/t2xnV GF/0Xxqa65buptwA4NmxhbazbKKjav1dEF4IoiA5L2sTf9ZyNq8wXaiXks1Ygv618WZK nJlNL6qHlMzoUjUcmIEV3JPWEPkJZZOGYdWd6KUlHfI+EvuI9nVY1SkS1XYI7C4zAqeY E+cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sQm7C0csGCSUphGwwy3EJS3COvPu540ShVAmaOf+je0=; b=vREH2tIQkviaYM4XCKXg1BtYv8AiVnf3PWk3z8XmcNa9tw8cYUDNWuV5pe0BAML8fi gQhe33jL4g7zffz5BfrZjDkmbTl6TEydHfQf1qsCOlN6Qq5uSUbZfxWrHNijvwtEEBn9 faewHTFaR5sWxdvpd1arhgzLDTZJWJ/NG9tuHRd3uUR4ZXQA/ijw9dNqR2lG5WJOfnYj k9mmwBrlCgeh+w0Eqc/y/9d6N0RZ5ts+R+fPPZIUJAjWGeBOLn2PYKjH9GgzwGN5JG5r 4lC0JBDKEhTEhacoxq7Ln6rd+tFglfJ0wWLX8OLQ79PH+HldxJRpoHlEQe2yHiJ9UEv5 3U3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tPdHSJYU; 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 b2si3415687edy.80.2021.04.27.12.28.18; Tue, 27 Apr 2021 12:28:41 -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=@kernel.org header.s=k20201202 header.b=tPdHSJYU; 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 S235719AbhD0T2J (ORCPT + 99 others); Tue, 27 Apr 2021 15:28:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:37792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235563AbhD0T2I (ORCPT ); Tue, 27 Apr 2021 15:28:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E4899613F6; Tue, 27 Apr 2021 19:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619551645; bh=zODLgaHDmvG4j+p01pswoad3NugaCPrLy4HTzlU8D54=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tPdHSJYUrzZXRrBNAweKWhOs+1WcH0Cz8K9syNgDU//9YMirmPLIzn9wO79ETLGhN l04LK/nWw1h3R77uBQ7Q/p6x8oGxTeN9RaFh+sSHMGF//W/b+lwkI78f9hh+nhAhpm g+TQz4vvjfaqpYCM5YK09+Mu2oT6CEyiJ7KzFNvgKPbCT7hUFM70PMzuOBF2nhHtIk fzFw97FuoNbF9ugfEpPh0OPYv8F04SPJrs2XowMoD5MT/BtzKMN7inFRSYnjDPXY9p qWUgvXcLW2gpZo/9GhYnD8sh0oL0JtCRGe8xsP5lU8MD0WobYP3j8hhBZ+Fd9ZtBGr U7ljp30XIq23A== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 4B59C40647; Tue, 27 Apr 2021 16:27:22 -0300 (-03) Date: Tue, 27 Apr 2021 16:27:22 -0300 From: Arnaldo Carvalho de Melo To: Song Liu Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, acme@redhat.com, namhyung@kernel.org, jolsa@kernel.org, songliubraving@fb.com Subject: Re: [PATCH v5 5/5] perf-stat: introduce bpf_counter_ops->disable() Message-ID: References: <20210425214333.1090950-1-song@kernel.org> <20210425214333.1090950-6-song@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210425214333.1090950-6-song@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sun, Apr 25, 2021 at 02:43:33PM -0700, Song Liu escreveu: > Introduce bpf_counter_ops->disable(), which is used stop counting the > event. [acme@five perf]$ perf test -v python Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc 19: 'import perf' in python : --- start --- test child forked, pid 1497924 python usage test: "echo "import sys ; sys.path.append('/tmp/build/perf/python'); import perf" | '/usr/bin/python3' " Traceback (most recent call last): File "", line 1, in ImportError: /tmp/build/perf/python/perf.cpython-39-x86_64-linux-gnu.so: undefined symbol: bpf_counter__disable test child finished with -1 ---- end ---- 'import perf' in python: FAILED! [acme@five perf]$ I'll fix this up in my local tree, if you need to respin, please pick patches from tmp.perf/core, will refresh it later today. - Arnaldo > Signed-off-by: Song Liu > --- > tools/perf/util/bpf_counter.c | 26 ++++++++++++++++++++++++++ > tools/perf/util/bpf_counter.h | 7 +++++++ > tools/perf/util/evlist.c | 4 ++++ > 3 files changed, 37 insertions(+) > > diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c > index f179f57430253..ddb52f748c8e8 100644 > --- a/tools/perf/util/bpf_counter.c > +++ b/tools/perf/util/bpf_counter.c > @@ -215,6 +215,17 @@ static int bpf_program_profiler__enable(struct evsel *evsel) > return 0; > } > > +static int bpf_program_profiler__disable(struct evsel *evsel) > +{ > + struct bpf_counter *counter; > + > + list_for_each_entry(counter, &evsel->bpf_counter_list, list) { > + assert(counter->skel != NULL); > + bpf_prog_profiler_bpf__detach(counter->skel); > + } > + return 0; > +} > + > static int bpf_program_profiler__read(struct evsel *evsel) > { > // perf_cpu_map uses /sys/devices/system/cpu/online > @@ -280,6 +291,7 @@ static int bpf_program_profiler__install_pe(struct evsel *evsel, int cpu, > struct bpf_counter_ops bpf_program_profiler_ops = { > .load = bpf_program_profiler__load, > .enable = bpf_program_profiler__enable, > + .disable = bpf_program_profiler__disable, > .read = bpf_program_profiler__read, > .destroy = bpf_program_profiler__destroy, > .install_pe = bpf_program_profiler__install_pe, > @@ -627,6 +639,12 @@ static int bperf__enable(struct evsel *evsel) > return 0; > } > > +static int bperf__disable(struct evsel *evsel) > +{ > + evsel->follower_skel->bss->enabled = 0; > + return 0; > +} > + > static int bperf__read(struct evsel *evsel) > { > struct bperf_follower_bpf *skel = evsel->follower_skel; > @@ -768,6 +786,7 @@ static int bperf__destroy(struct evsel *evsel) > struct bpf_counter_ops bperf_ops = { > .load = bperf__load, > .enable = bperf__enable, > + .disable = bperf__disable, > .read = bperf__read, > .install_pe = bperf__install_pe, > .destroy = bperf__destroy, > @@ -806,6 +825,13 @@ int bpf_counter__enable(struct evsel *evsel) > return evsel->bpf_counter_ops->enable(evsel); > } > > +int bpf_counter__disable(struct evsel *evsel) > +{ > + if (bpf_counter_skip(evsel)) > + return 0; > + return evsel->bpf_counter_ops->disable(evsel); > +} > + > int bpf_counter__read(struct evsel *evsel) > { > if (bpf_counter_skip(evsel)) > diff --git a/tools/perf/util/bpf_counter.h b/tools/perf/util/bpf_counter.h > index cb9c532e0a079..d6d907c3dcf92 100644 > --- a/tools/perf/util/bpf_counter.h > +++ b/tools/perf/util/bpf_counter.h > @@ -18,6 +18,7 @@ typedef int (*bpf_counter_evsel_install_pe_op)(struct evsel *evsel, > struct bpf_counter_ops { > bpf_counter_evsel_target_op load; > bpf_counter_evsel_op enable; > + bpf_counter_evsel_op disable; > bpf_counter_evsel_op read; > bpf_counter_evsel_op destroy; > bpf_counter_evsel_install_pe_op install_pe; > @@ -32,6 +33,7 @@ struct bpf_counter { > > int bpf_counter__load(struct evsel *evsel, struct target *target); > int bpf_counter__enable(struct evsel *evsel); > +int bpf_counter__disable(struct evsel *evsel); > int bpf_counter__read(struct evsel *evsel); > void bpf_counter__destroy(struct evsel *evsel); > int bpf_counter__install_pe(struct evsel *evsel, int cpu, int fd); > @@ -51,6 +53,11 @@ static inline int bpf_counter__enable(struct evsel *evsel __maybe_unused) > return 0; > } > > +static inline int bpf_counter__disable(struct evsel *evsel __maybe_unused) > +{ > + return 0; > +} > + > static inline int bpf_counter__read(struct evsel *evsel __maybe_unused) > { > return -EAGAIN; > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index d29a8a118973c..e71041c890102 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -17,6 +17,7 @@ > #include "evsel.h" > #include "debug.h" > #include "units.h" > +#include "bpf_counter.h" > #include // page_size > #include "affinity.h" > #include "../perf.h" > @@ -421,6 +422,9 @@ static void __evlist__disable(struct evlist *evlist, char *evsel_name) > if (affinity__setup(&affinity) < 0) > return; > > + evlist__for_each_entry(evlist, pos) > + bpf_counter__disable(pos); > + > /* Disable 'immediate' events last */ > for (imm = 0; imm <= 1; imm++) { > evlist__for_each_cpu(evlist, i, cpu) { > -- > 2.30.2 > -- - Arnaldo