Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3094386pxj; Mon, 14 Jun 2021 14:21:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhnu+W1Jk+JWr6q05Lqp1dlRTuQIQDY5NTCsaPAqiAbkoMhSQ40pqGPfCWNI1KSF2FYfYy X-Received: by 2002:aa7:d785:: with SMTP id s5mr5905300edq.19.1623705713805; Mon, 14 Jun 2021 14:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623705713; cv=none; d=google.com; s=arc-20160816; b=PQiCSjaR4ahoyJoJv48kq3nyqgUaX3O9fc5bGwPA1+VYf7N7FSATuX/Ia3+UpYOGNB lLCNOLdghwlj2YhXF+1feVI89e0xbiF+MjUBdGWHbf6iIVUnyUC9rgMA4hIz4HKg4LSN iR2ppn7GkRWqXuIrCAK0fxjkJBAtInOnqRNRucMRgaImWJedtyGYoFsVa+vbAIupQzDE TwHSaOcW+n7eJy1G9ncKPJg56Or19CDMg7ky+i1m4auu7VecBIMdg29OdjfHcvFCzEou kuYG3lp34OVfILXFslh/zRNSy9tyxd5x0XnloeV6zmUoST+86XQj4+vK4XLNaTRcdhZw vpUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dPrRC5GgzYjCmG/sOcyalcGlRFIg9CpzRtffxeyBsJs=; b=SDPaCbSKiePJ2eo9SRTVbzDbjbnD9QP3++39ztZdUdo2Z7UoWW06JE9y5OLiqKMcJ0 e9zlksIjUX67WDCC+ygIGF3b8QkcH9jA5SkkGPg3NJRHaVY0sJPMBqQWzu1VJxapydOZ yFAWJwPFBPaPAIjReHXLMscCgVI2QEMZcdTnJpI2Vrc8A6Ry9ax4CbTdkzEbaU0JW52Y D4KlrjPu4DO34nsVyAD3/qWQ/4dTBnpYbOf05rs5udw17BckVYEIKE9rI2rttlYc/ce/ wbxLwx7z/bIKMTHBAAel9KrMvyUGDThQtkG5UeudPsaRz4vXbsKqmmsEfIYacbnR7IFW ijhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Cq8Kh47l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id be25si12850386edb.359.2021.06.14.14.21.30; Mon, 14 Jun 2021 14:21:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Cq8Kh47l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235072AbhFNVV0 (ORCPT + 99 others); Mon, 14 Jun 2021 17:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234866AbhFNVVY (ORCPT ); Mon, 14 Jun 2021 17:21:24 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36A92C061767 for ; Mon, 14 Jun 2021 14:19:09 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id f70so24723849qke.13 for ; Mon, 14 Jun 2021 14:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dPrRC5GgzYjCmG/sOcyalcGlRFIg9CpzRtffxeyBsJs=; b=Cq8Kh47l8CTW8cX2gegKOmPYyRubXDBLX8Wra8IzL6m6emUBcjZl3GKYuVRjuPm0v9 c8de88BP5fIqRjTKx231bOte4GqGnXQa5hRxJAXZ+iTiOAm2AKnIdPPGwFBl7rm+BupS rtTtKLbNKohQeqdYJVJSHO92kBetmnTG+rxFCT9JPqkF3aeC6dM+TflTPVIG9wTwdhjt aprvCNb3nTKFMGz12ZOCSNZuyeBhL6XL5r4uMlViOup2ZnYSFgNBSarroZlxVKO+JybG syK0UQnL89xa3dQyaH9afsouyOR1DSfr+T31Aw3k56HwDy//BIeRhq00BKxnJLzo1dvn xHPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dPrRC5GgzYjCmG/sOcyalcGlRFIg9CpzRtffxeyBsJs=; b=Mx8KS1qN1CkamrJjcSWEQQN/EKzvRm3fYKT4ZDBIHNzMbYfBE8I4X4n96FMd70ZkXH VBfgpl/+TCBVm85yYj+P253u/907NUCurtVHKEBa0qPOuuNreWL1316Ex/X1+93O86Ys xaYvZHOEX9mlWfpHthTqKcvljPRulmdVXZqNVgiIw2pysfsVSPzlCv8zoHxeLSJto6Zt BnVPtBxuY+wpYFk++8ozHtSHvKe7TE+wArHfaTRx7g0oFZ8ILSvi4IUPCp9gOx8KLzHa vj3bS/QV7jmh+bXVpf07RXYChBwQ6hq41JukMyeM5GPEVF1RsYpvkENRXOd1Cfiqxmx/ bXtA== X-Gm-Message-State: AOAM531EI9NDpChd56fTBeMAEkXjpSgETEFcpP2xac5ao1CX7NC9LXdQ Q2wNhFK0scQVqL1sdAmJKmTQOQ== X-Received: by 2002:a37:5943:: with SMTP id n64mr18642452qkb.122.1623705548426; Mon, 14 Jun 2021 14:19:08 -0700 (PDT) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id 4sm10968318qkv.134.2021.06.14.14.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jun 2021 14:19:07 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Roman Gushchin , Tejun Heo , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 3/4] fs: inode: count invalidated shadow pages in pginodesteal Date: Mon, 14 Jun 2021 17:19:03 -0400 Message-Id: <20210614211904.14420-3-hannes@cmpxchg.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614211904.14420-1-hannes@cmpxchg.org> References: <20210614211904.14420-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pginodesteal is supposed to capture the impact that inode reclaim has on the page cache state. Currently, it doesn't consider shadow pages that get dropped this way, even though this can have a significant impact on paging behavior, memory pressure calculations etc. To improve visibility into these effects, make sure shadow pages get counted when they get dropped through inode reclaim. This changes the return value semantics of invalidate_mapping_pages() semantics slightly, but the only two users are the inode shrinker itsel and a usb driver that logs it for debugging purposes. Signed-off-by: Johannes Weiner --- fs/inode.c | 2 +- mm/truncate.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index c93500d84264..8830a727b0af 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -768,7 +768,7 @@ static enum lru_status inode_lru_isolate(struct list_head *item, return LRU_ROTATE; } - if (inode_has_buffers(inode) || inode->i_data.nrpages) { + if (inode_has_buffers(inode) || !mapping_empty(&inode->i_data)) { __iget(inode); spin_unlock(&inode->i_lock); spin_unlock(lru_lock); diff --git a/mm/truncate.c b/mm/truncate.c index b92b86222625..95934c98259a 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -486,8 +486,9 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping, index = indices[i]; if (xa_is_value(page)) { - invalidate_exceptional_entry(mapping, index, - page); + count += invalidate_exceptional_entry(mapping, + index, + page); continue; } index += thp_nr_pages(page) - 1; @@ -515,19 +516,18 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping, } /** - * invalidate_mapping_pages - Invalidate all the unlocked pages of one inode - * @mapping: the address_space which holds the pages to invalidate + * invalidate_mapping_pages - Invalidate all clean, unlocked cache of one inode + * @mapping: the address_space which holds the cache to invalidate * @start: the offset 'from' which to invalidate * @end: the offset 'to' which to invalidate (inclusive) * - * This function only removes the unlocked pages, if you want to - * remove all the pages of one inode, you must call truncate_inode_pages. + * This function removes pages that are clean, unmapped and unlocked, + * as well as shadow entries. It will not block on IO activity. * - * invalidate_mapping_pages() will not block on IO activity. It will not - * invalidate pages which are dirty, locked, under writeback or mapped into - * pagetables. + * If you want to remove all the pages of one inode, regardless of + * their use and writeback state, use truncate_inode_pages(). * - * Return: the number of the pages that were invalidated + * Return: the number of the cache entries that were invalidated */ unsigned long invalidate_mapping_pages(struct address_space *mapping, pgoff_t start, pgoff_t end) -- 2.32.0