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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3327C433EF for ; Wed, 16 Mar 2022 16:35:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 702C78D0002; Wed, 16 Mar 2022 12:35:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B1336B0073; Wed, 16 Mar 2022 12:35:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 579CA8D0002; Wed, 16 Mar 2022 12:35:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 47C376B0071 for ; Wed, 16 Mar 2022 12:35:43 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 18230F7E for ; Wed, 16 Mar 2022 16:35:43 +0000 (UTC) X-FDA: 79250800566.07.8A1090C Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf07.hostedemail.com (Postfix) with ESMTP id 7EA614002D for ; Wed, 16 Mar 2022 16:35:42 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id h2so4455000pfh.6 for ; Wed, 16 Mar 2022 09:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=275NXYJb5aDtfGLgJwV8jy6NeIY7jYYNXA4F+p+7cbI=; b=ca3YzU4ecHyoF5z9aV8JSuIo/aHcR1av61umXYi8JxoeJeLfrsg6bHwTJ+7QfqMAY2 W5AJIv4jxXQqUafuQZkfyhG7dP7qQFMBfcbxYK74ZjEXybe+6DGMthl8sYjC6VHmBtKT MgGAvgJYWvrZvnpwYny8tHp5qwO1Wwa0sh9mJT0E6i5rD4MskKotZI7ypsp4Co/l2tVm PnXhHqsdCtll4ouLcB65KDtuFEfQHm4tvaRbUiniF8ugw9gwtPknP2TGah+iUDshxBkc uQ1LypK8NDdZHngCEYebr8//kv5aJfMWaTrpDvEKnEJy4RRIzqMPGcpT2Y/SZd0ZsZ03 SUsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=275NXYJb5aDtfGLgJwV8jy6NeIY7jYYNXA4F+p+7cbI=; b=pJWA0jzv3Y0oHH83lR5AdMWnMP6QfREJ0yE1YgKkCQWks84C6VCrYe6i4xEmatTftv f6ixQfmY6dqFgIjI/KGW4HBQfnFlrPzBAx2s6fNlRyrxDamKDjheA6HFx4DLqisQfjoV b1IBHgaMPWxmg1YAOOGQh9Um1Za3/c0+BK/Vgm4AGg6jw/6PeLrk7NAWo5HF+2bmiT0n DeQ55t8ToLGvhCXPqlZPqV7drqlSbzs7v4Vc29/E/ntIeX/wCXHs49UYm/1KC+2W1itf dJBS8RBk/wtC8odunxBPSuyqVIQKbgM/KVlnDw94SK2cMmXbO8sqBiiLsJo+3IF1Wgt5 Cggg== X-Gm-Message-State: AOAM5337PewgD0IkFUlE24uxiPTwbnQoOMJTL5cLNLejdgw7ceT/we0W BV3zGzKT8cFAjupPq9Y6H/d2llHx5oPhA1RVoeeClg== X-Google-Smtp-Source: ABdhPJy0dfdrNHDXfzLhLoV648rli3spqHAE3tjA1YC2TLkbHATBCWj+SMR8ittEPqKuL6E9L0btG1d4/XdhA5vNQAc= X-Received: by 2002:a65:6091:0:b0:35e:d274:5f54 with SMTP id t17-20020a656091000000b0035ed2745f54mr383547pgu.200.1647448541147; Wed, 16 Mar 2022 09:35:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yosry Ahmed Date: Wed, 16 Mar 2022 09:35:05 -0700 Message-ID: Subject: Re: [RFC bpf-next] Hierarchical Cgroup Stats Collection Using BPF To: Tejun Heo Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Johannes Weiner , Hao Luo , Shakeel Butt , Stanislav Fomichev , David Rientjes , bpf , KP Singh , cgroups@vger.kernel.org, Linux-MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7EA614002D X-Stat-Signature: ioryuuruidkpwr6634axbtpgwony1is4 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ca3YzU4e; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of yosryahmed@google.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=yosryahmed@google.com X-Rspam-User: X-HE-Tag: 1647448542-274079 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Tejun, Thanks for taking the time to read my proposal! Sorry for the late reply. This email skipped my inbox for some reason. On Sun, Mar 13, 2022 at 10:35 PM Tejun Heo wrote: > > Hello, > > On Wed, Mar 09, 2022 at 12:27:15PM -0800, Yosry Ahmed wrote: > ... > > These problems are already addressed by the rstat aggregation > > mechanism in the kernel, which is primarily used for memcg stats. We > > Not that it matters all that much but I don't think the above statement is > true given that sched stats are an integrated part of the rstat > implementation and io was converted before memcg. > Excuse my ignorance, I am new to kernel development. I only saw calls to cgroup_rstat_updated() in memcg and io and assumed they were the only users. Now I found cpu_account_cputime() :) > > - For every cgroup, we will either use flags to distinguish BPF stats > > updates from normal stats updates, or flush both anyway (memcg stats > > are periodically flushed anyway). > > I'd just keep them together. Usually most activities tend to happen > together, so it's cheaper to aggregate all of them in one go in most cases. This makes sense to me, thanks. > > > - Provide flags to enable/disable using per-cpu arrays (for stats that > > are not updated frequently), and enable/disable hierarchical > > aggregation (for non-hierarchical stats, they can still make benefit > > of the automatic entries creation & deletion). > > - Provide different hierarchical aggregation operations : SUM, MAX, MIN, etc. > > - Instead of an array as the map value, use a struct, and let the user > > provide an aggregator function in the form of a BPF program. > > I'm more partial to the last option. It does make the usage a bit more > compilcated but hopefully it shouldn't be too bad with good examples. > > I don't have strong opinions on the bpf side of things but it'd be great to > be able to use rstat from bpf. It indeed gives more flexibility but is more complicated. Also, I am not sure about the overhead to make calls to BPF programs in every aggregation step. Looking forward to get feedback on the bpf side of things. > > Thanks. > > -- > tejun