From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 668CEC3DA4A for ; Fri, 26 Jul 2024 17:44:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D74D06B0092; Fri, 26 Jul 2024 13:44:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D24E36B0093; Fri, 26 Jul 2024 13:44:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BECB66B0095; Fri, 26 Jul 2024 13:44:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A09F56B0092 for ; Fri, 26 Jul 2024 13:44:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A0FA61C1256 for ; Fri, 26 Jul 2024 17:44:11 +0000 (UTC) X-FDA: 82382627502.30.290BEBA Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf19.hostedemail.com (Postfix) with ESMTP id C7BD41A0009 for ; Fri, 26 Jul 2024 17:44:09 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="bCFHd/FD"; spf=pass (imf19.hostedemail.com: domain of yosryahmed@google.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722015800; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6wkRT8xYEb3zK1bE83f4Y39EZuG09QMTkBMl0VIjcUQ=; b=WXE92Owd8CWu99NYjeZvGD4aDzgudYeBmVYXOmmRvyr6ENRyrlKcsivnNgfmywZ4E5pJhq NqltSDNUik3xcyECtNhTj1D7X3o1aigFtAJWYZxHqx2cMqO8NREWoimsIf5GZU9sBKmMql H+PqZkWlcjXWmKtKBHiuZCnb5L761Mw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722015800; a=rsa-sha256; cv=none; b=w+677DZa6P9BWLI87Wsusavf/X9b7V8tLnzLibvsQLOjKWohvMWvSuC5hTqIAVETZZkyvT LRbbAqEW1EytNA9cCACzMbZ6qeRRqaQWRcqEtoUqFlvxMDi+rnB6MDd5B0u9tcmcOlnJAh Zg69BOwVM6/T8d8e31Ki9ii4WjQesl8= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="bCFHd/FD"; spf=pass (imf19.hostedemail.com: domain of yosryahmed@google.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=yosryahmed@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-52f025bc147so2100972e87.3 for ; Fri, 26 Jul 2024 10:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722015848; x=1722620648; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6wkRT8xYEb3zK1bE83f4Y39EZuG09QMTkBMl0VIjcUQ=; b=bCFHd/FDSWZTa5TSxW8ljr49H9axVVXWwJOlhAyc/JQfOAb09cvtfOlN5NZl6dVy4K th1xqEDJNP/4wuFAI9Z7yVVsP7Wa490YtCpu/TUgk8Yb6coCQ6dqVSx0lAWr3hrtF6hC lU245pspw+7MgP2CoKEgGu4cisNLCjiR6wNGvM9KIXsgzUVeqM0c38RczOtgWbEKS1Gu kNk0ATzyi+Ut3i3EV1iAgF+PloWmUn7tc9odFASxEWw0uGHB6y9zmrm99zY8idxmWsRR Qxon1fatL1RPlEsUNDXDU01Vw+N1D81+tF+kvPPrpFAJ7ie+Ebpz0V3MH9qHs9GU6Gm2 hNpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722015848; x=1722620648; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6wkRT8xYEb3zK1bE83f4Y39EZuG09QMTkBMl0VIjcUQ=; b=uxIz6rS6CeqdadLhzljKof7oNRa49EaLYWKMqwn4zV27t0qTNbOhsTuL9GpRpa5Q5J R1X9WVLxrrKzB8g/VqPe0DkasaNaBVzqrjFJPkhqdFktDPj/adUJewunT27IikawTAYb HTfMOajhz8OCcTxMoKdGW3bPoamWTTXX7B4jN0LDFVWvnlhcwHRYzyTk2wVUr+LlXYDp aTl+KpAqCcB7yXA7AEDema81OKgHydooEx4uqZy9ZdYSQSyJ7C/5H9zl19nDwgITYigo PwTJLU0EtM8engGV8eUfrYC1RHLdCDegWz7QvCYBcle0VXYvW5fHILpzI01DqKLVzEIy oZpg== X-Forwarded-Encrypted: i=1; AJvYcCX9dwwOlDel/TrNE3Nteqxx7jV6vIZB9NO2iGTo1xNasJ8VGxc2HBDXoBOUin3xB7djFmrbbYbvE4YHPxKkJpRNyH8= X-Gm-Message-State: AOJu0YyPxdj+lA1I06yeTUsg2KMqwWIDeRW41YO2dDYY5ckS6BOUsqgB 4MRWEj/NTQWIaBQwNMNPUIyFCzsttZSsP+aPdWTnk2JC+qSsP0yLqKWFuFpIh/ZKVicK6XqEGu2 HV/5DIDFU9c0oRqSjGb+Pd62FOikZlkiqfXk0 X-Google-Smtp-Source: AGHT+IH0zH4RcaRMCSfEP7q8GVobM5XEVw2We27FrdbthB0wxkDIc2oCYDy428qbvB/pOG0btoGmmUUYPqKMsEkEb0E= X-Received: by 2002:a19:2d04:0:b0:52e:9382:a36 with SMTP id 2adb3069b0e04-5309b27b2a9mr355143e87.30.1722015847438; Fri, 26 Jul 2024 10:44:07 -0700 (PDT) MIME-Version: 1.0 References: <20240722225306.1494878-1-shakeel.butt@linux.dev> In-Reply-To: From: Yosry Ahmed Date: Fri, 26 Jul 2024 10:43:31 -0700 Message-ID: Subject: Re: [RFC PATCH] memcg: expose children memory usage for root To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Greg Thelen , Facebook Kernel Team , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: C7BD41A0009 X-Stat-Signature: tg8tfww33hyp9qbu5qhdn6raqgce4bqq X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722015849-534448 X-HE-Meta: U2FsdGVkX19Lulip7byWUg79iYQqzV1OMQv+4sauA/w9TL4A4z1z/1VNBEaQDpiE7orYShxqWbjd2F8fYkQVzhUtdILfEurTyh2EOPx8JWUqYkgbWmWNeousbA4ZcGb2LIm0DMmmv0oJGD73R7v551xLwPwa4k/EqwGYV68tLiM8PmoevK+9kmg3eH5UtWZlOSRIasot/JA7cc7xIwO8Py3gVE9nQvNTwISxjZw3WfP+npFQ3Sso32atWEf/xxmL2dN5Am8eMIQd97FeHkkL5o+nDnrt9xQ20jtUmz4zldNcd9xoyJsbtAk/GB4P5ylq0vhPSC+i0o626pmf/ASAgqERcemExVcHL+h0MK5Aw2lDsfAqODnltroTwPdC8nOQ3buidC4Y+y+IiOAmGsIAjZWXx88rLR5/jL1+10I4JQ48QbKwkdXn1/0yvfOZQIdPkfFMAdQB33PscWh3qf0e1faXTeuESU2/JXolkXocr6KtPZd4zOpRS6d0bIkgSlRUDZ/If50rnQbxOalMPCUuu/a5Rq+J84pUGvrXfD05X2LdGec5rzAhPBMuUTzkYV7VZ5qcAADKdaFYz3lqPAu/ZzbmKLnKs6ET+3uDd/CAFtQP8jruTAlbDAzdiI6q02t6AK8Jg58bDsnZxzMt1RrjhOwjs674eCYtPD5j/gP6J4xJRtbjLx1x5cduZdxUs5hUzh2pNPlqnjYOf0asg7OulQ8XPI/ALPOp56D9Ba3+Zqv3Ffw0Yh+wg7Y4afewDLXpt3Gim1PjJjpzasYut2iCYLWPzqkR1hntY1gW+DhOOD2fuafUexeLRQ2C5q4zqYiXuQ6A0ixDUuNYx+ly3A7BmnJJQ4HWqlS505FNPBOpnlPYfQII0HKLqNcf5mPoSxAeH4k6pw3pn2OgsQKVHtpiEDIYODO/aGWpUcpodfvQfkyAPI/oO7y2YWM1BSfV7wyVWCDnjZys7keQgdYvDav HfDKILDC 7EhCn76WDNkH3sB1fK8DfPL4n0KwYC7T5gCkK++/Al83Ozv74MA4nITbteJAZ6Jo7Qaw+y5tm64GVJA6D3mvhp7u2BkoidLlPc8D7NHbXHhpr+yChF6S6CVgeB4lUbJbc7d36hrE14KUmhBoboayZkxdIKzn9agI0e12yCtheIe0toxU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Jul 26, 2024 at 10:30=E2=80=AFAM Shakeel Butt wrote: > > On Fri, Jul 26, 2024 at 09:25:27AM GMT, Yosry Ahmed wrote: > > On Fri, Jul 26, 2024 at 8:48=E2=80=AFAM Shakeel Butt wrote: > > > > [...] > > > > > > No, the workloads running in non-root memcgs will not see any > > > difference. Only the workloads running in root will see charging > > > overhead. > > > > Oh yeah we already charge the root's page counters hierarchically in > > the upstream kernel, we just do not charge them if the origin of the > > charge is the root itself. > > > > We also have workloads that iterate top-level memcgs to calculate the > > total charged memory, so memory.children_usage for the root memcg > > would help. > > > > As for memory.current, do you have any data about how much memory is > > charged to the root itself? We think of the memory charged to the root > > as system overhead, while the memory charged to top-level memcgs > > isn't. > > > > So basically total_memory - root::memory.children_usage would be a > > fast way to get a rough estimation of system overhead. The same would > > not apply for total_memory - root::memory.current if I understand > > correctly. > > Please note that root::memory.children_usage will have top level zombies > included as well (at least until lru reparenting is not done). So, for > your example it would provide good estimation of top level zombie memory > through root::memory.children_usage - top_level(alive)::memory.current. Good point. The fact that it includes the top-level zombies makes it less valuable for this use case, as zombie memory is considered system overhead as well. So we need to iterate the top level memcgs anyway.