Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1653287ioo; Sun, 22 May 2022 23:07:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4i7RYa6KAHXFYMC9VKvIz26b+MqcT076I1mEAzAVJk6CdAgclcKWhtd8tFSIqNNxH6+gj X-Received: by 2002:a17:90b:3e8d:b0:1e0:3d95:a0e1 with SMTP id rj13-20020a17090b3e8d00b001e03d95a0e1mr6340046pjb.61.1653286046061; Sun, 22 May 2022 23:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653286046; cv=none; d=google.com; s=arc-20160816; b=njJlJhvZZuiF2QGaB2ecg3jpDCkEMUMUAyKkV6GKTa9OiTZAv0GImdB/Q3BlpLWwtl 3lX3HOanqC6pPw7Dh6yKyFqhWCCYjiNwhfSxUxRgxxB3gyh+FnD06lFgz14h3FqSk172 U39e5UcQiL68LerPWYLdAuC7BfyVYISNoA3/98R2l7azl2FycYoB5mEXof4A9m3dDNkr NbRPsWQnflD44mXNXMiHPCp45P8n4K2CTiX4OXeW9cG2YYx+IIs7JQRyXf0tY3EBIDv1 xi9Pn5uKaDBMLALcYTAvlgQtWwic7xIfQq0ITqld57ps6RPum1K6cohNAv0wcsi4Z6XZ Ax7A== 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:sender:dkim-signature; bh=u22Vdb8ad4QsGUpvqDD4jw8opLANlipXffF4J28OkDw=; b=VC4kg9BtA02NGdubyreYe/4ccbF6DomW3+JFmuij+mElzMGog0U33+finUjlaCaKYp XmYLbIV/2iu/Ay5gTasjfZwO45WLrpqSrC0m1whykXMzTZRv4xy37hMZKcI9PcTkAwdu rlosrtgrUvuermG4TRckRv04H50TDxOqbrC+mKPUQGAsm6vEyTvb3kPAP9Kg5yy/3q1l cTFW+fyjJWgLrl9qJQHdgjLeDo+lwxxJWWxns90BAc+g1bQkxZYxG/cdd+SDT7zXdtM8 FQ/riKxGaR6rsJ+ST0Ciq/gsGgM3ODkZjmASW06NOV/5lc19FnNHvzKUa1NzP7ba4JpV VpTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=alC71XCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h128-20020a625386000000b004fa3a8e004csi11698683pfb.259.2022.05.22.23.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=alC71XCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 077F02F021; Sun, 22 May 2022 22:58:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351787AbiETQpQ (ORCPT + 99 others); Fri, 20 May 2022 12:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiETQpN (ORCPT ); Fri, 20 May 2022 12:45:13 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D5D178567; Fri, 20 May 2022 09:45:12 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d22so7803215plr.9; Fri, 20 May 2022 09:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=u22Vdb8ad4QsGUpvqDD4jw8opLANlipXffF4J28OkDw=; b=alC71XCAjWLZ2L+MKQYDKx3KTDbWUY+ds3nxi6wLqgO7s9wjvHmeS0X4mp5EnSoUUl 5azRlTmtfw/UqAiUwhI5sZANOPrUEC/QVcgidBJjdj4vzvuMoqNBW3nF9tMw2moyZlgN 8wyQDt0+i8Ada0za5PsJuWKfV+qMDHHHk2GretQeRaKoVLkVf0wFl6lveJrSxek6tugV CGXMeMWuv7bzSJ5ekUqL6IxWkCb1TWH3HxYnZOseiU6svnyorwth8UX8rb5PIV8m9KMA KOP4TMl/Nnd2YqrNvrxDocxEl3yX1fsJgCEhZhQWU9/MAB/jhNnUTNVoxy08eGE2Tu0V r/5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=u22Vdb8ad4QsGUpvqDD4jw8opLANlipXffF4J28OkDw=; b=IOtTvcJiQ8WXVNaJploMVtDsmP/0ioJ8LIo6qbOKA8PBVzkaqhbGsSnzlqr3PPAmx1 HTZdskCfxZ6kobIxp/pLmmnUAQLTocSwwSVTPRT+mUnskJLEQSZW/5/F2AILMVbVo+Bn abQ4kEBLSnYUf8IeeQEorU6IyQ427T1twq7712qCViQXHEb280Epndgd77zPb/QPavRa PG8Z2+8cD0nG59V3KA6mRVXUsEUtIW162uujDcNf8rx4rwDKRqtgl2+o5RqJwjPGvOng DMNEAft2AsCC4I3D+eRE7UuxFGp4FmBPLJvRMZIgmiQ9j9naXZPe3PfQQ7b2fxlAYO7R mdBQ== X-Gm-Message-State: AOAM533unz4xbJLttFEap9bNm7IAS1QM4dwHhSsG7XxbrVHYAv7LqyLv ZeL2It1tQCf5NmXZwXJCsLg= X-Received: by 2002:a17:90a:cc02:b0:1df:257a:5396 with SMTP id b2-20020a17090acc0200b001df257a5396mr12031837pju.190.1653065111792; Fri, 20 May 2022 09:45:11 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::4:1761]) by smtp.gmail.com with ESMTPSA id j7-20020a170902690700b001616b71e5e6sm5917456plk.175.2022.05.20.09.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 09:45:11 -0700 (PDT) Sender: Tejun Heo Date: Fri, 20 May 2022 06:45:10 -1000 From: Tejun Heo To: Yonghong Song Cc: Yosry Ahmed , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Hao Luo , Zefan Li , Johannes Weiner , Shuah Khan , Roman Gushchin , Michal Hocko , Stanislav Fomichev , David Rientjes , Greg Thelen , Shakeel Butt , Linux Kernel Mailing List , Networking , bpf , Cgroups Subject: Re: [PATCH bpf-next v1 3/5] bpf: Introduce cgroup iter Message-ID: References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-4-yosryahmed@google.com> <73fd9853-5dab-8b59-24a0-74c0a6cae88e@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73fd9853-5dab-8b59-24a0-74c0a6cae88e@fb.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Yonghong. On Fri, May 20, 2022 at 09:29:43AM -0700, Yonghong Song wrote: > Maybe you can have a bpf program signature like below: > > int BPF_PROG(dump_vmscan, struct bpf_iter_meta *meta, struct cgroup *cgrp, > struct cgroup *parent_cgrp) > > parent_cgrp is NULL when cgrp is the root cgroup. > > I would like the bpf program should send the following information to > user space: > I don't think parent cgroup dir name would be sufficient to reconstruct the path given that multiple cgroups in different subtrees can have the same name. For live cgroups, userspace can find the path from id (or ino) without traversing anything by constructing the fhandle, open it open_by_handle_at() and then reading /proc/self/fd/$FD symlink - https://lkml.org/lkml/2020/12/2/1126. This isn't available for dead cgroups but I'm not sure how much that'd matter given that they aren't visible from userspace anyway. > > > This way, user space can easily construct the cgroup hierarchy stat like > cpu mem cpu pressure mem pressure ... > cgroup1 ... > child1 ... > grandchild1 ... > child2 ... > cgroup 2 ... > child 3 ... > ... ... > > the bpf iterator can have additional parameter like > cgroup_id = ... to only call bpf program once with that > cgroup_id if specified. > > The kernel part of cgroup_iter can call cgroup_rstat_flush() > before calling cgroup_iter bpf program. > > WDYT? Would it work to just pass in @cgrp and provide a group of helpers so that the program can do whatever it wanna do including looking up the full path and passing that to userspace? Thanks. -- tejun