From patchwork Tue Feb 28 08:50:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 5926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2904688wrd; Tue, 28 Feb 2023 01:12:40 -0800 (PST) X-Google-Smtp-Source: AK7set9DodcWlkc/NbZ8PpfBP+pDRppnGcKzPmAK6rX5ev9k07epnVC0udGwGoxm+YVEBP2nmehO X-Received: by 2002:a17:902:e851:b0:19c:f16c:5cb4 with SMTP id t17-20020a170902e85100b0019cf16c5cb4mr2535044plg.1.1677575560509; Tue, 28 Feb 2023 01:12:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677575560; cv=none; d=google.com; s=arc-20160816; b=XivZBOwXDRnX9QyVyQv/qc3ccAE2dFkH/h+NdMizWNMGLqxB882cN0ByFRNb3q2KoE WIksInx3qXcN91PEjhy0aj5KzpKxrg4qMZdiOtdcXJwb24tsxQO0YvJabN2+1cKXqqeV k4wc7hJJEvXewqxEJq2iGmzz/pfkgYg9JqA9cA9S2LSuKb5jYvU72WJ0xpW34MoLatGN FMz0GczFpds9Ll+lFG/Tvsw1Yafj9G9XxuKBJ6MN/4107d/MpTiOFbr5aAZDHpL80u0j alAmshLpWOa5hKrNi3WV6yYZGPeIlZY75y99GsjiXc3AxjGC2W0ETQvK8WOq9RwJOS+l ApQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=xdSAVrwCtkhEWC8GgYYqKMfIX8yBwrpfZDbmqtRyDyA=; b=HrMjEczmbvOTyl2laQrafxImEzWeMOoWnLfSwYJM35hgLsT/70DJ4IHz2PyxFwX1Xp pLfzh7sVNPOaonDzRmut1EVjtrzZgQqhiYVEEPWqwummnyopMn+95OdVMmDw20kQjjjx Sh+90sFhCgnqZnPFTb0pdlloZPDeWFuPPY2ozLtllb8d1Az1lGnh4u/l4/Qj3GsjGnZM Qt9ZbsROGDI8wd4rf2ko4jd8Cn+qWYWk8JMJ35md7TIKRTFKA/Gw4oQUNqa+a8FVssGZ lmYVyCplOgQXRRNW5hgkuz3xXwg60k0sc4rsMxRXW7ovldFP1oXRUm8XNW8RWvW+PYtV IRbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SOVV++5Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jy14-20020a17090342ce00b0019aa6d30d52si8864589plb.155.2023.02.28.01.12.28; Tue, 28 Feb 2023 01:12:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SOVV++5Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230383AbjB1IuS (ORCPT + 99 others); Tue, 28 Feb 2023 03:50:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbjB1IuO (ORCPT ); Tue, 28 Feb 2023 03:50:14 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E36C9EC57 for ; Tue, 28 Feb 2023 00:50:06 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id i11-20020a056a00224b00b005d44149eb06so4808298pfu.10 for ; Tue, 28 Feb 2023 00:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677574206; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=xdSAVrwCtkhEWC8GgYYqKMfIX8yBwrpfZDbmqtRyDyA=; b=SOVV++5ZdqitZ36JKIv2fFMUIZWr2mRvM+1SYrMDqxcU64YKMcyXiXS7/JBzrMzVGR a6lwTwArMZ5cvyX8urVSHUrUuVQOSfF42XGvNomA8Tvnp0LV06/wsJWl0LMz4W76Db5h y3jUa5jifEAMLoWLF0Zr9sO3rNX27weBBlTgPK6tlMagy9lhu6URapPi6JL/AiWDq+/O xpiOl8e/9NHV1lIOw2MgMwgF5M6/In9pOSbo61IAhJJdv/IGVjLeA7M8iH+2ekiFYHMp H9Jqpmo7RoeMES/COvqdvDIkncurMcMLwWiPU0V57IM51nNJ+lMIpEBY3rU7HFrTSgtB lU7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677574206; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xdSAVrwCtkhEWC8GgYYqKMfIX8yBwrpfZDbmqtRyDyA=; b=bd2vVjnnolo8vCezWag9JqdUXYKvv24fWtc6WOJIRO6Tu812Jbmo1j22Ol7bG8+ReV cJplR51b7NbGtTqWuRfhwq/6KSiTMQgSkyGYGgV50RBFVR3pRHB0WvhGIY9Swh9BBzK4 OzT0CEWEcXEBHzNMRbPGl0y40UYcX6L8ljj+0rrqDjgm3CUozCmBrGwyLWa4OqugVvVA 07OlA1671RCk8hov3itcoMZZBlx4IKR4GgXly7wH4assXaseDpngoRKlngGpjL6lT37K vNegHA+/htNBPK7Tbppay6FGOGLmL7J+tO7FwYT9VuocAoz4ofc8NNL+Vd95R0h40OxL tnxg== X-Gm-Message-State: AO0yUKXzuoETbP73c6iSxJIUQv5kAv0u65ZqyjTHw6nK8DN+zvp4vvU/ 5CfDaF8V1WjJTJgCqzWlANw+r1M3WWRFFDc4 X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a17:902:6bc5:b0:19c:fc1b:e600 with SMTP id m5-20020a1709026bc500b0019cfc1be600mr684030plt.5.1677574206196; Tue, 28 Feb 2023 00:50:06 -0800 (PST) Date: Tue, 28 Feb 2023 08:50:00 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog Message-ID: <20230228085002.2592473-1-yosryahmed@google.com> Subject: [PATCH v1 0/2] Ignore non-LRU-based reclaim in memcg reclaim From: Yosry Ahmed To: Alexander Viro , "Darrick J. Wong" , Christoph Lameter , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, "Matthew Wilcox (Oracle)" , Miaohe Lin , David Hildenbrand , Johannes Weiner , Peter Xu , NeilBrown , Shakeel Butt , Michal Hocko Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759065471076770504?= X-GMAIL-MSGID: =?utf-8?q?1759065471076770504?= Reclaimed pages through other means than LRU-based reclaim are tracked through reclaim_state in struct scan_control, which is stashed in current task_struct. These pages are added to the number of reclaimed pages through LRUs. For memcg reclaim, these pages generally cannot be linked to the memcg under reclaim and can cause an overestimated count of reclaimed pages. This short series tries to address that. Patch 1 is just refactoring updating reclaim_state into a helper function, and renames reclaimed_slab to just reclaimed, with a comment describing its true purpose. Patch 2 ignores pages reclaimed outside of LRU reclaim in memcg reclaim. The pages are uncharged anyway, so even if we end up under-reporting reclaimed pages we will still succeed in making progress during charging. Do not let the diff stat trick you, patch 2 is a one-line change. All the rest is moving a couple of functions around and a huge comment :) RFC -> v1: - Exported report_freed_pages in case XFS is built as a module (Matthew Wilcox). - Renamed reclaimed_slab to reclaim in previously missed MGLRU code. - Refactored using reclaim_state to update sc->nr_reclaimed into a helper and added an XL comment explaining why we ignore reclaim_state->reclaimed in memcg reclaim (Johannes Weiner). Yosry Ahmed (2): mm: vmscan: refactor updating reclaimed pages in reclaim_state mm: vmscan: ignore non-LRU-based reclaim in memcg reclaim fs/inode.c | 3 +- fs/xfs/xfs_buf.c | 3 +- include/linux/swap.h | 5 ++- mm/slab.c | 3 +- mm/slob.c | 6 ++-- mm/slub.c | 5 ++- mm/vmscan.c | 79 +++++++++++++++++++++++++++++++++++--------- 7 files changed, 74 insertions(+), 30 deletions(-)