Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp967990rdb; Wed, 24 Jan 2024 00:04:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFPLywefIc+wVvwHdBP+Psv4APs7dtLYDZEoNvp7UeNJev547cSQcytMCLdru/m1U8r+U1 X-Received: by 2002:a05:6358:3a14:b0:176:4c29:57fe with SMTP id g20-20020a0563583a1400b001764c2957femr2504171rwe.5.1706083466240; Wed, 24 Jan 2024 00:04:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706083466; cv=pass; d=google.com; s=arc-20160816; b=oP1jtPfIqWe6qbgVrkGRruM6B60d772aNRKV47PWLZGF1fxEpoY4gnfcdH7U2eMoWf bIJpaPgB02ovL/1/77k0dLJIGXR49huNjFBgOZ3EZDfKMhM94GZxB0rVlFXe9+Kp1JIu XCkJhVhyFFO3ZGrfOZgp7Vk8NmQMFvn/8YDZnnjYcR922kn6hu4qQbLsgafNGm3YTS13 4w2clk67AOz9qGTjH1S0CvLrtZg9AdAMqZyjZ2Hy07aYzhkgQucW+qKrpZ66cVlwoDUu WkHJqX6zF4Q9QP5yao/ClGGcEALOb38hRJpkVVrTXRlUaA3zj2xdyylBtaJ+7tl5w/XW SUkw== 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=sUY8xqCzF/ho9H6VnM7nIW3YTPMmxBLu+pNBzIkIdWc=; fh=EgMSEucgypjvGSqdze11421EbIYU8uUi54sIjJbFkyk=; b=WJNcZ7OKFju9RK9IDB+RlZKAeR+Is775yroYAtVEhHsXeH5NYXnr1A3VUH+mBovoLp ZaKHJxleq+tqUhmY7CdzB32NLI9X7FDIaLrHBn6FLkz4FroUUiSVlq8qA2kWav4Su1NA A4ACbsTaIBNqZWf6jgZUf7LhpSwMBeCRCtBzqsSynqPHzILkDoVk1h2HgMzBjOlXyKkg pL13ulGahSAYJZ9bBVr6Gj/Qc5v4WaLV5/AmIFI7272T9x7OZz18FNBZoyXKHZ6yyciq 8XGC7okfbmEnOH1LwERwFaGPjTSlJKXjMzd6RBJiBihuRDRCokvDKBm/2p32mtD9SG91 NihQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=d9yJYnB8; dkim=pass header.i=@suse.com header.s=susede1 header.b=d9yJYnB8; 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-36590-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q13-20020a63e94d000000b005cee9115685si11222166pgj.496.2024.01.24.00.04.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 00:04:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36590-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=d9yJYnB8; dkim=pass header.i=@suse.com header.s=susede1 header.b=d9yJYnB8; 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-36590-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36590-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A9CDDB235EA for ; Wed, 24 Jan 2024 07:50:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23787171AF; Wed, 24 Jan 2024 07:50:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="d9yJYnB8"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="d9yJYnB8" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 66440168D7; Wed, 24 Jan 2024 07:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706082649; cv=none; b=bVNvzbjUJ+P4oX2QlB9bxfooCA9+FMBxpkmt1dSBOB49xlNmrw3QDKUE4KDYjA785xlUQStxcHvQDE/fJRD/zbXMMcpujj0MaXxQ+p1QQfQHlDOs3dnmDXXvTxAiN83X5Eju2raAPF4ORMwiP4+o/rSMuJ+BphxGEYPeNySu7tM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706082649; c=relaxed/simple; bh=cC2LHOBYxvF1gJoW39qXQupPj84QBL5OBB3dmmbB0Y4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XQYwz3/s64p1+KZUafpobl1iZajrXwRGY2dQOiSAWkOmJH8usnoz1UKk+SBnKJmbPSFkLi06T/tZPKTsV/T3OJXImAD5NfpzHKxxcUUZGCzosxaKX24uD6VMCeAr4CcAZalLPxCzywWHRroNePs3cGipyVJtdJJjjd+DrWerH9s= 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=d9yJYnB8; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=d9yJYnB8; arc=none smtp.client-ip=195.135.223.130 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-out1.suse.de (Postfix) with ESMTPS id 2C8D021EB6; Wed, 24 Jan 2024 07:50:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1706082644; 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=sUY8xqCzF/ho9H6VnM7nIW3YTPMmxBLu+pNBzIkIdWc=; b=d9yJYnB8gVI3nNOhaiezeRXyIDCwE3OFGeee6sYMbH9eTyPTWPGRq6gf/75o5M7uWPSftQ 1ItK3LWFd4chp+82V2UIy8EDmTrYn42Lv1IelQop4bBQJMiUBj8ICT99u3/PMD1maW8bMe wPcoLOpfnPIdANtQ1Q6tjip8lUE7k4Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1706082644; 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=sUY8xqCzF/ho9H6VnM7nIW3YTPMmxBLu+pNBzIkIdWc=; b=d9yJYnB8gVI3nNOhaiezeRXyIDCwE3OFGeee6sYMbH9eTyPTWPGRq6gf/75o5M7uWPSftQ 1ItK3LWFd4chp+82V2UIy8EDmTrYn42Lv1IelQop4bBQJMiUBj8ICT99u3/PMD1maW8bMe wPcoLOpfnPIdANtQ1Q6tjip8lUE7k4Q= 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 098771333E; Wed, 24 Jan 2024 07:50:43 +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 vhqROlPBsGWhXAAAD6G6ig (envelope-from ); Wed, 24 Jan 2024 07:50:43 +0000 Date: Wed, 24 Jan 2024 08:50:43 +0100 From: Michal Hocko To: Johannes Weiner Cc: "T.J. Mercier" , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , android-mm@google.com, yuzhao@google.com, yangyifei03@kuaishou.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Revert "mm:vmscan: fix inaccurate reclaim during proactive reclaim" Message-ID: References: <20240121214413.833776-1-tjmercier@google.com> <20240123164819.GB1745986@cmpxchg.org> 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: <20240123164819.GB1745986@cmpxchg.org> Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=d9yJYnB8 X-Spamd-Result: default: False [-2.81 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; 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)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 2C8D021EB6 X-Spam-Level: X-Spam-Score: -2.81 X-Spam-Flag: NO On Tue 23-01-24 11:48:19, Johannes Weiner wrote: > The revert isn't a straight-forward solution. > > The patch you're reverting fixed conventional reclaim and broke > MGLRU. Your revert fixes MGLRU and breaks conventional reclaim. > > On Tue, Jan 23, 2024 at 05:58:05AM -0800, T.J. Mercier wrote: > > They both are able to make progress. The main difference is that a > > single iteration of try_to_free_mem_cgroup_pages with MGLRU ends soon > > after it reclaims nr_to_reclaim, and before it touches all memcgs. So > > a single iteration really will reclaim only about SWAP_CLUSTER_MAX-ish > > pages with MGLRU. WIthout MGLRU the memcg walk is not aborted > > immediately after nr_to_reclaim is reached, so a single call to > > try_to_free_mem_cgroup_pages can actually reclaim thousands of pages > > even when sc->nr_to_reclaim is 32. (I.E. MGLRU overreclaims less.) > > https://lore.kernel.org/lkml/20221201223923.873696-1-yuzhao@google.com/ > > Is that a feature or a bug? > > * 1. Memcg LRU only applies to global reclaim, and the round-robin incrementing > * of their max_seq counters ensures the eventual fairness to all eligible > * memcgs. For memcg reclaim, it still relies on mem_cgroup_iter(). > > If it bails out exactly after nr_to_reclaim, it'll overreclaim > less. But with steady reclaim in a complex subtree, it will always hit > the first cgroup returned by mem_cgroup_iter() and then bail. This > seems like a fairness issue. Agreed. We would need to re-introduce something like we used to have before 1ba6fc9af35bf. > We should figure out what the right method for balancing fairness with > overreclaim is, regardless of reclaim implementation. Because having > two different approaches and reverting dependent things back and forth > doesn't make sense. Absolutely agreed! > Using an LRU to rotate through memcgs over multiple reclaim cycles > seems like a good idea. Why is this specific to MGLRU? Shouldn't this > be a generic piece of memcg infrastructure? > > Then there is the question of why there is an LRU for global reclaim, > but not for subtree reclaim. Reclaiming a container with multiple > subtrees would benefit from the fairness provided by a container-level > LRU order just as much; having fairness for root but not for subtrees > would produce different reclaim and pressure behavior, and can cause > regressions when moving a service from bare-metal into a container. > > Figuring out these differences and converging on a method for cgroup > fairness would be the better way of fixing this. Because of the > regression risk to the default reclaim implementation, I'm inclined to > NAK this revert. I do agree that a simple revert doesn't seem to be the way to go. -- Michal Hocko SUSE Labs