Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2703794pxb; Mon, 19 Apr 2021 11:41:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrHJZHcfapB/Owj8jukQVSbhER808yu/SmLxykgIr9qgxA5Ecq7MTD8Uzubxj+N4mpjHhj X-Received: by 2002:a17:906:4756:: with SMTP id j22mr22858370ejs.506.1618857714212; Mon, 19 Apr 2021 11:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618857714; cv=none; d=google.com; s=arc-20160816; b=ZXkwlUOosQLHYmuafRQ47cR/LIu9Uu17cWsE5NhApja/msDoIFGZ9UOWo4nfCLOD35 woerq+JNeAgVRArRp1VG7vdviKxK7YNnLzcLcKxNwK9bwgTKhqcqUSLj9UgCrJkkoPC8 VS82wvlui9m59cbge2V6SRAhbhfy+EJQRl9NJLci7/Y0XMI+Kt4GoXcK0Ag6DnJCzvyH ZhPOnlAcGP7kItW1Ty37QIoUAoguthNLSZ/Lbo2H7VkbOWlNQoo3Q3vGNloJHDrVOzrr OKWkdcJTrFqp1wZ0W2pqRB44JzZR9YwX/Obfqp3eXokGd6ELidLVlc02agYpnpWI7rH6 22Jg== 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=HxAG4kbNBg9X46ZjvrZeyxdy/hfYbf4rBJQlMhrU+Ow=; b=rKYsnPggz2WjwKnlo/4Nhy9UUoIqIzLDTOxM/7M6cP4s8yOMiXmHv6sYLx/PzNT2qf oVtrFHi7D6M7bcdgMqoY7t8Wx/yKtc3OmOpv92RN8fWvVGPRIdw0B7caDiFXunZrV9f7 ku3lj6oVpFAVSr/xsulhLMyXOeSGbkBwxbUQ//w07Rr781ph1g0JZSVbPo1Qgua8Jh8Y MOjqwS6RNHMiHd3zdga5v7prYrceuGyG2+rUAWJ+n1+XjNS7bLOV+aufpdeWadTdR0Eg ns6RwNxm9/fGq6FwtjzgwHF98ntPnymf1v9tNl5WKHNM/Vr7DxlPRcia9U7bnzXlEylL Q0iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SGnM2MCj; 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 j22si12939183eds.145.2021.04.19.11.41.31; Mon, 19 Apr 2021 11:41:54 -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=SGnM2MCj; 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 S239720AbhDSO1N (ORCPT + 99 others); Mon, 19 Apr 2021 10:27:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53387 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239296AbhDSO1M (ORCPT ); Mon, 19 Apr 2021 10:27:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618842402; 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=HxAG4kbNBg9X46ZjvrZeyxdy/hfYbf4rBJQlMhrU+Ow=; b=SGnM2MCjKjGY/zbxDVgwLFFGNDpAIjYgpGxWtlvYhb4fushvU4M1D99QxiuAQLBbN1Pvzq ljxrFyztltgcQu4QSwn05KUTNprxIjDlZ8ecfiuvvNTcvmfzxcbkeuBIN8gpa3E9+AiaV0 D/YK7G/M1WBozKaBM7lPHoG10TgnDzU= 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-561-tZCMx9clOY2_lcqiovsQLw-1; Mon, 19 Apr 2021 10:26:41 -0400 X-MC-Unique: tZCMx9clOY2_lcqiovsQLw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86E3587A826; Mon, 19 Apr 2021 14:26:39 +0000 (UTC) Received: from krava (unknown [10.40.195.124]) by smtp.corp.redhat.com (Postfix) with SMTP id D723A5D742; Mon, 19 Apr 2021 14:26:37 +0000 (UTC) Date: Mon, 19 Apr 2021 16:26:36 +0200 From: Jiri Olsa To: Song Liu Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, acme@kernel.org, acme@redhat.com, namhyung@kernel.org, jolsa@kernel.org, songliubraving@fb.com Subject: Re: [PATCH v3 3/4] perf-stat: introduce config stat.bpf-counter-events Message-ID: References: <20210416221325.2373497-1-song@kernel.org> <20210416221325.2373497-4-song@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210416221325.2373497-4-song@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 16, 2021 at 03:13:24PM -0700, Song Liu wrote: SNIP > +/* > + * Returns: > + * 0 if all events use BPF; > + * 1 if some events do NOT use BPF; > + * < 0 on errors; > + */ > static int read_bpf_map_counters(void) > { > + bool has_none_bpf_events = false; > struct evsel *counter; > int err; > > evlist__for_each_entry(evsel_list, counter) { > + if (!evsel__is_bpf(counter)) { > + has_none_bpf_events = true; > + continue; > + } > err = bpf_counter__read(counter); > if (err) > return err; > } > - return 0; > + return has_none_bpf_events ? 1 : 0; > } > > static void read_counters(struct timespec *rs) > @@ -442,9 +455,10 @@ static void read_counters(struct timespec *rs) > int err; > > if (!stat_config.stop_read_counter) { > - if (target__has_bpf(&target)) > - err = read_bpf_map_counters(); > - else > + err = read_bpf_map_counters(); > + if (err < 0) > + return; > + if (err) > err = read_affinity_counters(rs); this part is confusing for me.. I understand we don't want to enter read_affinity_counters when there's no bpf counter, so we don't set affinities in vain.. but there must be better way ;-) > diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c > index 5de991ab46af9..3189b63714371 100644 > --- a/tools/perf/util/bpf_counter.c > +++ b/tools/perf/util/bpf_counter.c > @@ -792,6 +792,8 @@ int bpf_counter__load(struct evsel *evsel, struct target *target) > evsel->bpf_counter_ops = &bpf_program_profiler_ops; > else if (target->use_bpf) > evsel->bpf_counter_ops = &bperf_ops; > + else if (evsel__match_bpf_counter_events(evsel->name)) > + evsel->bpf_counter_ops = &bperf_ops; please put this with the target->use_bpf check, it seems like it's another thing thanks, jirka