From patchwork Wed Jun 21 16:45:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287669 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 C5504C001DB for ; Wed, 21 Jun 2023 16:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A49978D0008; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26D828D000B; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF2A98D000A; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A90528D000C for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 57D7A40987 for ; Wed, 21 Jun 2023 16:46:06 +0000 (UTC) X-FDA: 80927332332.23.99AB132 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 33EF48002A for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=t7EgP9l+; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H7xjtBA+jzTamJkZvSrBReaOKW0qDsx5kc7RVJ9s550=; b=JHcGmnK/qaepHputZJTg07QqWViQ6QuymZMfXPRhCrA7f2/8QKzwnPFkfXoAASASLBIZln PjpQFD0cyTq60IKV1IE+CKi5Iu9aIwbQf3UIpfFORldjU87+XFMkNx9fw2ClXjxzNyz/Z3 +zY6g+ti6GU6MDZqaaMxlPgPoOs5ZJA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365964; a=rsa-sha256; cv=none; b=21YFTUGrDfxwSJVTJYDYq3DjQfwFuTklCznCPYlEwiUli5tzl36f+XtOXnfPocZ8lW+x9A rozXmUOc4NeskPKi8Xp5zEgAx79oEwvVKiQXMW+YAFy8L2dfD0UwTkYCj24IW1kie+nE// pq9PpnPW8H69lbALWB6bl88UNXkOzeE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=t7EgP9l+; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=H7xjtBA+jzTamJkZvSrBReaOKW0qDsx5kc7RVJ9s550=; b=t7EgP9l+MssKQftiMAo7VAdBCc Nv98h8aNtVO16LGaXGeEq2m9ltD2DVLbWxZHMVIHdnansE52q8B0dmRkBjGAlUiCMoIMy/OreImcr 5cqHvjHzMp6Nq3yxahSKcv8h0zZPtEmJc2nmPl3Y7HZoHQEaS6cdgbsAZkrux0e53j9vMSEKgXdOK EKZ68SjKoRwct8bGiDcah4w9QZ3tVXt3ANsdqnDF3UeEkp2GKmn12AODcUbhsUcILgUOYmiiBAZWV 9DXjTmPrk3hO4ePJxd9hC8YahWikG3UdRtJUwE1RGLdoobQf/AQ8MdhsOblwR8sJo3t78oQYQslj4 WpEPi5ag==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y2-00EjEd-D4; Wed, 21 Jun 2023 16:46:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 11/13] mm: Rename invalidate_mapping_pagevec to mapping_try_invalidate Date: Wed, 21 Jun 2023 17:45:55 +0100 Message-Id: <20230621164557.3510324-12-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 33EF48002A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: o3cpncjmgrxtff83en78dh981w5br4ht X-HE-Tag: 1687365963-901829 X-HE-Meta: U2FsdGVkX18UCLj7VYi77QYFcvB+tqNvFHOWKi0h9+92w8LO7+5TEf9qBuIZv7LQaDrQ4tS3cFH2GI6bmVQ7iFiq3L5xwkTv+t+ioD1qMoyfKFX38fQRyhndDzopgeQsr4paa2I47xjD9/g6Cg/MbrTs32B753Lh+aauvJ/F4XytsxTuGI3QwuWQ4VqAh0+vmUdVJVZAmQz2NHkHygmU16Dt2HHbFLl1CpdgzpuvRcGLjcbp+4lUApG/cQ5LszONW56KZSIwFcMe7IEFYnrM9DT4Hlvoeavp1d/l1ckj9i5kSWU1hC4lkRQPSnhuBJimlvOfayAkdc5A/4/dkH11iBgcTi7L1ySyH8ZqihV+daF8xKhmcKqrvZV8Bv0axIypYE1mOBcyyMq5G/cHf/O0tB2AjQZioMxxLIEGyf+iP80z1npill4O1KpgY5Va4biB60GX3UNUcBmFHpTzmvQzZav0zKkxT5L8nPjnpTCiRBMrsuN6fqvdgTl0Tk4lm5asLtvbRdO4Dht6fQJ7AgDHas2I0EkiX1Dre4gpieK5HiNS/jSKJtu3K26JtUycHay5eOXr2P6mSS8dL9FXNGyvLVqXojIW2ol4UP/a9M/7H2aHEw28curR/7iB39c/bgbid/rUfmdm54+YTVxf+Ur5fEGqUKraVEIWwsVbYKSI7l6TGRKuBxAYbmQG0KxUlZfjY79Cgy+5xTVtT7E7GyEHsmFnd0TM62vVsE8nUZ3bDXaBtWx1iEwWPD0NRhFdLi7/A1eW+nz5Rja9D+tz0+fhoiYVwiw9i/8fRVr8F4okbtSL4HUoiCRvAsY7NvQukmgCTZl3FOdR71nHlsnC1+O+DtMUkrEoQgm7QYbCUmMp7xF4au/OD9NfP5Lc61pknut0/AtCh8tJ2cVOqvO/OjxGhlSHnrzvGrn6CRJKkGCtc2/4qIfoLw0pg/31WJogxoWzc/774XL2k7yzT67+3Cu VFWhN47s qplIKOBYAvwwHhdvd9b17uZ/LKjr+vvc8aLcPmr8pw0V29SRfBbnAWWt8bfruaOBb6851rSh72f1lk1jbfVjm0+eI+rXsapH5UmqQtYQgfKNc9U9LKPRb1M6AN1G2NGHBvxNB59np+Cw1D1Vmi5B+hw2kDHwqDVK7dLuoKDUSLixDM+MGeza2mubzhu4S7DuPqcu/0xiRB1pg4xFJG7ZcxrqfD83pWl/7v1y+zAXo9INtwpo= 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: We don't use pagevecs for the LRU cache any more, and we don't know that the failed invalidations were due to the folio being in an LRU cache. So rename it to be more accurate. Signed-off-by: Matthew Wilcox (Oracle) --- mm/fadvise.c | 16 +++++++--------- mm/internal.h | 4 ++-- mm/truncate.c | 25 ++++++++++++------------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/mm/fadvise.c b/mm/fadvise.c index fb7c5f43fd2a..f684ffd7f9c9 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -143,7 +143,7 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice) } if (end_index >= start_index) { - unsigned long nr_pagevec = 0; + unsigned long nr_failed = 0; /* * It's common to FADV_DONTNEED right after @@ -156,17 +156,15 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice) */ lru_add_drain(); - invalidate_mapping_pagevec(mapping, - start_index, end_index, - &nr_pagevec); + mapping_try_invalidate(mapping, start_index, end_index, + &nr_failed); /* - * If fewer pages were invalidated than expected then - * it is possible that some of the pages were on - * a per-cpu pagevec for a remote CPU. Drain all - * pagevecs and try again. + * The failures may be due to the folio being + * in the LRU cache of a remote CPU. Drain all + * caches and try again. */ - if (nr_pagevec) { + if (nr_failed) { lru_add_drain_all(); invalidate_mapping_pages(mapping, start_index, end_index); diff --git a/mm/internal.h b/mm/internal.h index 119a8241f9d9..2ff7587b4045 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -133,8 +133,8 @@ int truncate_inode_folio(struct address_space *mapping, struct folio *folio); bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end); long invalidate_inode_page(struct page *page); -unsigned long invalidate_mapping_pagevec(struct address_space *mapping, - pgoff_t start, pgoff_t end, unsigned long *nr_pagevec); +unsigned long mapping_try_invalidate(struct address_space *mapping, + pgoff_t start, pgoff_t end, unsigned long *nr_failed); /** * folio_evictable - Test whether a folio is evictable. diff --git a/mm/truncate.c b/mm/truncate.c index 86de31ed4d32..4a917570887f 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -486,18 +486,17 @@ void truncate_inode_pages_final(struct address_space *mapping) EXPORT_SYMBOL(truncate_inode_pages_final); /** - * invalidate_mapping_pagevec - Invalidate all the unlocked pages of one inode - * @mapping: the address_space which holds the pages to invalidate + * mapping_try_invalidate - Invalidate all the evictable folios of one inode + * @mapping: the address_space which holds the folios to invalidate * @start: the offset 'from' which to invalidate * @end: the offset 'to' which to invalidate (inclusive) - * @nr_pagevec: invalidate failed page number for caller + * @nr_failed: How many folio invalidations failed * - * This helper is similar to invalidate_mapping_pages(), except that it accounts - * for pages that are likely on a pagevec and counts them in @nr_pagevec, which - * will be used by the caller. + * This function is similar to invalidate_mapping_pages(), except that it + * returns the number of folios which could not be evicted in @nr_failed. */ -unsigned long invalidate_mapping_pagevec(struct address_space *mapping, - pgoff_t start, pgoff_t end, unsigned long *nr_pagevec) +unsigned long mapping_try_invalidate(struct address_space *mapping, + pgoff_t start, pgoff_t end, unsigned long *nr_failed) { pgoff_t indices[PAGEVEC_SIZE]; struct folio_batch fbatch; @@ -527,9 +526,9 @@ unsigned long invalidate_mapping_pagevec(struct address_space *mapping, */ if (!ret) { deactivate_file_folio(folio); - /* It is likely on the pagevec of a remote CPU */ - if (nr_pagevec) - (*nr_pagevec)++; + /* Likely in the lru cache of a remote CPU */ + if (nr_failed) + (*nr_failed)++; } count += ret; } @@ -552,12 +551,12 @@ unsigned long invalidate_mapping_pagevec(struct address_space *mapping, * 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 cache entries that were invalidated + * Return: The number of indices that had their contents invalidated */ unsigned long invalidate_mapping_pages(struct address_space *mapping, pgoff_t start, pgoff_t end) { - return invalidate_mapping_pagevec(mapping, start, end, NULL); + return mapping_try_invalidate(mapping, start, end, NULL); } EXPORT_SYMBOL(invalidate_mapping_pages);