Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp2240041rdb; Sun, 21 Jan 2024 13:44:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcMMAZWvOetvKLy1S8rdRSPXFhMTLF+2lic0iB40gARk0KwnXC/RDhrIeZgpiHlO/8QWoi X-Received: by 2002:ac8:4e17:0:b0:42a:bd8:7d27 with SMTP id c23-20020ac84e17000000b0042a0bd87d27mr3818010qtw.60.1705873481812; Sun, 21 Jan 2024 13:44:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705873481; cv=pass; d=google.com; s=arc-20160816; b=LSS9qTK5zSeKxzytfBY8j1TUYA20TMAWLGq7mPvb2cQZCyT1hFbgIMyO7XWG/75ClR NWXiMJ0JBmnB+upMWwL6SDIYrlOwww89BFVUkSH4bQhj9STx/owmFfhS5RFBaOcK5cMh w9ZVbLtd2J2xKySRMObw7Q3WYd3S0VF7X/o6jyFtBbZBCUcHFZ7kV/1TvhZr+2N/085M tE+4JmzTJh8SoNpLD2UwySbESBPcHpZjPe3VnAxlXVzMxD06BfQJBnC9lOcG67GN6x2G P00qNCW8kXVkk7UJXp0vrIaiBg+6X3uK6CbI+jCL7OYHTfyZbNZVeMrU/wqqiDQ3/lbi B3Kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=42CVSiV7dgut5spnJTiZryp5KS2ThmG9GG1m+AnlGQk=; fh=8SOEPYHiX2SkQMu4DWrrQSAZpruKoyQ2vJMHppJwDT0=; b=DnkuhM2oRnl3PCh9+nkTA58EPjkYr3rUzVoLF8Ut/8R5LY8F9/8rs/I4V8AFh3EUO4 FO+bLdacDI70IT+8yrVIAEVhnGD0SclL4nda15bwYOyco5un5oWvdrgbSucdE2qIuQ0Y U3FaZ+ET0SttBGI4dtOty8mmCfsZgx8uqFNTGRGtbRIBCnm4uofScL16Q3Y2OhJzaBoT bbEIPQgG6MrIyweQK/ZEULTdZ1g21gch/TyIWVxi9aNYXwdhu5082NW3cTD1KCdowrIQ tbLSNdYj+ZzWG57jXJK9WQBT1vyLL1qG5bU7HJ98FYGUq4cJNf46Rg3/z28k0Wwxz+2k iIHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zFC7YGFg; arc=pass (i=1 spf=pass spfdomain=flex--tjmercier.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-32193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32193-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 i8-20020a05620a248800b00781706eb820si3420770qkn.196.2024.01.21.13.44.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 13:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32193-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=zFC7YGFg; arc=pass (i=1 spf=pass spfdomain=flex--tjmercier.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-32193-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32193-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 8F9281C20A46 for ; Sun, 21 Jan 2024 21:44:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A660838DE4; Sun, 21 Jan 2024 21:44:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zFC7YGFg" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 E29EE1E49E for ; Sun, 21 Jan 2024 21:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705873472; cv=none; b=r0bJlxX8efIItJ74eWMSXX4NeWQ37IyUt93oZrkmrL/VOtkFL3cQGZ50v5wA9lFVKNVv6cPVi31LFw5tWtcvo3h4hCNA+Cjf1e7i0eL/RInvjp6i2pLDWQRLGSf4YuhuPfn9sQLrnjtEtqIQCXCqD+kDhDATtqJIfGLvnQXBxK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705873472; c=relaxed/simple; bh=6sK28xbIZX8Pa42yZVUnnO4tegkf3aHV2JBuABAaq9s=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=SCCQEOgNjW6dJniWbC8qHQdxR3RI9/vbZ7+l3GiFmMh1u6j/T55QJZPhk3jpkptVlOrSYZGgLLmScucHMiHxUxL69tmA2s2pQInxUM7uxCuf2Nk8eItFkD8CC406bB9fxDgz+54rSye860Rllg8wc/+yIyl1soSYOoSgGBmbwJs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tjmercier.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zFC7YGFg; arc=none smtp.client-ip=209.85.219.202 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=flex--tjmercier.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc21df30950so4272577276.3 for ; Sun, 21 Jan 2024 13:44:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705873470; x=1706478270; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=42CVSiV7dgut5spnJTiZryp5KS2ThmG9GG1m+AnlGQk=; b=zFC7YGFgTUSe4o8g7OvYXif2sQvVT8ZClTIuaKc5LJbfZPUwj/ia+tc4XAQRJquY9q 205RcDZZul8Q3IZUaPVh04dj9IBR1iFBTWrtaEFWMILFl7/lx4IU4/xtIaWaen4XDdse hxUsvjE9OTGhh4C1N07zqJvrJiCsHkaSMgzDMExE0WUJgLroFYBLCxM2xGS7Lm7ZMC5m 8GirrynXqk6AwZ1s2Lar2rkbHW7hwKJPV3MnHYS1rikEbf+skHmvx6YZlsxcNUEa966N uTMx3w/7taxXjailSNpL7eakJ9JolsxbmXxZwYTLRADC/OcJS+GH/dQh2pbzZUt02U9a iyug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705873470; x=1706478270; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=42CVSiV7dgut5spnJTiZryp5KS2ThmG9GG1m+AnlGQk=; b=AzHk7EsSDG1iejy3h/y74Fu9t9foFuUmuT+ES3bFGCwZRfcNJFq9qgJuoaasDFm3G5 Q6/pC9IDuIoAx7Lf//Loio4zTau4QGScjStGfXBcts8JUkgG9ku8UX5TtBt/arrhqga9 5ddAyjyDCbGgJOZVjW9ToelT882RuYRf1eqEA0bF13ODB1/umJL0Awf2Y2T64zBWj/J2 OUnLp/ON+6s1FiHj5U+YMAhLMo0cvVrNr8x5DGv6xqoQ2BrIvmqFAqZ/xxX8pzELj5tB ZK4i1KgYIT+YE14veSaDTavJ6VkXaA0wEHquVeF4RgqvdKBPmVAkAQTibICmzto1lh3d C0kw== X-Gm-Message-State: AOJu0Yw8l0ffziHERrb42gt6iy9pOJnZZWTmBkuoGEFV72n+vi2dzi1h b0VrepS2+wW15CDqZJGRgYeKRJt+pYwz05GRnXdFB1oVuaGYV9d5bTONltVTJ5N/NlpCw2bxPMd MSziomlzhAKAiuw== X-Received: from tj-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5683]) (user=tjmercier job=sendgmr) by 2002:a25:8204:0:b0:dc2:2179:5f30 with SMTP id q4-20020a258204000000b00dc221795f30mr1531560ybk.1.1705873469887; Sun, 21 Jan 2024 13:44:29 -0800 (PST) Date: Sun, 21 Jan 2024 21:44:12 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240121214413.833776-1-tjmercier@google.com> Subject: [PATCH] Revert "mm:vmscan: fix inaccurate reclaim during proactive reclaim" From: "T.J. Mercier" To: tjmercier@google.com, Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton Cc: android-mm@google.com, yuzhao@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" This reverts commit 0388536ac29104a478c79b3869541524caec28eb. Proactive reclaim on the root cgroup is 10x slower after this patch when MGLRU is enabled, and completion times for proactive reclaim on much smaller non-root cgroups take ~30% longer (with or without MGLRU). With root reclaim before the patch, I observe average reclaim rates of ~70k pages/sec before try_to_free_mem_cgroup_pages starts to fail and the nr_retries counter starts to decrement, eventually ending the proactive reclaim attempt. After the patch the reclaim rate is consistently ~6.6k pages/sec due to the reduced nr_pages value causing scan aborts as soon as SWAP_CLUSTER_MAX pages are reclaimed. The proactive reclaim doesn't complete after several minutes because try_to_free_mem_cgroup_pages is still capable of reclaiming pages in tiny SWAP_CLUSTER_MAX page chunks and nr_retries is never decremented. The docs for memory.reclaim say, "the kernel can over or under reclaim from the target cgroup" which this patch was trying to fix. Revert it until a less costly solution is found. Signed-off-by: T.J. Mercier --- mm/memcontrol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e4c8735e7c85..cee536c97151 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6956,8 +6956,8 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf, lru_add_drain_all(); reclaimed = try_to_free_mem_cgroup_pages(memcg, - min(nr_to_reclaim - nr_reclaimed, SWAP_CLUSTER_MAX), - GFP_KERNEL, reclaim_options); + nr_to_reclaim - nr_reclaimed, + GFP_KERNEL, reclaim_options); if (!reclaimed && !nr_retries--) return -EAGAIN; -- 2.43.0.429.g432eaa2c6b-goog