From patchwork Thu Feb 2 23:32:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13126804 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 3528FC61DA4 for ; Thu, 2 Feb 2023 23:32:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 926566B0078; Thu, 2 Feb 2023 18:32:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AEEB6B007B; Thu, 2 Feb 2023 18:32:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 728476B007D; Thu, 2 Feb 2023 18:32:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5E9166B0078 for ; Thu, 2 Feb 2023 18:32:36 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3E386C08EC for ; Thu, 2 Feb 2023 23:32:36 +0000 (UTC) X-FDA: 80423953512.09.B313D78 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf18.hostedemail.com (Postfix) with ESMTP id 94DA11C0011 for ; Thu, 2 Feb 2023 23:32:34 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=q5PqSQK+; spf=pass (imf18.hostedemail.com: domain of 3EUjcYwoKCDgsimlsUbgYXaiiafY.Wigfchor-ggepUWe.ila@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3EUjcYwoKCDgsimlsUbgYXaiiafY.Wigfchor-ggepUWe.ila@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=1675380754; 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=wvPcslomLoHkLO8Yc6SUQeV30+piSf1wG3UvD93eRjk=; b=lc5tyM0sSszrhvrjoEGaeCH6PU6f6PXmxeMY+GZLYCXl5xTmnAz5POUa/b4H5b8lFRkTJE ufEv5AqI9QuulXMrZrr+f7leYaFMMZCD5UZROBsLN4X2iaDoUrFCLxh8+Mabc+ywhKnLQS O5OC3O53PDJFM8kb/A9K5vJlV/qqd0E= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=q5PqSQK+; spf=pass (imf18.hostedemail.com: domain of 3EUjcYwoKCDgsimlsUbgYXaiiafY.Wigfchor-ggepUWe.ila@flex--yosryahmed.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3EUjcYwoKCDgsimlsUbgYXaiiafY.Wigfchor-ggepUWe.ila@flex--yosryahmed.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675380754; a=rsa-sha256; cv=none; b=PWgjInmxh/6Fk12LY+/tT9lsNOWZH103F6uIG71EAkJmhXLtbbKVQxVZtNGbrsPVFZ+DEH UH1u0wbmoRwf5TtZQGcygZNt4TG2uIVtNrH4tGMLR1UyOdxbK4Q6yEV+ebGpQu8JCLWpjV Zz4f/kBk5C18ahXcHK51beGIzq4EDTA= Received: by mail-yb1-f202.google.com with SMTP id u186-20020a2560c3000000b007c8e2cf3668so3222434ybb.14 for ; Thu, 02 Feb 2023 15:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=wvPcslomLoHkLO8Yc6SUQeV30+piSf1wG3UvD93eRjk=; b=q5PqSQK+++lHtbhZUFBCU+x4zpvrGh4pIKNqDt3jPaMwOvRLITz/8gh2vIwvbOGDXn FHL9NUVDmtVGdSCj3mFBi6xfSbyUqEIbfHvKMj5uruVu3bVrC4szl3SkUVxsmgJJdA73 f0c3SqPtAbMisWYNFJZMbClTUB/2DVlUqbm73mTLpJAOTzCvliRc8Ua1t33hUrwY3x00 s0Bvg1ekxl+6tcU7L35HzxkbHl9Lbf25lU7EViogFcVu6T3rEY/kyMhRQM2LWbU1A9Kn elaobooFLoeTUYtg7Z9LZd33Y+HOrY2Gl7eapgrfYntF6Elpt+jMwqYKaK3W3qIDHp5q /cHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wvPcslomLoHkLO8Yc6SUQeV30+piSf1wG3UvD93eRjk=; b=ijymkLAoWzzKFlpPigna3GeyNNue3UurtipSlZejbJDELRaT+si4ZQpJ7qBmyUy/gP eC7rYyppwnPRJx09rzo2aQllmp2zs4WYdcKeiPIqglRxdRqGuAjOrok9HTxeViYCTEP0 aN4yAXmC6k1Toq8gFTzHt0Zvd5xpTQz4Wr1lFHh9d/t8urtAqWnYZcMZLLvPkdxAqGuP Zmkg6nCjyN5MUCym+4GZN8xitMADBQndQJyWgjNoDjKAdu2c1zjZ8RGCs4Zs9+Iu6d0H MSaY+J+tk0ERlCIrfPF2n9q9/65QGcUgag0yuw6gP9Iov3cAhesCur/cifzq4KynfppI ss6w== X-Gm-Message-State: AO0yUKWQOSngIJWkUVQVzXUVUtxpUjgY7v7rlqLuweGHQJLFau5jkkgs K0vmf3kHtWHaGLbgy2ftTxcuQcpnqqsKMTx0 X-Google-Smtp-Source: AK7set9kUtHsaRY6uXu6dJRkVwBjqCpF4UUcFJZVMG6LU7esmRkQZlJLDYJYrU6vi4GT4w30ZHbokAZ4HSwiHzRk X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a25:9e90:0:b0:866:b2a0:6e9d with SMTP id p16-20020a259e90000000b00866b2a06e9dmr104800ybq.203.1675380753703; Thu, 02 Feb 2023 15:32:33 -0800 (PST) Date: Thu, 2 Feb 2023 23:32:27 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog Message-ID: <20230202233229.3895713-1-yosryahmed@google.com> Subject: [RFC 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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 94DA11C0011 X-Stat-Signature: txiffxf5c8y3gwa5cx8fqbjhq9kruk1i X-Rspam-User: X-HE-Tag: 1675380754-964553 X-HE-Meta: U2FsdGVkX19Ld9A6scHBH+RBPqVr0rsBLb2spHkB9SvoQn9bRFMq3FK+LCC/3HLNgcEi65jN+AppUnWRexwXdiT7Ni2OnVJ4S8RLHBHq05GBLRzyqKv2KKBAaBO3KzEMxdcfX1/cz43Jr9IfmLexmwL7N7+bch/ddUxIOUoCJMMmLHGPdMMuhdIiHrwN8/fOwbuGxUirgz9YixjqjuE/f1bklwthNPybQN1jqJQUZnWr29mTh40ATW5NphxIoCtYCfOXzPJEeaRpe/gQ/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/SZTgJ5RaWEHpxb3c8n0Z7+FcbWUi+dLLhjbIKUnLXjrC7qdmb59VMwCaorn8+3BZEjSzU4fT1kc9U3Z/9UvtDoYzgdSE3WS0RxflKp3ZnJIeib+mIVMhhw6WtJqNZNT8Og/tP7hS+0MhHKRJD8LszYx14a94CuMSocx7PFlxtwJ0dClAf3Mue7WPhfe+lr9jenFLwZNzi0sfov+ilONDk5SQpiT3KsPBepfAQu9K66HMaRQPis67RHQkxXMwryawuzccYzaI8MZuGT02tuxgK1UtQuuCx+55NTARRg4J/P0rQAHU/97gSUgjkQe934N7EWZqcD9xx/XsH2DT+Qrus+CC6ifcgjtc= 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 original draft was a little bit different. It also kept track of uncharged objcg pages, and reported them only in memcg reclaim and only if the uncharged memcg is in the subtree of the memcg under reclaim. This was an attempt to make reporting of memcg reclaim even more accurate, but was dropped due to questionable complexity vs benefit tradeoff. It can be revived if there is interest. 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 | 19 ++++++++++++++++--- 7 files changed, 27 insertions(+), 17 deletions(-)