From patchwork Thu Jun 6 15:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Michal_Koutn=C3=BD?= X-Patchwork-Id: 13688671 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 A9780C27C54 for ; Thu, 6 Jun 2024 15:22:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 732BB6B00A2; Thu, 6 Jun 2024 11:22:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B9826B00A3; Thu, 6 Jun 2024 11:22:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5828E6B00A4; Thu, 6 Jun 2024 11:22:47 -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 1DF2E6B00A2 for ; Thu, 6 Jun 2024 11:22:47 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BC9FE160A56 for ; Thu, 6 Jun 2024 15:22:46 +0000 (UTC) X-FDA: 82200831132.24.241A5B1 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf10.hostedemail.com (Postfix) with ESMTP id 900A8C0028 for ; Thu, 6 Jun 2024 15:22:43 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=PYVS50ct; dkim=pass header.d=suse.com header.s=susede1 header.b=Gu9CsrXI; spf=pass (imf10.hostedemail.com: domain of mkoutny@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=mkoutny@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717687364; 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=Z0Kc8Bd03I/KnkB6dRr+g2P2M/m8COOx/mJJqEqwMus=; b=fnwrCYmRt8soh8N2RXWEUCpK62g4o44XKI1sd23/43OJhW5lDNZkwt22cjZ2mqhz301kf0 T7Qsn8OjC0W3lcBKm51GlCvkHm25EDhC1df4LvJEbPCUhuqxAq9E8sy0qI7g39ut6KKptN BR6IsxTeJNi5czMApTg9glNscVb156o= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=PYVS50ct; dkim=pass header.d=suse.com header.s=susede1 header.b=Gu9CsrXI; spf=pass (imf10.hostedemail.com: domain of mkoutny@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=mkoutny@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717687364; a=rsa-sha256; cv=none; b=6LWYUvlSFQwPlPoxLRPX8vr3xe61DRFmkW/XLR4Z+XCfhQS/hoie4+r9wvfN31bcaWUNjd H/CkOpf5TN8mlq0OsKm0ScN80wsW1SgrV3bk44jneGbxvPTVluKgorMsTB7OiN7YAUeqcW VlD1E2JoP2W31vMUbJigEJV/SlQ6m4g= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E56F51F911; Thu, 6 Jun 2024 15:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1717687362; h=from:from:reply-to: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=Z0Kc8Bd03I/KnkB6dRr+g2P2M/m8COOx/mJJqEqwMus=; b=PYVS50ct27fZ1kFviVdI2+iaasghsghfsADIf6ykfOUJo1I3S/eUVwK+sM8FFPr9GlUr05 OgXekOse/MmOmiV61qCtZkX/YYsGJKIQwuu65vR4kUPsvYykLkdDY4IFv6YnGnxAo6tdRc gzjNcNb+jiv9DLM/1aNmU6nR2j27N0k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1717687361; h=from:from:reply-to: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=Z0Kc8Bd03I/KnkB6dRr+g2P2M/m8COOx/mJJqEqwMus=; b=Gu9CsrXIVDQN/4p87XZxcHzZVpgZZghmoeVrajfUjsncBrYYZALOXtavU4d69nLIyeaEw7 1upqOVOe6ahh0CGtZnKoUBO8i8trQiD0ZmjfhwrDgquqBEHYWDaTkRdP4eWmWJ7GuOaSRB Dg24BMzTwpRJGjEj4ckfD2sEe2RFLUk= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D397D13A97; Thu, 6 Jun 2024 15:22:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AP2DM0HUYWbGbwAAD6G6ig (envelope-from ); Thu, 06 Jun 2024 15:22:41 +0000 From: =?utf-8?q?Michal_Koutn=C3=BD?= To: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , "Jan Kratochvil (Azul)" Subject: [RFC PATCH v5 2/3] memcg: Add memory.swap.max.effective like hierarchical_memsw_limit Date: Thu, 6 Jun 2024 17:22:31 +0200 Message-ID: <20240606152232.20253-3-mkoutny@suse.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240606152232.20253-1-mkoutny@suse.com> References: <20240606152232.20253-1-mkoutny@suse.com> MIME-Version: 1.0 X-Rspamd-Action: no action X-Stat-Signature: 18kg8t154h11ytr4tbc9mfrm6w1fg5gi X-Rspamd-Queue-Id: 900A8C0028 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1717687363-706530 X-HE-Meta: U2FsdGVkX1/dR/VC6ZPOnCWSXF92O1OfVmDPZk9iwDkzsw4amP/RV9f1AXCc7fvZ0fkmYdnCZhrYiGV4G4wXiDRO0TbG+ZwAH9qRncYZBT5I+umXyRwYfTIg03HXXHeiAcOhkBEbc0S2iZK+Kfjihx2XvJPr8C1Z6n9F25rx5l0tiy7eGTmfSoq8vZXmlXkrFGqOR11IiMEQLtY0k61ue8lq21gNBNm0H18hY7iaNTKWAhYzAWpjCiUksVYycllN/hPbzQ7iwg4SUlSoSIV+g30K3Qls00S5UZALWxgpy6kkNHPls+bPl/xW1RVzResH+QxXWyxwHO7yHWEQZgVsJ6jqWWbel0kvmcwcNY5pppz4MWED3u0KfwQxwGmwFhvprvEBuvuAC7ES9VJucZ3lm7MknwtMGf0PQ2hVlRlgH9zp/nx1NrbS5rd1e5bH6bxwcNpJkpOljVxS/JIbMhTfqq4sc77vw3HmVwSnx6P873Xe+TrWrcx7Z5uWrcA7KUq8rSh7W10wa0dZB5/FNWyCmjAdM6wHjkWE+hPu6XA4PK/XSdjDLwCIwICXv+1c3dTV/YFmy6KVqi4LIg9komFpPYtol9ret4CjgahhVJf9yRdR9S6bv0DNoWxbP6qalvkckagg6MfsgZI/alN4Q4xVLstnvj7zfzASHRq5IqT1nmINmZDQlT+g6IbcE+5TmII61x8E40847/sDrMY0Tkh5VcLBgTYWNzIWtXdSl9TZptHGnEzveJKnj99DPYeim0PqtTi0yl13GVqmnNbjeaUEo8B+8zWVWHhd6gb4xlTgt0ZUy21nyBig4m+XZmBctSCEOx86OfDjXErM/xI8kwCISvRumBYXZsekrhJTep0YeC7p92tQ7BN6okdNqnTehrEkhFx8pnASWcSN/zYtI0ahL3YzFGysGQdKyhDDiYPezx90Ki25+R2FnbfilET++XAeVbiEVLedhr0IlMzw5eT dZSiUcp0 OOBt1cSjBBd3TbFk5S07KKXvs0wKqdglnJWSKwQQnRGd2I8UTPuFT0iLs3GD/ZVwik5L4bAETVhjxdki1bWyWWGuXEqOWqZ7btrWgP93k/XcFmLciCmJEhszbdY9Czoa/8FPy/Q3BkjKFVFdIglxD+ajC46yxEikrWKM9MZGte7U9nse6uyrv+YeNdvjyOCR7FRZj00n+XUuyh2WQcA0x+8K1PgLZJz4WbTKQgteR3DheBsxAePurTgR+jgQp7k5We5GYIJqmd3EZ40uegH2FgWjG5G/Bt/pDfSVGT5hAncpfKOCs6fbLMcvp8p3KdCLpj5WF6TT7ZP3uQv8upZLO1E7mgHXjyW3om+k4yirjHx96qT41hwkM46EoMBwOav3ihX9sDxkN78891ZCN16xFtpZ5vy5s9YwozPrnsY/LWeBrfA6f+cuh6vRMaw== 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: cgroup v1 used memory.stat:hierarchical_memsw_limit to report the value of effecitve memsw limit. cgroup v2 has no combined charing but swap.max limit, add a new memcg attribute file that contains the effective value of memory limit for given cgroup (following cpuset.cpus.effective pattern) for cases when whole hierarchy cannot be traversed up due to cgroupns visibility. Signed-off-by: Jan Kratochvil (Azul) [ mkoutny: rewrite commit message, only memory.swap.max change] Signed-off-by: Michal Koutný --- mm/memcontrol.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 86bcec84fe7b..a889385f6033 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -8279,6 +8279,19 @@ static ssize_t swap_max_write(struct kernfs_open_file *of, return nbytes; } +static int swap_max_effective_show(struct seq_file *m, void *v) +{ + unsigned long swap; + struct mem_cgroup *mi; + + /* Hierarchical information */ + swap = PAGE_COUNTER_MAX; + for (mi = mem_cgroup_from_seq(m); mi; mi = parent_mem_cgroup(mi)) + swap = min(swap, READ_ONCE(mi->swap.max)); + + return seq_puts_memcg_tunable(m, swap); +} + static int swap_events_show(struct seq_file *m, void *v) { struct mem_cgroup *memcg = mem_cgroup_from_seq(m); @@ -8311,6 +8324,11 @@ static struct cftype swap_files[] = { .seq_show = swap_max_show, .write = swap_max_write, }, + { + .name = "swap.max.effective", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = swap_max_effective_show, + }, { .name = "swap.peak", .flags = CFTYPE_NOT_ON_ROOT,