Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3283656lfo; Mon, 23 May 2022 00:40:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzcQD5/A5ceAfGytTm0NAoOdq/zZpqruntAeXPigHr+TZMNvatv9UOCr2xNSCsAVvCSmmw X-Received: by 2002:a05:6a00:1709:b0:505:fa47:b611 with SMTP id h9-20020a056a00170900b00505fa47b611mr22448648pfc.65.1653291604645; Mon, 23 May 2022 00:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653291604; cv=none; d=google.com; s=arc-20160816; b=KIwhnYQVPM+zIIZUZIUag+7KhXFnGCcxQJ1BAU34kHvueYncKfXbgRfiql9eGGfVJA HvNfUvpPfcYPWjzw/gd5fgb2ebQun7GQUsynjMMD7EQBuB7bpI5DgFwFw85CDilhn/Ir b/B8W18955lWphiAetgBbS7YgOzuSpxPw+jhyL1a2Y6uacEma8FEGnz2dyJNRhoeIJah wK9FZBoRwH53+4P+pV6JzDXsv/07whbVy4rhscSuYgtjncq/IpVOK21r3t/8erM8vUjV ZWyUgZKvwhfzPNHFveX1Y9/GYT7He4SitpqSTnyekg+WnPUJsFWfqmMYB6sYUpt4etnA NhgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Ndrz/Orvp7gcBGGOOLwcGhWh997j9sWnxKmSb6IuujM=; b=vL6RevDE30wtBZXxch6G4RNGj5KtY6E+B5wkmtuJxKF5miJIZVBQzpknsoCb02nSC3 rfBFB95ZpixuHTQB4YQNA+TvmrE5/2wCLpduxVQpDDgnrR77720ooOd4GPW1u5nwgZR8 ukVrdimo3dAxlf+ZwkFhsNDNs00A3e89a+T7vgpSTjQe4M6QT5my0MR8LTL406jTKWCZ SBTUvR/vTabSQlw+uECi1L9sLrcitpxO67xOufbsIJoBtHixnbwieWdtFC9S7dlHghtr +ayxS7OoBcHutwOeNMllxzxOx+FTgKtTnSZHse6qYuCfLV3iVvA/KYSztzfULYm1TkoO XnKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BDgF8vyy; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d3-20020a636803000000b00398ff843754si9435885pgc.461.2022.05.23.00.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:40:04 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BDgF8vyy; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2E6C1C765C; Sun, 22 May 2022 23:46:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231826AbiEUCn1 (ORCPT + 99 others); Fri, 20 May 2022 22:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239386AbiEUCn0 (ORCPT ); Fri, 20 May 2022 22:43:26 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 735D71737C6 for ; Fri, 20 May 2022 19:43:24 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id 11so6866062qtp.9 for ; Fri, 20 May 2022 19:43:24 -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=Ndrz/Orvp7gcBGGOOLwcGhWh997j9sWnxKmSb6IuujM=; b=BDgF8vyyA+xZnKQeleXK8QqAnjkCiXSY0NYaUoybbPy5lZReZm4LJLJRAB4oDF1E0J Ppe2rcbKXC2oj8Qi4MWBmYtHr1ikoaxG+mKJjuPFQ/rngPWYy4Q/NtPmoINXtIUrgBHp WdXsJgie3zycP4uG1rKtTn/E01eKwZ7sCXWGgkNqIGT/ZYIdB07JqIc7XPl4VfxGyS62 c/k4oZqOXhjMkzb4cYRFlbPiBfv+JIrAm3Z3As4kkIabRD+ZXVZaF0qz7Xj0Qvgjhzyn wuMxjbep3l3CRiPhTcXqgQ2rz36IvwoT9pvEuYEXuX5XJeeKGbLCQCwuaUnrre94oQD1 hz5w== 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=Ndrz/Orvp7gcBGGOOLwcGhWh997j9sWnxKmSb6IuujM=; b=gm49uaHm4GMOMSCijvgZ7ck1bz0q1krdwV9ffXo3F5c5SewlmzseiMTAHSz+5Kp3Eg Fi4KcdHD3cpQy+Ho6I9BYrphR52qdbA00+5EbMdf7W7ysYip9ZpohkZZFQB8BaLRSXy9 EClTBkHznZpT13yldEkW4k5SJyLYlw/vUNTlwGVQD8tp8UhS8cjlCP8i4QT69i5uWnPo aSw77PiU9P1QwAjMelVQ97ll2JTegSz+SpISsYsAVbKgXDi13y8STtDopQjaiVwIIDsY 2bkEP1WULVdBzRLmX62WDMhgZsDiUoRGOx/usBMRHVRU1GVuAmCklaTzzwQL4r3gxkWi sRIA== X-Gm-Message-State: AOAM532FAZPHX2lRUXzxkFEVDhZuLVsELvw/Mo6Z6NXGwa7nTK6KwPL6 zaA/nk875VHoCvyiDH+Xkoib6eOEeSYfepbq7o6StA== X-Received: by 2002:a05:622a:54e:b0:2f3:c9db:c512 with SMTP id m14-20020a05622a054e00b002f3c9dbc512mr9752878qtx.478.1653101003376; Fri, 20 May 2022 19:43:23 -0700 (PDT) MIME-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-4-yosryahmed@google.com> <73fd9853-5dab-8b59-24a0-74c0a6cae88e@fb.com> <4cbdd3e9-c6fe-d796-5560-cd09c9220868@fb.com> In-Reply-To: <4cbdd3e9-c6fe-d796-5560-cd09c9220868@fb.com> From: Hao Luo Date: Fri, 20 May 2022 19:43:12 -0700 Message-ID: Subject: Re: [PATCH bpf-next v1 3/5] bpf: Introduce cgroup iter To: Yonghong Song Cc: Tejun Heo , Yosry Ahmed , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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 On Fri, May 20, 2022 at 5:58 PM Yonghong Song wrote: > On 5/20/22 2:49 PM, Hao Luo wrote: > > Hi Tejun and Yonghong, > > > > On Fri, May 20, 2022 at 12:42 PM Hao Luo wrote: > >> > >> Hi Tejun and Yonghong, > >> > >> On Fri, May 20, 2022 at 9:45 AM Tejun Heo wrote: > >>> On Fri, May 20, 2022 at 09:29:43AM -0700, Yonghong Song wrote: > >>>> > >>>> > >>>> 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. > >> > >> Yep, this should work. We just need to make the cgroup_id parameter > >> optional. If it is specified when creating bpf_iter_link, we print for > >> that cgroup only. If it is not specified, we iterate over all cgroups. > >> If I understand correctly, sounds doable. > >> > > > > Yonghong, I realized that seek() which Tejun has been calling out, can > > be used to specify the target cgroup, rather than adding a new > > parameter. Maybe, we can pass cgroup_id to seek() on cgroup bpf_iter, > > which will instruct read() to return the corresponding cgroup's stats. > > On the other hand, reading without calling seek() beforehand will > > return all the cgroups. > > Currently, seek is not supported for bpf_iter. > > const struct file_operations bpf_iter_fops = { > .open = iter_open, > .llseek = no_llseek, > .read = bpf_seq_read, > .release = iter_release, > }; > > But if seek() works, I don't mind to remove this restriction. > But not sure what to seek. Do you mean to provide a cgroup_fd/cgroup_id > as the seek() syscall parameter? This may work. Yes, passing a cgroup_id as the seek() syscall parameter was what I meant. Tejun previously requested us to support seek() for a proper iterator. Since Alexei has a nice solution that all of us have ack'ed, I am not sure whether we still want to add seek() for bpf_iter as Tejun asked. I guess not. > > But considering we have parameterized example (map_fd) and > in the future, we may have other parameterized bpf_iter > (e.g., for one task). Maybe parameter-based approach is better. > Acknowledged. > > > > WDYT?