Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1677899lqt; Wed, 20 Mar 2024 10:39:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXHdFODD5eVh24qwYmVN9Tjx/zIfXza/KwJLzzbcw7QPtM4nPDS2GbvU86Zf6pIqKKZVLUQdtsKrvrlG8AI8sLHIfjRKRdveAOmLK54Q== X-Google-Smtp-Source: AGHT+IFfMglb7Tv5CK5kAfoz3k+uGMQ+KG40ewg39Qk/hUMAjdB1Z2ExG6Mtcr2DY/1V4S+mi7dA X-Received: by 2002:a0c:ca8a:0:b0:690:caa4:50e with SMTP id a10-20020a0cca8a000000b00690caa4050emr19244313qvk.29.1710956342796; Wed, 20 Mar 2024 10:39:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710956342; cv=pass; d=google.com; s=arc-20160816; b=OdMclOZlKaUD1+o8ViwIO+4QJBQEz7DR9+lw54s1+uKzIq8orcDJcVGe/3RfzBZTNU Gx5XGZHtWlYbyZ7nK7IYOwohAKEuCUGTqjDHyYJNE8P41SVSNADPUsVaDRDuBrvyiH1v 9AWCIivZUtGRvW0EeoT90TWlQTeWE1DlwEKMHhdkDZNY5xV3iM08X3sE1in94jfZqmGG jHXg2hfyFvX8vHDj5uWbN5QXQqT+cUqqZY1TuI3OMs/HtYfn9NgJmQbNvB/qR5iLJdFT m6DF3NUt9WD4u8w/m6TEB6IUpC2l3HLqfQVmJpllamtx7HrP/1ez3jfbM3Rz4eSDvlmf BT8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=mqLtQwQxhbXwBUY4R9Zu7ftNuAQlfnwIHtSjEpmlHsg=; fh=gtwHBQQSGXdVqKZKjA8R9b3QbDhmPciy+55IjIvkmYQ=; b=f0q78GOwbV8/flqFs+jfez+lIy/7SU4Z7+332W1tfJPM0h46llAelvqvPfd/S+q1H6 Hcje3QbTePl0W/g6gjaNtJ6XI+eqFm9bG8FBRiKQWm3ILQHWv7LY0Cu8EqoanS7woBeo oy8apEdhvrCYztMTWPZGVlm+pJZHeuhxw+l2vcAEqfn5eUtp6mnFz1rrlN9CJRc+lkHQ VJ9rEd9zlh3eZbR7C9ZTYNc8/LQ9tPE2B7EK6KJssmFqD0B+P0jdgm4ch/ftfAVTY3aR JacLK0y5g51l7Sq8+b5t6s4cIYtv9hFfCq7zvboKse/uQu05U65hnKcwlIz4e5dQgRvu uMMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=X3VdWnQl; dkim=pass header.i=@suse.com header.s=susede1 header.b=p1JLIAXc; 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-109242-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z1-20020a056214040100b0068d039dbe5esi13425301qvx.492.2024.03.20.10.39.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 10:39:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109242-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=X3VdWnQl; dkim=pass header.i=@suse.com header.s=susede1 header.b=p1JLIAXc; 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-109242-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109242-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 861411C21963 for ; Wed, 20 Mar 2024 17:39:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1680D6A8B5; Wed, 20 Mar 2024 17:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="X3VdWnQl"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="p1JLIAXc" 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 324476A341; Wed, 20 Mar 2024 17:38:42 +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=1710956325; cv=none; b=HMXt5bu71H3VxkGjfWcPsVn1Ttutex25Bq4DeXP/DDL9DEzBRKEjK32WfQYyyglaK6pxPmOeSySBv+Ug2AcO1RmW82vqHnpUCcde9YQGVLjswUl5ppy3SGIMJjOgOgM8KzXUnN6JJtr4ehY5DbLDFO2lLp5mjfql/r59vZykrA4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710956325; c=relaxed/simple; bh=xwp4eRRwCGaPiDsjgiJ3KwoPvozYMQ2RaLp7XX1ULPQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Yn3Yp8t26mEAE/4cu2nNIbnT1JkU2T2dfUT7mTJmZFemyHY9fjBJmZ7Miw0bKm+hbP0MgPRm4e0fOCFha4dy2oMKcvnP20fI6eB3McXPNmXpndLp1FxUt6NVK/TWjzhXAe+BEUBsSax4L2Gz3ID3NwNU3/R3BL0sipVEDtveLvA= 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=X3VdWnQl; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=p1JLIAXc; 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 CCFB15C076; Wed, 20 Mar 2024 17:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1710956321; 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=mqLtQwQxhbXwBUY4R9Zu7ftNuAQlfnwIHtSjEpmlHsg=; b=X3VdWnQlS/g6pWFhuVbT/AUDemD4JAAc4icdTTLYm8HSFLEB4CY8TylpT9RlButKQrQQyQ mgJ4Wzzv3xRXX/ai0LyLOcbN8IlMjpibSs9GMlLHoh/vVpse0Q300vhFuKf5JPd/qksVoy fMCGUY9aKwr/TMoSrR+TyVEA3fWdAH4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1710956320; 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=mqLtQwQxhbXwBUY4R9Zu7ftNuAQlfnwIHtSjEpmlHsg=; b=p1JLIAXc7klbNEa+aPwcd4sdocYrjpEL2KLbnLX6Q2Dxu9wwk9YwK+fcSnsxp000H7ojla 0H6nKtybZrOGOh0e0fFYObJbLAa8xqtpLH6YmImLsfCiCt7pDk9HfIbGHDmvOoCpR0YEI+ SoL6CBaYZqFqR19V+ddbkEECSvsY5+s= 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 AE782136CD; Wed, 20 Mar 2024 17:38:40 +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 oStwJyAf+2V5fwAAD6G6ig (envelope-from ); Wed, 20 Mar 2024 17:38:40 +0000 Date: Wed, 20 Mar 2024 18:38:31 +0100 From: Michal Hocko To: Waiman Long Cc: Pavel Tikhomirov , Johannes Weiner , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Vladimir Davydov , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@openvz.org Subject: Re: [PATCH] mm/memcontrol: stop resize loop if limit was changed again Message-ID: References: <20240320100556.463266-1-ptikhomirov@virtuozzo.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=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Score: 0.44 Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=p1JLIAXc X-Spamd-Bar: / X-Spam-Flag: NO X-Spamd-Result: default: False [0.44 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; BAYES_HAM(-0.05)[59.50%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DKIM_TRACE(0.00)[suse.com:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWELVE(0.00)[12]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; FREEMAIL_CC(0.00)[virtuozzo.com,cmpxchg.org,linux.dev,linux-foundation.org,gmail.com,vger.kernel.org,kvack.org,openvz.org]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: CCFB15C076 On Wed 20-03-24 18:12:50, Michal Hocko wrote: > On Wed 20-03-24 13:09:07, Waiman Long wrote: > > > > On 3/20/24 06:03, Pavel Tikhomirov wrote: > > > In memory_max_write() we first set memcg->memory.max and only then > > > try to enforce it in loop. What if while we are in loop someone else > > > have changed memcg->memory.max but we are still trying to enforce > > > the old value? I believe this can lead to nasty consequence like getting > > > an oom on perfectly fine cgroup within it's limits or excess reclaim. > > > > Concurrent write to the same cgroup control file is not possible as the > > underlying kernfs_open_file structure has a mutex that serialize access to > > the file. > > This is good to know and I was not aware of that. Thanks! Btw. even if the interface itself is serialized then uncoordinated userspace is still timing dependent so fundamentally racy. -- Michal Hocko SUSE Labs