Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp394281iof; Mon, 6 Jun 2022 05:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySR8n6l2zuTEjb5GKcUldG3/BQFj7I1R0f1lyPeWki6VbNRV92wOIe78JUOXo6FnhAk0Kq X-Received: by 2002:a63:874a:0:b0:3fd:c151:cafb with SMTP id i71-20020a63874a000000b003fdc151cafbmr4550974pge.543.1654519125758; Mon, 06 Jun 2022 05:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654519125; cv=none; d=google.com; s=arc-20160816; b=wgWRlMx/SOdGzNB2kIG4cK8NfSDZQBtcOukpIFx15DTOBN6zCfVze4zRjS2qzaVEqM lBRd2PMsRReO6AGqxstTnf3+OG1sWeY3xguJcM9cYqbfJJtMgU24K44lGH5f8Qw3yRMx lns6jhto0KgT62FNFaJRcg4SZJAjP2dx0TFXklbT0ohzl6ReOMGOAXnwIZ4knvSZOLre 9hFB4YG2wt6JD3Krwy9wpA6oAHQQ9nI1bRA0iIbIlPdkfTQa6eUsqBlf7kO7utd5CP6O glZDPbdadqkVQ9WMi1w7gZKLO+B/4wbOpZ83/uxHJvzqdT7cmYkMJeYE3iNw1WVpp9hS mOIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9PH08cMIB+cEkHAUwWnoV2Rdrv9uIuIlFs1vAUeLjT8=; b=HKKwGqFgYyMkE258uQ9xMvRbLT4zMg1Ce01YQI94efRXes8xuA4smZlynmVcvU3+Kl iRKxI8JuLeCgvaq18qG1PBZOoEK8QHyZtZLxELpnbYng90gffu3AiEiJYXPEhFEOmb1n XJY1OCuN8gTDKssAYgxt0R3XaW22RJQt3DEdZrHZCbkGHT0hPY5I+4/MINER1xornO0f l7/qbAoOLrA13QP4ssw8twiA7XCYKNjZ4HDDMakJhfMHVdGYnoaOb5rcXSBu4qzRVPtx H3kadd7tEI3XKCbVW5zTF0saVn/0DmSYxWf5huVTl25Kx3CYXTpbvNZGbpXlECQgqAgM rnYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=kkcGeuhV; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m3-20020a170902f64300b00163f5028fe7si22091565plg.365.2022.06.06.05.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 05:38:45 -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=@suse.com header.s=susede1 header.b=kkcGeuhV; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 869347937C; Mon, 6 Jun 2022 05:32:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237116AbiFFMco (ORCPT + 99 others); Mon, 6 Jun 2022 08:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237101AbiFFMch (ORCPT ); Mon, 6 Jun 2022 08:32:37 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A695006B; Mon, 6 Jun 2022 05:32:25 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 567FC218A0; Mon, 6 Jun 2022 12:32:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1654518744; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9PH08cMIB+cEkHAUwWnoV2Rdrv9uIuIlFs1vAUeLjT8=; b=kkcGeuhVE5Zp7oPO/179KJdiOaqFznXyMnLXtvm36fYBU0bVl0mvNwBtpbRJl9dfr/+RiE 6+V2g6bvqx/sqvTs8KJxLuwtOPyRCN+64wkDcfUBnK2Kl4cuUe61yYbnAbyigE+nfD07VX PxiKWoJJKcspi04Ocy896GgXS5pzquw= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 888FD139F5; Mon, 6 Jun 2022 12:32:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UhHOH9fznWIuPQAAMHmgww (envelope-from ); Mon, 06 Jun 2022 12:32:23 +0000 Date: Mon, 6 Jun 2022 14:32:22 +0200 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Yosry Ahmed Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Tejun Heo , 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 5/5] bpf: add a selftest for cgroup hierarchical stats collection Message-ID: <20220606123222.GA4377@blackbody.suse.cz> References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-6-yosryahmed@google.com> <20220603162339.GA25043@blackbody.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 On Fri, Jun 03, 2022 at 12:52:27PM -0700, Yosry Ahmed wrote: > Good catch. I get confused between cgrp->subsys and > task->cgroups->subsys sometimes because of different fallback > behavior. IIUC cgrp->subsys should have NULL if the memory controller > is not enabled (no nearest ancestor fallback), and hence I can use > memory_subsys_enabled() that I defined just above task_memcg() to test > for this (I have no idea why I am not already using it here). Is my > understanding correct? You're correct, css_set (task->cgroups) has a css (memcg) always defined (be it root only (or even a css from v1 hierarchy but that should not relevant here)). A particular cgroup can have the css set to NULL. When I think about your stats collecting example now, task_memcg() looks more suitable to achieve proper hierarchical counting in the end (IOW you'd lose info from tasks who don't reside in memcg-enabled leaf). (It's just that task_memcg won't return NULL. Unless the kernel is compiled without memcg support completely, which makes me think how do the config-dependent values propagate to BPF programs?) Thanks, Michal