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: 13154533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DBECC64ED6 for ; Tue, 28 Feb 2023 08:50:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC2A46B0073; Tue, 28 Feb 2023 03:50:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A73FF6B0075; Tue, 28 Feb 2023 03:50:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93B776B0078; Tue, 28 Feb 2023 03:50:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 806396B0073 for ; Tue, 28 Feb 2023 03:50:09 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 40198A13F9 for ; Tue, 28 Feb 2023 08:50:09 +0000 (UTC) X-FDA: 80516078538.13.6DF5DA8 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf26.hostedemail.com (Postfix) with ESMTP id 8BB9E140015 for ; Tue, 28 Feb 2023 08:50:07 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=SOVV++5Z; spf=pass (imf26.hostedemail.com: domain of 3PsD9YwoKCNsVLPOV7EJBADLLDIB.9LJIFKRU-JJHS79H.LOD@flex--yosryahmed.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3PsD9YwoKCNsVLPOV7EJBADLLDIB.9LJIFKRU-JJHS79H.LOD@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677574207; a=rsa-sha256; cv=none; b=BhOhgE+8Vj59Aq3GxVx7cG5vWYw0n0XVijdOLQFxvH/LQk0b4nhSByDK02NO6nE/6dfQdV U3UsFmFbIul5qc+flKjWAOIQ6FkakhAiYwy7A1LSqCR+xkFE3784o+w0soG4ueugkUFVHc gMD9+KD+kAnj54bZndSGU5XfvDXvnj8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=SOVV++5Z; spf=pass (imf26.hostedemail.com: domain of 3PsD9YwoKCNsVLPOV7EJBADLLDIB.9LJIFKRU-JJHS79H.LOD@flex--yosryahmed.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3PsD9YwoKCNsVLPOV7EJBADLLDIB.9LJIFKRU-JJHS79H.LOD@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677574207; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=xdSAVrwCtkhEWC8GgYYqKMfIX8yBwrpfZDbmqtRyDyA=; b=HxZ1htBpUWoqE0qOR1+vz0aCeChWKZE+uPa7noh7P1uY+45XhMcEEvq3W/vtBJ2YbCozpm Gjj0wRbMXMDE7Z2aOvkmZe7n2W56ydIPTf3j4MNHDbGsodatduLStHolwJlIuGc9vAAZgV xZMMdqnmlpzRN9Agj6BVHRwWfl4WqMU= Received: by mail-pf1-f202.google.com with SMTP id 202-20020a6218d3000000b005a89856900eso4794870pfy.14 for ; Tue, 28 Feb 2023 00:50:07 -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=qT7FPyxt7WqBHtwAwjXXwoUkFioc2b1YBdErVFKuY8jzjKpQiUljEV6NYKA7QGaJql Li7MM3tCnXM5pBdYl2Ak8XdySTbntF+mpUtegkd7KIH3Y6za8JlLuiwOmFc5pkuOTAI3 vMquhI6BaWN+VUWLW6kYAifi1QAuixk0tX9HK47iR5zNIuxcfipp3bh0nhjk+Z7NkIoC /R91T6hisnxfVOQrDoUoU/O9R04YxMt6UaRcovbkbyZxmdKZpQXoFWCrcr11KOhHZJ/X 86Xbuys+ktVJpXX+J7+RiUO8E/uiU5lfb+kbDMimnHquZDLE8B/3PSHp1QmrGTEd66nh 8UUA== X-Gm-Message-State: AO0yUKUpX2CAYo+Iy4vRyZ9/8Ia1KqMuwE23BkUbpeXxJDlz1IT+jQhb a8MjArN/ruqmaUNtRpYoT50hHv8YWbtSIKur X-Google-Smtp-Source: AK7set9xyaSEGINDP0JdrxfWpmvgvG2OFkld3cb1qL57vscSNy7S0nejYo/cjvFVY+VnsY2ooCNyScP6qk2951NZ 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-Rspam-User: X-Rspamd-Queue-Id: 8BB9E140015 X-Rspamd-Server: rspam01 X-Stat-Signature: bdmuharytgcwch64bupkym7pkndb9ebd X-HE-Tag: 1677574207-9030 X-HE-Meta: U2FsdGVkX1+Z7Xxb5tGlEkpXZIDYvpV0tbHlfpJ7lqGnKFK7uf18cNMNq1eSQjBedFhjqFkQylBt56UeH/7bW1ObKg8GvYU02cr0VTiFDHN/jz8brmci10GTBn5iLoWVtAf6PuesqfmQUpp9igMNUJn7yt2J3yHv8qcCp/TwLOrX18QNsw24DCEQOb91bJMiKaVqNMThD5TNJKv0DAL3xeiJevJP8QYNxuvEZIEHUfwb6eM4SJX7dRE4zMnW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qjwtZnU/ZnNwwkRPKbP3JW0286FNPqAIdz+V6pmwuP8EJrtisgJra4v9t1SLGWqFZV3XcP18reo13KQnYGEd3K/6pkUoryJTI2ORGhclBi5Jv4qTnqaTEVds3ymIJdWHCSwWIzcuOdw7fbAA44t7SYjBMMC/OWFAxNBK0Qb1zakXe50m2llrJxUsNr/6G+axPuxRPkWGoVIQ32DCrDsxqqPKzea3qP+CtaxauPUjhgHP/Dbn/Inleymbf2SXOl42mNQJW2qJmLfB1Ij5OZLv6+13MZHRt2NswnCJwf5FF0Kf5xzr96vXOgg4PY2IGcUDvUEO8uDXHlIlc+F6OVJ3QUioG6jZrFdfeBXRGQ4LlU5bbL/1oNvY4Kck7Ba+Xolrmp8HV+E= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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(-)