Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp462560lqt; Thu, 6 Jun 2024 08:35:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVVRX/5Onpve04tbgPrAsFHgQHDQ+ECKbHdPWrMurZu92xchpq6LMSAiziJ3YOQGdriOiDAMnC0l+tECWhpRvPGGYltQUYNh5IL+Unscw== X-Google-Smtp-Source: AGHT+IHMSSysc8V9Gei4qBK29IImKDF3Y7UFN7/UT2BZZC0OLp/otj+rn1K0+9JUGCwZ7klgwap1 X-Received: by 2002:a05:6a20:2588:b0:1a9:6c18:7e96 with SMTP id adf61e73a8af0-1b2b6f84f0cmr6504764637.19.1717688101556; Thu, 06 Jun 2024 08:35:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717688101; cv=pass; d=google.com; s=arc-20160816; b=as/n8AaL4A8YPK0aNyNTDLN7YfxyBC1i1jMPvGhFUVcaZjzWelF9PM30ISxzsmS+Bl 6aD+EI1Sd2HbB7R+3/0k/OlbaLbmC1dPe1KQgf+SLoZpw+mDYM2C+kFihfz84PekFJtG If03N673bj2JO5rCkGDB8OWn706oXTADAJTXCX8qFHSU+5AgV/In/h9UGO2vaGkDxRkt lyMtrmS7oQBiL03ZX2Kf+gsUSaJC3HqphAZHJcySJlLTZFRQV8I+pQDZ1I7iktAa3Aqm NW4D3rvgyre+eRwEoGdafJ3QRt42obh5mBg2zQ8g67QmThu7/G9qWQVxA8TLhBFSZdr6 X4+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature; bh=ETytyPpyO/ne7SCX3Wq9PF58dUOe/pCqU+w54NHSJZY=; fh=lzYMZyG15BnyKm+pO/wAoBnNDFMGTtmcEwSpAo1AE4M=; b=Z0zf8LXxRATxqkJ2j4C0kjy8Okl/6/wyZ3QOAjKELSzG9rVthCcR/t1vLSpOPgkzPH nSGD5UXQv7M2U/QBORyoUtn2pNbEneS9bqXv4lYsejOHWaF8pKMIjQEGRyTv2+lgXa/g /U+e5N5SHbkXLi+upJ9svSTDEVfF0A9/Yc1iAZg0aQgHiffhClVfScgDKc6VEUE3ejBK wGGfeiRtttYeSEg9q6Tjvi5ZdOoG51jsXkow59bYGXebX6HPtFmH774A8y0xVSFRb2xS XycJvjlgfp+lM4HuuzGfIefp9VhDuBl92Jwx348/sWM6UhMLCrbfXJT94RwP6TkqJz5h tS8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=HEBOZkbD; dkim=pass header.i=@suse.com header.s=susede1 header.b=HEBOZkbD; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-204563-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2083181dsi1329932a12.138.2024.06.06.08.35.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 08:35:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204563-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=HEBOZkbD; dkim=pass header.i=@suse.com header.s=susede1 header.b=HEBOZkbD; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-204563-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9320B28B7DA for ; Thu, 6 Jun 2024 15:23:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AE9B197A7C; Thu, 6 Jun 2024 15:22:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="HEBOZkbD"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="HEBOZkbD" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53D44197511; Thu, 6 Jun 2024 15:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717687371; cv=none; b=P0u9VgeEKKfynFKwl8kbnPHO0hLYCFThoyRBGlJzYTsaCGLXvK2p77w0SLjV8esUZ+8mQ1WpAfu04VwAOw2pHMBbzatKoYaL1R1lLGrzw+ubigbpJrC2HjKWpOMsABK3s0wzvCS0NLzXJ1QkrQPamxl8BusY2RSePSnvPKDP/lU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717687371; c=relaxed/simple; bh=5X6i5YJwK+jQB7PuduPkzuTtnC15SQWqQq4DC5e8bnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BpI/hT6Yx5Db7o6Zlc2f42Q//xq0O2AuifaF4fW/jm3UsXzchYp6IPRyAdIWQkl/ucLJLZJMuNPPXhsTvRPIsHeSxgSVAZwvUCRy1ItFR0wKeO0fjFuV6ZQf+JbIFqu+5npDa7WJvRAujrp4kpatS45xNlZ5zOagtNGzMgOsqiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=HEBOZkbD; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=HEBOZkbD; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com 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 F2EBA1FB3A; 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=ETytyPpyO/ne7SCX3Wq9PF58dUOe/pCqU+w54NHSJZY=; b=HEBOZkbDPKcmXI4zASPz2S6DI/nP7AL3FnDRJbLlPWsYAT1l+8WVlXcFRqoCM2DMBtHA0t Sp99OGabVzlFxnuI7rqsGABXYYKdja4X+tmblQnS5s4pVn/QkXrgi3C6Ojr/08g83xt2yX T8eJREiDDsTpL6uYmDn2b3a1Qg5TKNo= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=HEBOZkbD 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=ETytyPpyO/ne7SCX3Wq9PF58dUOe/pCqU+w54NHSJZY=; b=HEBOZkbDPKcmXI4zASPz2S6DI/nP7AL3FnDRJbLlPWsYAT1l+8WVlXcFRqoCM2DMBtHA0t Sp99OGabVzlFxnuI7rqsGABXYYKdja4X+tmblQnS5s4pVn/QkXrgi3C6Ojr/08g83xt2yX T8eJREiDDsTpL6uYmDn2b3a1Qg5TKNo= 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 E01E313A9E; 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 IGGYNkHUYWbGbwAAD6G6ig (envelope-from ); Thu, 06 Jun 2024 15:22:41 +0000 From: =?UTF-8?q?Michal=20Koutn=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 3/3] memcg: Notify on memory.max.effective changes Date: Thu, 6 Jun 2024 17:22:32 +0200 Message-ID: <20240606152232.20253-4-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spamd-Result: default: False [-3.21 / 50.00]; DWL_DNSWL_MED(-2.00)[suse.com:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; BAYES_HAM(-0.70)[83.30%]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWELVE(0.00)[14]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; R_RATELIMIT(0.00)[to_ip_from(RL5prnn869rbm1x4t47t486h7c)]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Queue-Id: F2EBA1FB3A X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Score: -3.21 When users are interested in cgroup's effective limit, they typically respond to the value somehow and therefore they should be notified when the value changes. Use the standard menchanism of triggering a modification of respective cgroup file. Signed-off-by: Michal Koutný --- include/linux/memcontrol.h | 2 ++ mm/memcontrol.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 030d34e9d117..79ecbbd87c4c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -232,6 +232,8 @@ struct mem_cgroup { /* memory.events and memory.events.local */ struct cgroup_file events_file; struct cgroup_file events_local_file; + /* memory.max.effective */ + struct cgroup_file mem_max_file; /* handle for "memory.swap.events" */ struct cgroup_file swap_events_file; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a889385f6033..72c8e4693506 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7022,6 +7022,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off) { struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); + struct mem_cgroup *iter; unsigned int nr_reclaims = MAX_RECLAIM_RETRIES; bool drained = false; unsigned long max; @@ -7061,6 +7062,14 @@ static ssize_t memory_max_write(struct kernfs_open_file *of, break; } + /* + * Notification about limit tightening, not about coming OOMs, so it + * can be after reclaim. + */ + for_each_mem_cgroup_tree(iter, memcg) { + cgroup_file_notify(&iter->mem_max_file); + } + memcg_wb_domain_size_changed(memcg); return nbytes; } @@ -7275,6 +7284,7 @@ static struct cftype memory_files[] = { { .name = "max.effective", .flags = CFTYPE_NOT_ON_ROOT, + .file_offset = offsetof(struct mem_cgroup, mem_max_file), .seq_show = memory_max_effective_show, }, { -- 2.45.1