From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6560AC11F65 for ; Wed, 30 Jun 2021 06:20:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 472A861D08 for ; Wed, 30 Jun 2021 06:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232343AbhF3GWl (ORCPT ); Wed, 30 Jun 2021 02:22:41 -0400 Received: from mail-lj1-f169.google.com ([209.85.208.169]:39683 "EHLO mail-lj1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbhF3GWj (ORCPT ); Wed, 30 Jun 2021 02:22:39 -0400 Received: by mail-lj1-f169.google.com with SMTP id c11so1675635ljd.6 for ; Tue, 29 Jun 2021 23:20:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Fi84/fcfdof1rBJUwt6I4qit4XezHxGkLHK4x+X55A0=; b=jFuNg6orlKQJyPLfgqQvpkC4w9UK9hJv4Gb1hXUYXzkZpHViLqkEOWWRek1or1tbrO Di/mlkf8zMUwf6zEzKg48YvzHLNoCNxRX0vFJLG2Kwk6uikOIEh3EI9oHepkZpgWiISH hXeFGapN7g7tSY34MdU6FJw2n85Zhgc7W3d2q1JFJtakQ0IT8sDhtDJillS69qOyJ8Mt WsueQhSSNW2YlrUvnuw7HnD1hAcmH1ZFMd+KXsgDKhxAJmCwA6moKAe6GtXB01j5sLgb uHaYa8l61u0ZLSZ1ZdG2NjO3ml6qcdMjHsdre+Z6Ubt1OJnTw14hobD20a5d3QvIWAdd YmGg== X-Gm-Message-State: AOAM531mYy+zGVZfyXfhKcqnJP1Bce5cM7id3gFqNE6EEYrChkJwapCa gHdCDNE7+g+ckJRYSuy0pPZAq318pwQi7p3Vj34= X-Google-Smtp-Source: ABdhPJwtshQlkTpu133O2Eazog1AoiarWWI9uQt4mgYxEI7iFpRcT3mckJ6nW9u7oaU3dJ1XOnrqpgjorM2492/Ui9Y= X-Received: by 2002:a2e:5c42:: with SMTP id q63mr6508934ljb.23.1625034010564; Tue, 29 Jun 2021 23:20:10 -0700 (PDT) MIME-Version: 1.0 References: <20210625071826.608504-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Tue, 29 Jun 2021 23:19:59 -0700 Message-ID: Subject: Re: [PATCHSET v4 0/4] perf stat: Enable BPF counters with --for-each-cgroup To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Andi Kleen , Ian Rogers , Stephane Eranian , Song Liu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 27, 2021 at 8:29 AM Namhyung Kim wrote: > > On Fri, Jun 25, 2021 at 12:18 AM Namhyung Kim wrote: > > > > Hello, > > > > This is to add BPF support for --for-each-cgroup to handle many cgroup > > events on big machines. You can use the --bpf-counters to enable the > > new behavior. > > > > * changes in v4 > > - convert cgrp_readings to a per-cpu array map > > - remove now-unused cpu_idx map > > - move common functions to a header file > > - reuse bpftool bootstrap binary > > - fix build error in the cgroup code > > > > * changes in v3 > > - support cgroup hierarchy with ancestor ids > > - add and trigger raw_tp BPF program > > - add a build rule for vmlinux.h > > > > * changes in v2 > > - remove incorrect use of BPF_F_PRESERVE_ELEMS > > - add missing map elements after lookup > > - handle cgroup v1 > > > > Basic idea is to use a single set of per-cpu events to count > > interested events and aggregate them to each cgroup. I used bperf > > mechanism to use a BPF program for cgroup-switches and save the > > results in a matching map element for given cgroups. > > > > Without this, we need to have separate events for cgroups, and it > > creates unnecessary multiplexing overhead (and PMU programming) when > > tasks in different cgroups are switched. I saw this makes a big > > difference on 256 cpu machines with hundreds of cgroups. > > > > Actually this is what I wanted to do it in the kernel [1], but we can > > do the job using BPF! > > Ugh, I found the current kernel bpf verifier doesn't accept the > bpf_get_current_ancestor_cgroup_id() helper. Will send the fix > to BPF folks. The fix landed on the bpf-next tree. Thanks, Namhyung