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 513FCC3DA49 for ; Fri, 26 Jul 2024 18:17:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E64A6B0099; Fri, 26 Jul 2024 14:17:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 996C86B009A; Fri, 26 Jul 2024 14:17:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85DCE6B009B; Fri, 26 Jul 2024 14:17:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6887A6B0099 for ; Fri, 26 Jul 2024 14:17:01 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 034CD121A77 for ; Fri, 26 Jul 2024 18:17:00 +0000 (UTC) X-FDA: 82382710242.06.B36B13F Received: from out-175.mta0.migadu.com (out-175.mta0.migadu.com [91.218.175.175]) by imf18.hostedemail.com (Postfix) with ESMTP id D6AD81C0031 for ; Fri, 26 Jul 2024 18:16:58 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=A+yA6E3F; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf18.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.175 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722017778; a=rsa-sha256; cv=none; b=N8ctvfuvbpcS6TGwhgvJmHj5r84jQu4nXbFF46xK7Ou4iB0CS8oVnkBX+CWs0ehAPv+z03 PM2l2j5BUttVVWPJyduzXVxr8cQjeBjcW3095dXvelL/L2mEDxA0c31afCAIOnnXaLomNP cSvbSxNYHuhm3RAuXUM/k5vFRDdT4wY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=A+yA6E3F; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf18.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.175 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722017778; 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=Swun6CogEp3EWEPStG+jjImIZ9tcFlvinrHHXIyi+ps=; b=UPkeC4mKUAVQJxwFWHW5lu3096dSpwLhkxiBhRzb/fzFrV5Ayo+RWkXU36XyuXQHF+fYqk qyMadUFH7WBEV0H+3gaxQPCXIMeU2gfn3qPCSC0Wpfck3ZtaQWU3tl0Jp6lQgQ6t/GxjAl 0Vz+4fbTMDUVapBbQsTarfye5prmFac= Date: Fri, 26 Jul 2024 11:16:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1722017816; h=from:from: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; bh=Swun6CogEp3EWEPStG+jjImIZ9tcFlvinrHHXIyi+ps=; b=A+yA6E3FeWWMRIxWCPIEgHvwDvnszVvf1jIzTbK9EdowIuJTq5pFgOvy2JRyFyaOF+ONiQ ycykG5HKkldwdAgPZDgwORMXq0BxxLo7Ss4Ns8SQQ/4nI2Saaf0UdtRh3AGdZHOWlTy/N7 nlAD17Er47tOjTk6w6pG8SvJJPxt8JQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Yosry Ahmed 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 Subject: Re: [RFC PATCH] memcg: expose children memory usage for root Message-ID: References: <20240722225306.1494878-1-shakeel.butt@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D6AD81C0031 X-Stat-Signature: uth6m3xcm9k4f9qya5bkfhscor17cizk X-Rspam-User: X-HE-Tag: 1722017818-898177 X-HE-Meta: U2FsdGVkX199LhEnUQVpDYjCbhrzaqRpnWVGjez4CuAEMACzUfZpxtB6fH+BwO7E0aqR6142wcbH5tnF8qaarSrb89hG7cKrXpXob16uYYM9aPgZy0PuUokrZyWAhyCamOyPyzc0T9Hv5uyo+cjagk3uIIlC9GXaA60N0dNFjw+Vrx5RkDwN4fOb4tnQpGGoOU5aNmlh2ElYC40q7LaeX3j5UGEJUBYATNBz4L1v5DQQjfYTJ6X3tvBN4eY14W+0Qv/w20aG6Gv5BNJfXeaXPIqBR6xkZlLs0ZpZTCZUlncQNgoSkgClyLEWW7CMfzgDy/7GTegoN/NBl0Cr8u+tqXBh9ejL7g9xn5OSVxcPhF9p1Js2SKTDrv5dj4YZTUobseRnbMk4uZuPSimpFqdTHZNOLE5BbkulKdj+DnK0x9Mkj7FVTnm2Kfi7Iszsu+lA7PhiYSkbVzZzczJ6Jbwif3xYFYCWHqA0Jsas/gxscElwI/vvrV7YWtK6WbYRU2DnznM9+gQTK/p4wFU32DLEhlWFN4jLJvF4gEd1ZMX7x/e10Ov+AjlhMUPfCU/qKV1nq0ZvfCWeVL0rEZgjRE/XrrHUgjA6W92U4Q/rl+RszLhtV1o/QXnuG4i4dnrM7kLFYFvWGW61PqGCfMP8G/H6bMHEcsDp9FRosiSGTpHg5I5iWVCzyDiTrdYaHlaneCqexNFL/SUXrsI9aCi9VSSV+xJvZzIKfRJlYomCkle0iyU+wxKGeI+vCY0ZyAmOdUlXgr/PY5rILxBabmtsGV51BrCIrQ66/wb9RypIUVSwqEXEmgTz+yDJpcLHCIOT9Fhv/Wx8u0oqtwDy4/EQy0UhIT1Y/PduG8aw+6F0771KVnIWZqMhXsQusd6EymXGnNZEckU16OUqWe+FQIee7Q3NHp/Qeh+bMynOeIQ3xGR9yHey+3cJkZMfuC5sktlIUPd8oLyHK+WyBNIrzvvWU4b QddxhjP+ I8HVqNAsimMz7axcR4wkt6SBL6TtJxUYcQ2qtGHcHe1dApr4w45r+V0HCCGNlY0KKv1gXNcbzPRn41y/gQkuSG1ppDpKvOcA3gXekHW/ODSF7G8ulUA3SUJEcAOUURowrWtLsbpapEUQsCZe8krHMTRlGMN5iLxGXhOdcyiK5AKwUCAhRKY+E/eRTSqA6fbv9+SFcDS5kfPvAUynQ0IZfawy1dA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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:43:31AM GMT, Yosry Ahmed wrote: > On Fri, Jul 26, 2024 at 10:30 AM Shakeel Butt wrote: > > > > On Fri, Jul 26, 2024 at 09:25:27AM GMT, Yosry Ahmed wrote: > > > On Fri, Jul 26, 2024 at 8:48 AM 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. Most of the users use systemd which has fixed top level hierarchy, so this is fine for most users.