Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp207714pxb; Fri, 15 Jan 2021 10:54:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyztZB+VBJ8q7BfBt/rKqw2ip9wqeXor0Nupx9vh9ghufzCxSTpQg4I7Z/FajDbxAmtyk1f X-Received: by 2002:a17:907:3fa6:: with SMTP id hr38mr9983407ejc.24.1610736891738; Fri, 15 Jan 2021 10:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610736891; cv=none; d=google.com; s=arc-20160816; b=J1TToNlvfiiET8iVG9CoDvM9/Vhnrz/IP9C5BdTIKmLhH5rAcz3rvQP5u71xPCd3wR mPupL8I88BsWEDFwrQwhNhJwOu2sLhDdIQcsnzALi5PUFsonV6ilja0DUylmajDkP3pu qVer8Godgx3WvqJLasUWaI5G5TTqNOJKj8SpRO5ii3xd0SPQQamQHWU9bwC+/CK8n2fx wIKsGOaIoojING/tkPBCCU9kw9Tzd14+daU9D2sIoSOxNO6sp/3sAsrTGRq817O90QNt xc2hxyuIYBbJfpZAFJDufqMYA24y+HLbobVpxoo8fdnKtI0nXpWyNGGrnYddy5dDv2cw vJvA== 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=4LhSFe6FTkzhhmUSuShNy5IX0ya+3i7Dy33KykLNdlY=; b=kBmzgkenKDa89eukiVyWzSx7WNOFlsTEaKXqzEa+eRbzqkH6kDeWYcGQUovoMdTSO4 ZB3iYyH+v9+QJCLSgdjvr9mzixL+SnkX8aGIvaRoYigtKkyo0CM+K4/GuOKcCgL7CXxK NUxyGZElt4JCshK22EhNnrybAa5NCfHFk0qXFeWOR5LME8VTaML42mE6W57HGKAqvux7 tmsPqeWffzY40WJ4h96e/9CF6QDHhLKVrn41m+v52Gp9zxf42+hCX6eiWSi+kuqmxWj3 mIvRRq9ynHKdZwksa73YO++GA7wykeG5TD40NlRUWUAoQEhS09G01nH1PbsFBdjHdp2H JDcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OQQy0mlw; 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 a72si2238260edf.380.2021.01.15.10.54.27; Fri, 15 Jan 2021 10:54:51 -0800 (PST) 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=OQQy0mlw; 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 S2387533AbhAOSxU (ORCPT + 99 others); Fri, 15 Jan 2021 13:53:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:52906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732973AbhAOSxT (ORCPT ); Fri, 15 Jan 2021 13:53:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 463E22336F; Fri, 15 Jan 2021 18:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610736759; bh=bNmv8opxj2w/GfQ5B9uYIonThSq0yWk3kvyk1ZXkNco=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OQQy0mlwz+oaHkciQTio675hNV5pGBIfm6re8J0ESlzhcbAmg4GMw8wCrV+fsEfPW 8+srQf9pyVjqrJuerimMWLwRt5dA/igrtifyb3cBs7w1WrAsi75tWGDnXENRUuBXsx 73/AfyAnWmNfwAjGYag8HiZfHnw0TapDpM2P45MD9kTLVK0lEOihdhMhm4Z6UBWtOX n6xDIdx+WiZOOZrrgACI4HwkTcM4Vpu4mZzB0d14IxZeOOz11W/lGvbt0NOubhpcl8 JI2v4+zy+viF2KEW9SQx/R4C0hqi4fsmtX3fE2kThgplChsZLAwKdc2HJHeBIU6l50 6mk/kpmJ+UBTw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 6388E40522; Fri, 15 Jan 2021 15:53:11 -0300 (-03) Date: Fri, 15 Jan 2021 15:53:11 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Song Liu , linux-kernel , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Mark Rutland , Jiri Olsa , kernel-team@fb.com Subject: Re: [PATCH v7 3/3] perf-stat: enable counting events for BPF programs Message-ID: <20210115185311.GB457607@kernel.org> References: <20201229214214.3413833-1-songliubraving@fb.com> <20201229214214.3413833-4-songliubraving@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Jan 12, 2021 at 04:35:14PM +0900, Namhyung Kim escreveu: > Hi, > > On Wed, Dec 30, 2020 at 6:42 AM Song Liu wrote: > > > > Introduce perf-stat -b option, which counts events for BPF programs, like: > > > > [root@localhost ~]# ~/perf stat -e ref-cycles,cycles -b 254 -I 1000 > > 1.487903822 115,200 ref-cycles > > 1.487903822 86,012 cycles > > 2.489147029 80,560 ref-cycles > > 2.489147029 73,784 cycles > > 3.490341825 60,720 ref-cycles > > 3.490341825 37,797 cycles > > 4.491540887 37,120 ref-cycles > > 4.491540887 31,963 cycles > > > > The example above counts cycles and ref-cycles of BPF program of id 254. > > This is similar to bpftool-prog-profile command, but more flexible. > > > > perf-stat -b creates per-cpu perf_event and loads fentry/fexit BPF > > programs (monitor-progs) to the target BPF program (target-prog). The > > monitor-progs read perf_event before and after the target-prog, and > > aggregate the difference in a BPF map. Then the user space reads data > > from these maps. > > > > A new struct bpf_counter is introduced to provide common interface that > > uses BPF programs/maps to count perf events. > > Acked-by: Namhyung Kim Applied locally, testing now. - Arnaldo