Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5992006rwp; Mon, 17 Jul 2023 12:56:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlEV5X9u21EFDDqJ3BInv/ybob4UGf6f8TBH+KHeD3PF3TYRItW/8n+DiEA7+iX65Pl2pDxS X-Received: by 2002:a05:6830:14d0:b0:6b7:4efe:a9a4 with SMTP id t16-20020a05683014d000b006b74efea9a4mr13114980otq.23.1689623808915; Mon, 17 Jul 2023 12:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689623808; cv=none; d=google.com; s=arc-20160816; b=cRGuqpSJCz6fylr95D8TSWPOzif6uUPkQbl8uVmAsYVXJ+8YcwrrGZpPzdAb4sWm8c ELf2zRbqjU0eoRbqfd35YvR1sceYNZHnN9wCbjCaV8Mrt7wVC/xKQcH/rAenYNkraCdD VK3qD/SHKBsWsEIvNXrPKsYwg5MZU8P27iKkimYWohkMh8c0KLXVjt/FMqkfoWM+teoE R3+b1FqCR9mpn5RuzBMZwpDYeEwXuqMIXQewmIJCi32e+DJMK5VUfsNBULnMPHni6zyY uAwn7vsMcn+8KwkVT/VJEcwk4ku6aaiqspOGWIbY2IctAwWQ5B1GXY+H8ty8LQFLwZ16 VWFQ== 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=xWoO0TUyoZ+Qmv9rHsFJp85hT+0xnOPhDe/kh1QoW+4=; fh=cpVGWf4RprNftWMU1V+toTwQfpUro6h05Qw1llkB12E=; b=GOfsyBKsksL2ofeKrM9ubbznjwHwZcd/b++e5ilNr8r6roUiroWLmeWb58W6m2nGR2 /9HUlUSbIt+yDaEjYniXL2ARH69DUasA8bkBeW1WwYnPvhmnJXqlpP9cU5UrVrMNPj6k ugh5lK9iWv3jNyn62auuTmyzK4Tz2AvvX09y/KyiNVEzZ/Vbyt1UnnPG4rSQ/N+P2mfo sHQEeusJ2JM7EQ4OgPi6bCU3mu4Tazk8g1hohIagQkR2BW49+9AcBU1HoE8fGlLmnB44 4O5RcBbYWz7rRSC2faNl0XODv2MteM+TFaoBy3ilZwFr99M3g4SuzwXn4O1wvebzXWbp mLTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="b/OD9dQB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k68-20020a633d47000000b0056334952edfsi269368pga.883.2023.07.17.12.56.36; Mon, 17 Jul 2023 12:56:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="b/OD9dQB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229780AbjGQTw2 (ORCPT + 99 others); Mon, 17 Jul 2023 15:52:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjGQTw1 (ORCPT ); Mon, 17 Jul 2023 15:52:27 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3ABF126; Mon, 17 Jul 2023 12:52:26 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-78654448524so183423139f.2; Mon, 17 Jul 2023 12:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689623546; x=1692215546; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=xWoO0TUyoZ+Qmv9rHsFJp85hT+0xnOPhDe/kh1QoW+4=; b=b/OD9dQBwXE1T8MrYijlWFmG5nFgVYLUSGDixvQrh4A+Vyno/KDVv+Pz7WNzBol1c7 hgPj6C5a/CdM8V4v9GlJbGJegX4cmUqZhY386PFQo/u2kdOS0H4F+ItE8lvfOabQMBq4 B+t9XaxuY0MkH70snVL8s0ePHjc8aFM4oFpf04Gbq9YxNiylU21jGRFT0TNyzjtuCIgC 4PuELLmlzmV0xkS9mzXnFdHXNCEkugpQcM7PUci+dtuq5vf475R0VjnGL8r4cmHGgXTo /swLnuNI5MMi1CSwtcMJdKE52LgaAn2tNjyeq/xMKoRE3jD+BOKiRoB2KLYtpMkgvRrm 2Nwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689623546; x=1692215546; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xWoO0TUyoZ+Qmv9rHsFJp85hT+0xnOPhDe/kh1QoW+4=; b=ffEVZK8lXuDEplQMwal+DoztshOHznxH4dIgMJbuhxfAVZ6CaJpWMfgctgjqcmwMnH TuBKOJwJqeKyWqOn5VNcq+Br71kuNAxomHqB7DYrjyyvOuIcgtcH+9YGgwAdTf87tARs Skh6AHesYnLnt6wNOS3NTOlYhl7BJ+h3Tq3mOP0fKwSlT/Tsc710ay8MNYqSDfwuTC6o nVwEAkHMx0ALXBpLdip6NMigNJG+ctVl4rniLtgXgTrIsH1NM/ZWhGh6gjn4QauvbA3+ 6DSC/4FhvvPZooqICLNQukwAEf7XUV7EHJvqdd/bi6H44QFaT5VNFiGBiTnpYgIU18yi 3BnQ== X-Gm-Message-State: ABy/qLZrNQkRj3ce/3YsQ+N/yeax0HxwwsShd6fMEBSIMKMH/v4KgJvw 2sZL4clAgDTHb2xwnElw7MA= X-Received: by 2002:a5d:9544:0:b0:780:bf50:32ce with SMTP id a4-20020a5d9544000000b00780bf5032cemr615151ios.19.1689623545792; Mon, 17 Jul 2023 12:52:25 -0700 (PDT) Received: from localhost (dhcp-72-235-13-41.hawaiiantel.net. [72.235.13.41]) by smtp.gmail.com with ESMTPSA id t11-20020a6b090b000000b0077e35ffac2fsm68393ioi.32.2023.07.17.12.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 12:52:25 -0700 (PDT) Sender: Tejun Heo Date: Mon, 17 Jul 2023 09:52:24 -1000 From: Tejun Heo To: Hao Jia Cc: lizefan.x@bytedance.com, hannes@cmpxchg.org, mkoutny@suse.com, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cgroup/rstat: record the cumulative per-cpu time of cgroup and its descendants Message-ID: References: <20230717093612.40846-1-jiahao.os@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230717093612.40846-1-jiahao.os@bytedance.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,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, On Mon, Jul 17, 2023 at 05:36:12PM +0800, Hao Jia wrote: > Now the member variable bstat of the structure cgroup_rstat_cpu You said "now" indicating that the behavior has changed recently but I don't see what changed there. Can you elaborate? > records the per-cpu time of the cgroup itself, but does not > include the per-cpu time of its descendants. The per-cpu time It does. The per-cpu delta is added to its parent and then that will in turn be used to propagate to its parent. > including descendants is very useful for calculating the > per-cpu usage of cgroups. > > Although we can indirectly obtain the total per-cpu time > of the cgroup and its descendants by accumulating the per-cpu > bstat of each descendant of the cgroup. But after a child cgroup > is removed, we will lose its bstat information. This will cause > the cumulative value to be non-monotonic, thus affecting > the accuracy of cgroup per-cpu usage. > > So we add the cumul_bstat variable to record the total > per-cpu time of this cgroup and its descendants, which is > similar to "cpuacct.usage*" in cgroup v1. And this is > also helpful for the migration from cgroup v1 to cgroup v2. > After adding this variable, we can obtain the per-cpu time of > cgroup and its descendants in user mode through eBPF, etc. I think you're misunderstanding how the code works. Can you please double check? Thanks. -- tejun