Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp306522pxy; Wed, 21 Apr 2021 03:34:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUL/EDRRMQkKH3ylLkDTX5p8IjmKcobAyLtI0p5/7I+7q4t6yvSrUUE09YCfxrB+u4qJg0 X-Received: by 2002:a17:906:f41:: with SMTP id h1mr22461007ejj.399.1619001277357; Wed, 21 Apr 2021 03:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619001277; cv=none; d=google.com; s=arc-20160816; b=erxHtz+fhDlE7Hw17rrkHIBilR7u385E+jJoeMgIy1vQ8s7z2JHxTW8aAsOc8652g9 AELVMMQSkUqfEB7NVVF5mOfjSFLOpdH1d/H99aSBvMkeSEa5zF4s8Ow6T8AcD3Tk3RT4 pjLjYnc1bEoKzaSJwqNaTK7k+3Vm4moRhMZkmji8ASldyilgbvGhX64rM9iVVUBw0r1G oYRHAOopBSGxSyyAxjKVxg19dH+gnaloeIZaASkYY9u3CDnE/9TxYvEuF65hIwj0j9ef /jFIMQJpzSW1M3D7CfpMgnOErS1ESj66dvl0WPGpUzYf8lQQPSoutFpwoO6Kp9hxBBCm 0+jQ== 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=x9vYDchYhebFU76wqYouyAVgYBvDfRNiPS9Y9xYWp/k=; b=LmQumQvr0XeQahDXrh3AjWZb6gnQdXbzqDfrspP+bfy6Q738hv2+N10jvq87PmWt9X +KW5dBvtOe9FSXDeNzzPCqEEVAwhVkpC5eXb6V9ND2M3I6VDRpEGgZcyMb84cplohzoG Nkf3ts685vKAkflSElojp66RdxcKG1vh3WEAhf03heCjXA14/c8ZozxjdFjolUyPvbkR 1HY9HoHiMocuuuwz56cJ6pCuc4HGIWrEM/PE98AKy2vTa19eQurINY76ymNsCAwdVW+P 3+L0KDBumLhVcQFp8J4mZDCb3AIxkC/e96JLj3wRfSWxXTCCtKk2gzXeXm1LeH6td/0n BTDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RR67y3BP; 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 js8si1464498ejc.236.2021.04.21.03.34.14; Wed, 21 Apr 2021 03:34:37 -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=RR67y3BP; 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 S238809AbhDUKTX (ORCPT + 99 others); Wed, 21 Apr 2021 06:19:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39377 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234947AbhDUKTL (ORCPT ); Wed, 21 Apr 2021 06:19:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619000311; 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=x9vYDchYhebFU76wqYouyAVgYBvDfRNiPS9Y9xYWp/k=; b=RR67y3BPg00isJshV2mVFu1p1Ho4FVHcDAJho3su6l3pABb/QrIskARzHJHK6Ih4cgCFT4 9qM6Y4/mKjXhZ88LlRedJ36nVmsfyBmQH520lwlZhvF0+finiV43H5SSyXne4zWT459Q1n in72XMnFxnjAFPHdAYikEI3kcr9BnJ4= 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-184-RZ1mMx62MQuCqPtaFOhj5g-1; Wed, 21 Apr 2021 06:18:27 -0400 X-MC-Unique: RZ1mMx62MQuCqPtaFOhj5g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 898D718397A7; Wed, 21 Apr 2021 10:18:26 +0000 (UTC) Received: from krava (unknown [10.40.193.60]) by smtp.corp.redhat.com (Postfix) with SMTP id BF2E919D9B; Wed, 21 Apr 2021 10:18:24 +0000 (UTC) Date: Wed, 21 Apr 2021 12:18:23 +0200 From: Jiri Olsa To: Song Liu Cc: Song Liu , "linux-kernel@vger.kernel.org" , Kernel Team , "acme@kernel.org" , "acme@redhat.com" , "namhyung@kernel.org" , "jolsa@kernel.org" Subject: Re: [PATCH v4 3/4] perf-stat: introduce config stat.bpf-counter-events Message-ID: References: <20210419203649.164121-1-song@kernel.org> <20210419203649.164121-4-song@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 20, 2021 at 09:21:32PM +0000, Song Liu wrote: > > > > On Apr 20, 2021, at 10:31 AM, Jiri Olsa wrote: > > > > On Mon, Apr 19, 2021 at 01:36:48PM -0700, Song Liu wrote: > > > > SNIP > > > >> if (stat_config.initial_delay < 0) { > >> @@ -784,11 +790,11 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) > >> if (affinity__setup(&affinity) < 0) > >> return -1; > >> > >> - if (target__has_bpf(&target)) { > >> - evlist__for_each_entry(evsel_list, counter) { > >> - if (bpf_counter__load(counter, &target)) > >> - return -1; > >> - } > >> + evlist__for_each_entry(evsel_list, counter) { > >> + if (bpf_counter__load(counter, &target)) > >> + return -1; > >> + if (!evsel__is_bpf(counter)) > >> + all_counters_use_bpf = false; > > > > could be done in bpf_counter__load, check below: > > > >> } > >> > >> evlist__for_each_cpu (evsel_list, i, cpu) { > >> diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c > >> index 5de991ab46af9..33b1888103dfa 100644 > >> --- a/tools/perf/util/bpf_counter.c > >> +++ b/tools/perf/util/bpf_counter.c > >> @@ -790,7 +790,8 @@ int bpf_counter__load(struct evsel *evsel, struct target *target) > >> { > >> if (target->bpf_str) > >> evsel->bpf_counter_ops = &bpf_program_profiler_ops; > >> - else if (target->use_bpf) > >> + else if (target->use_bpf || > >> + evsel__match_bpf_counter_events(evsel->name)) > >> evsel->bpf_counter_ops = &bperf_ops; > > > > with: > > else > > all_counters_use_bpf = false; > > > > I was also thinking of oving it to evlist, but it's sat specific, > > so I think it's good as static.. thanks for changing the implementation > > Hmm... then we need to somehow make all_counters_use_bpf visible in > bpf_counter.c, which won't be very clean. Also, since this is stat > specific, I guess it is better to keep it inside builtin-stat.c? > The runtime overhead should be minimal. ah it's different file :) then it's better as it is, sorry jirka > > Thanks, > Song >