Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp112927rdb; Fri, 26 Jan 2024 22:18:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFnW3jcLnTsLpw7//Ta0/jLOckZBjiQFcKlQ+EpJ1IaeGvtiCNfn2IxBTvkFEySS/lwfeiw X-Received: by 2002:a05:6214:d84:b0:686:abd9:5d1c with SMTP id e4-20020a0562140d8400b00686abd95d1cmr1148915qve.82.1706336299166; Fri, 26 Jan 2024 22:18:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706336299; cv=pass; d=google.com; s=arc-20160816; b=UgnWJJ0fwumttBE+8BVfCbOdS5TEny2jwPX/N/djyMbtNLI6mRcVSOS49Mq0dRRGJn KbaYlZx0mVoK5PTC6OZ5HWFbNWE3vJcKmAffCk0BRWaqEK+cwCdzJTqhr58T30LQQQQ7 d1nPNdDfLoPc4RzEhIvqfukDMH6GJuq9o0TORp9Np6mBHp1PeMvgzvVvOlMVEiTuZBWu 7ElXhPdyr9wkQHsjm5cathANuUFRlBJDAXrkS9ilVbwHGTl1XpoDNjitCpxvatSGF/Pg fB66Q1AA0HMbymGxyr5a6Ps66wwvFlpWdqVj/oXOYPXGgi2stVZ3VKh27Y1FZ6J2o+MF A/RQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=rQS8ABsYVYk+vXzULL6wVLsWJRItyzMNzDk9tNnAZhk=; fh=fC8KGgybcOMgtrthIp2mDh67dAgfG1xtg9fv5/mBT2U=; b=OHEGg3dkDu34TNTtqaMGTTy6JdvZNj4znEBG5MNJCGorDelIY/Sf8AjSegLPrgAltv quS3umuBUtZzOFjAn51HOUxBtFzU379z0r5bGpV5lP1EGIyQhapR3dfbF58cA0kbroys 48V282gi6LCjrObtVYuH00cPRqulqNGtNRThoWecdqHwHchHf3jRmCciHe9WX4+Mc4bt VtzFeo2YOziOqJVB1jgq8Ba9EdLYWvvFAObMJ+phrE0DRkr2XtxqPygaAxgKLrKVJL58 CP5HAmAEQFdbXOzXuSiUsWOSg9wEMMtxIqxKxA56KjBZ/SH34FenACZNdebojikxvaAP Oprg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Z9l+dhbg; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-41077-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jz13-20020a0562140e6d00b006816f4917b2si2890564qvb.615.2024.01.26.22.18.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 22:18:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41077-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Z9l+dhbg; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-41077-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 D75241C228AB for ; Sat, 27 Jan 2024 06:18:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A74914AAE; Sat, 27 Jan 2024 06:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Z9l+dhbg" Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 8A23B14263 for ; Sat, 27 Jan 2024 06:18:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706336289; cv=none; b=s5kUWxeVD0sdWJC1B3rQJ0ToU6RKuBWM46yuWusReyzXfSOokBH9yNjeBtBsDOBVKMTx6+UXCwHfImTEH/oXfRUiKsy+lTo7zI+Adx6I4rV1NxuTqMIbcEISm8RotUSO+/UxZpV3QiQ7SkeOaXqV958pP1XudikEskuQGL/+PF8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706336289; c=relaxed/simple; bh=w1/OgqChEj6StyqlrSu+Vzw7cQuKvUK042Bi/JTM83w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ebO8GFOFChHN37sy3NlB2fKIo50aPG50IXtaTwF4//YIzEQGGSeXdBqbmcJP01bfEz9KI1AfAWbHY3Xqc7l5mrtCIZ5yAOineZLVs6OT20MKCm++wrSuMo/wXI96+G9EJqVSrU68SQ6m1zQMSNjEjejkjbDuonyPb8MA5to/urM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Z9l+dhbg; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-55c24a32bf4so5015a12.0 for ; Fri, 26 Jan 2024 22:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706336286; x=1706941086; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rQS8ABsYVYk+vXzULL6wVLsWJRItyzMNzDk9tNnAZhk=; b=Z9l+dhbguPn2nvzsDvFFauhRtnuLgvL0IcyvcZjffL5MOAMn+oeMIjBR/RyVGFK4sJ Nm5mXOUTbR4Rf1VF1GLNxsDknU7tkCJtxaC9p5QFivTHzSwCFtXndZMtxO6zybi4zPbO gosWSzD8bzMOS7gSYn1RiDwAl9uB2eFUPtFRqdh26m9qsb248pfdQ/ajaVAOpMZP2Xeu xwTe9QBLTV/QGUNIhmC76T5ReizHSFuCfPgyN8OIwkrGlizzOOWk6Kzm8PuN4yHRGVl7 OVar4vmb3r/dviwuXbOwlKvBBS6uU4NW+3qaARFZ1e26oTHGdye8o92jCb48CMtvnAz5 JInw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706336286; x=1706941086; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rQS8ABsYVYk+vXzULL6wVLsWJRItyzMNzDk9tNnAZhk=; b=rtpmghkjXlBiySS7OBWvPQ4TAvMpAMIvI9he/BzH+eGOXlCxqPouWkkE7GxEXejmO1 ioKoaU8TnU1MVztvDdgESG5dXOJ0f92nAe14Yl8pKtO3zMsISlKPSLO/Jbqd99gLngP4 ocxA8rfj/jsnc0lDwD+K6LCLynsbXs9JI9i0mLAu8Y9m6DiPcFm/7mzqmVlVpZnMPNcs yjdrFt2OwpopRzwpBhOnFZLblqRD1cpFzGXqRT48iKpjA1a0DUO3PLWh9Pedsb+vLLUc MiQq/V31NZte47gZ6IZVfJsDY2gVVECbMH57n7wsnGIT8TqBLeLX2+FW+hMD2ZjTcuH1 Gpsg== X-Gm-Message-State: AOJu0Yy88U0sk8jiE0boi3wq1BEIu/FXQ/2Y9itCfNDaX4WqvHaTh+MD V4V91gSt9uDeeSBe7J0hVSitzaKYmUf4V6JkLdGRdW2/LMT93ZrI/GhccGXjByFh61fGo8rYG7s y7oxNPiNL6uSvf62hsgR1lOVT6rLkMkcIm4Mw X-Received: by 2002:a05:6402:2281:b0:55e:b62f:6eb6 with SMTP id cw1-20020a056402228100b0055eb62f6eb6mr27532edb.3.1706336285548; Fri, 26 Jan 2024 22:18:05 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240121214413.833776-1-tjmercier@google.com> <20240123164819.GB1745986@cmpxchg.org> In-Reply-To: <20240123164819.GB1745986@cmpxchg.org> From: Yu Zhao Date: Fri, 26 Jan 2024 23:17:26 -0700 Message-ID: Subject: Re: [PATCH] Revert "mm:vmscan: fix inaccurate reclaim during proactive reclaim" To: Johannes Weiner Cc: "T.J. Mercier" , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , android-mm@google.com, yangyifei03@kuaishou.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 23, 2024 at 9:48=E2=80=AFAM 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. This is not true -- the patch reverted regressed the active/inactive LRU too, on execution time. Quoting the commit message: "completion times for proactive reclaim on much smaller non-root cgroups take ~30% longer (with or without MGLRU)." And I wouldn't call the original patch a fix -- it shifted the problem from space to time, which at best is a tradeoff. > 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 incre= menting > * of their max_seq counters ensures the eventual fairness to all elig= ible > * 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. > > 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. > > 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.