Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3388620rwb; Mon, 7 Aug 2023 12:42:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcJMiW8B6er/e98Vy5S0aq7pLG5YqXdAg9Kodj/m5Epbxog5oIONcGFwb9LCNHzDltLMPB X-Received: by 2002:a2e:3c1a:0:b0:2b5:9f54:e290 with SMTP id j26-20020a2e3c1a000000b002b59f54e290mr7236184lja.0.1691437349408; Mon, 07 Aug 2023 12:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691437349; cv=none; d=google.com; s=arc-20160816; b=IoBXiZuIUgw3wcIf2f0M/6TOR8oWLBHf1bUUoTUecwOq3VkxIXIoMh5OboTFDo2cwE 3rR7x5BEYikLpOjw5U5dkPN68G94kdzIR8dtv9eKrco3J58LEMTd8uA+8AKIozFRkmT9 H1QHQOq6fufKGNvUzpx84xGLvNpF9Q6OYpUPzoTjCdW9s5T30SxfbHfU9c6Y9XBrG6JY PDa2ReO3JmnwICtc2Z8q6e0/JGr2Fgi+shI4tqRJ6bz5ShXdFjVaoPglRP3Y6Zy8kDWg Vz8DkQ1By8I7S2H3xQxM7WFl4MBO9nnXSE92FqnfWNapcK7DyVUe2LmVliUw9cE5da/0 vclw== 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=ZjR5pXl0UuinG01FbgVJViJLXMyiirXmYlC8ixIZaWI=; fh=nbw/nVFTH8T/egfCotWa5ah1Fa42EN+ugoyp0c9UFyE=; b=OYz2hvBuKeAkeZYJW/CZFWEVQls0IIQ5XSJDpQxenNQ4ZLe/kD/38EGVS4k5obKLn2 AEv5UT0KCa+UsQaivGugftkR1p/3jDR/F2WFGc2Y+L/DRr4uok77wCK8y1bQ++MKFjq/ wl9AJ0tJ6QRh3jDgeGBwqjWIhqZmrzo+4clzHXivvj75Hqe3rpmq5iysYkI+X4fvfCR4 D8YxbVVqilQGO154KxTJrP/TbrV0Qt/QTNx5BqkRbueMdpum+rZ/vNo0YiCH5BiZXl5h /nRqJZy8Yx9H/lJHd+sItxjNxadUWV5dzC2xKBsk0EBVcMSg3knIfJgW03RSC4Ae8qkT R6+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="LBJ/vxIx"; 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 z23-20020a1709063ad700b009889b69c1edsi6569193ejd.697.2023.08.07.12.42.05; Mon, 07 Aug 2023 12:42:29 -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="LBJ/vxIx"; 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 S230486AbjHGSmF (ORCPT + 99 others); Mon, 7 Aug 2023 14:42:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbjHGSmE (ORCPT ); Mon, 7 Aug 2023 14:42:04 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2566D171A; Mon, 7 Aug 2023 11:42:04 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1bb84194bf3so31963115ad.3; Mon, 07 Aug 2023 11:42:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691433723; x=1692038523; 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=ZjR5pXl0UuinG01FbgVJViJLXMyiirXmYlC8ixIZaWI=; b=LBJ/vxIxnRKTm7zQ76pErn2jwczKbYDq41bpll/TUjJBnW7H/rQJVuz1tyUkGcB6oM sV67vRXYiyxhwWeEsQLiJ0ID04XmOSbbo3N1w86bLzq6xWRNq49SI9OPgbvf4/AyPxLs qL4112juNxcf595WcqGthvXUXZhQWF/PBxa+jZ+4C7rjwk36arxNV9yw3hoY7vf+XO1r 0TxQ8G0HUw0gsWJjOTe85l556gc0VS5FHct7gGGq0LhfJcw8uIHOTS6oK6fTMFklJiHn Yey8etyXTAmszbJjWEEybEs45+iZ77ajyB36HpRv1hA6Fqc7E+0qtnvqqxBV2B9+Qy4k XBcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691433723; x=1692038523; 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=ZjR5pXl0UuinG01FbgVJViJLXMyiirXmYlC8ixIZaWI=; b=T4JMuAtyEWFhbRVXbEXVzL56fxogEzKJDXFv1Ln6FqQk76R3KfQ7Z2GWoSRRQRz8Qo n5DOcchAHgVJddukewY37OI5bDZoOQh8tUamfjn2GYg7Y0fMdNywpGLXOtLLN+5ahNym x+8YthwicJHe572/TeaJxabLnwcYjis/FFFv6Q07Er8rQWIIlG33il6eQwnZvCyyHHOu kM8MTH2ECA8WcMapcQHFQLxN9PX+uo6lS5dM0O/fdiUEcSze/aw6Rl+LEx2NJpDhymlT Om3q9s/fyiIi+3sXL/vMPbiH1I5FePZr+XpozEbwTFiK+IN7Wh/Y61Pb91RydtqLFNmm oSvg== X-Gm-Message-State: AOJu0YzFe7Y14MMJTIQzmZmrWD58pgnluejCqoINflcpPGZiRwVi6qE6 ct92VRfsibKwrgygwdZTKkI= X-Received: by 2002:a17:903:1cb:b0:1bc:5bdd:1f38 with SMTP id e11-20020a17090301cb00b001bc5bdd1f38mr7575761plh.3.1691433723515; Mon, 07 Aug 2023 11:42:03 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:9d5d]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001b801044466sm7240525plg.114.2023.08.07.11.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 11:42:03 -0700 (PDT) Sender: Tejun Heo Date: Mon, 7 Aug 2023 08:42:01 -1000 From: Tejun Heo To: Hao Jia Cc: lizefan.x@bytedance.com, hannes@cmpxchg.org, mkoutny@suse.com, songmuchun@bytedance.com, muchun.song@linux.dev, wuyun.abel@bytedance.com, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] cgroup/rstat: Record the cumulative per-cpu time of cgroup and its descendants Message-ID: References: <20230807032930.87785-1-jiahao.os@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230807032930.87785-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_BLOCKED,SPF_HELO_NONE, SPF_PASS 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 Mon, Aug 07, 2023 at 11:29:30AM +0800, Hao Jia wrote: > The member variable bstat of the structure cgroup_rstat_cpu > records the per-cpu time of the cgroup itself, but does not > include the per-cpu time of its descendants. The per-cpu time > 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 subtree_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/drgn, etc. > And we are still trying to determine how to expose it in the > cgroupfs interface. > > Suggested-by: Tejun Heo > Signed-off-by: Hao Jia Applied to cgroup/for-6.6. Thanks. -- tejun