From patchwork Mon Aug 8 19:33:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12939045 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 3C202C25B0C for ; Mon, 8 Aug 2022 19:35:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD7A58E0007; Mon, 8 Aug 2022 15:34:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B39018E0006; Mon, 8 Aug 2022 15:34:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F8938E0008; Mon, 8 Aug 2022 15:34:51 -0400 (EDT) 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 662798E0006 for ; Mon, 8 Aug 2022 15:34:51 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2FFB4C0134 for ; Mon, 8 Aug 2022 19:34:51 +0000 (UTC) X-FDA: 79777427982.12.F182324 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id CFB25C0136 for ; Mon, 8 Aug 2022 19:34:50 +0000 (UTC) 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=eQz2L5Sd+WJhCeFxF2qMEcGTWQTSZ58GjI77k+ag9os=; b=NG/xZwcT26rMmkefvclqeWiLrG DR4rtALAmr0jiYQKYswxrBCbefGHBB4xYJSY0mU8mBcg8xQjJE3HCanMuE6E6BasxAeeW3xm+o4jg csoF9xPvvmfsUMS6GEpRceVQFW2s7pbQX6LN4TX/EJGBMBiWmkYWnRugOH7CtKQi7Il/l5RX/kg4M IVC90t9R+Jz2Sba5FhJCIOqte3y4+VuaKJTEo1Nm0msl/c7GFIMMFlWeRi4DEzQZceZ00aNFbh8iL QbGqgL+hpvMUNXQIJ9W1JY0Sce2ZCz47+O7OArHNzsMwh1sQZxgioKn1Gs+qw+dr6mjgOyGprTtza z7eg3RhA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oL8WX-00EAsi-BC; Mon, 08 Aug 2022 19:34:49 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , hughd@google.com Subject: [PATCH 08/59] mm: Add folio_add_lru_vma() Date: Mon, 8 Aug 2022 20:33:36 +0100 Message-Id: <20220808193430.3378317-9-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808193430.3378317-1-willy@infradead.org> References: <20220808193430.3378317-1-willy@infradead.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659987290; a=rsa-sha256; cv=none; b=VNvMERLMRiiiaBnORGyiC68VyJhylQ9KwaGkg7RTW/aNIDKsNaeamGQSp+haDRCEgcxs9G 1wwaTWycOHQM920Tek3lnnT18M+uCNsAyVmQVhrZT03Hhitb5jLLIfD6ey2nuFINT2/Tyb XxWgjgR0UHRtDOnBwlEmnz8GUFoOrng= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="NG/xZwcT"; spf=none (imf22.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=1659987290; 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=eQz2L5Sd+WJhCeFxF2qMEcGTWQTSZ58GjI77k+ag9os=; b=2AfMopFHPPcC8pPXpwXxmXLNaZcpL5cqmlZ4UfkAXtfiEnRXs5OCiNg8UGDcdqQLX5FoSM Pn57IvespwfizeggqHS73GRFvyMCV8p6a1ifCTE17VM7p1X98LdGNFqtmUwte+esDnP8kB gDJ9gqKeONsibHbBtedkoO1f5AIDT1g= X-Rspamd-Queue-Id: CFB25C0136 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="NG/xZwcT"; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: xtyg6uibnb149dikdp6gt418e98hqdo6 X-HE-Tag: 1659987290-326578 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: Convert lru_cache_add_inactive_or_unevictable() to folio_add_lru_vma() and add a compatibility wrapper. --- include/linux/swap.h | 10 +++++----- mm/folio-compat.c | 6 ++++++ mm/swap.c | 19 +++++++++---------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 43150b9bbc5c..333d5588dc2d 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -375,11 +375,11 @@ extern unsigned long totalreserve_pages; /* linux/mm/swap.c */ -extern void lru_note_cost(struct lruvec *lruvec, bool file, - unsigned int nr_pages); -extern void lru_note_cost_folio(struct folio *); -extern void folio_add_lru(struct folio *); -extern void lru_cache_add(struct page *); +void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages); +void lru_note_cost_folio(struct folio *); +void folio_add_lru(struct folio *); +void folio_add_lru_vma(struct folio *, struct vm_area_struct *); +void lru_cache_add(struct page *); void mark_page_accessed(struct page *); void folio_mark_accessed(struct folio *); diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 458618c7302c..e1e23b4947d7 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -88,6 +88,12 @@ void lru_cache_add(struct page *page) } EXPORT_SYMBOL(lru_cache_add); +void lru_cache_add_inactive_or_unevictable(struct page *page, + struct vm_area_struct *vma) +{ + folio_add_lru_vma(page_folio(page), vma); +} + int add_to_page_cache_lru(struct page *page, struct address_space *mapping, pgoff_t index, gfp_t gfp) { diff --git a/mm/swap.c b/mm/swap.c index 9cee7f6a3809..6525011b715e 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -493,22 +493,21 @@ void folio_add_lru(struct folio *folio) EXPORT_SYMBOL(folio_add_lru); /** - * lru_cache_add_inactive_or_unevictable - * @page: the page to be added to LRU - * @vma: vma in which page is mapped for determining reclaimability + * folio_add_lru_vma() - Add a folio to the appropate LRU list for this VMA. + * @folio: The folio to be added to the LRU. + * @vma: VMA in which the folio is mapped. * - * Place @page on the inactive or unevictable LRU list, depending on its - * evictability. + * If the VMA is mlocked, @folio is added to the unevictable list. + * Otherwise, it is treated the same way as folio_add_lru(). */ -void lru_cache_add_inactive_or_unevictable(struct page *page, - struct vm_area_struct *vma) +void folio_add_lru_vma(struct folio *folio, struct vm_area_struct *vma) { - VM_BUG_ON_PAGE(PageLRU(page), page); + VM_BUG_ON_FOLIO(folio_test_lru(folio), folio); if (unlikely((vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) == VM_LOCKED)) - mlock_new_page(page); + mlock_new_page(&folio->page); else - lru_cache_add(page); + folio_add_lru(folio); } /*