From mboxrd@z Thu Jan 1 00:00:00 1970 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 3D2E2C433EF for ; Fri, 4 Feb 2022 19:59:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F8956B0093; Fri, 4 Feb 2022 14:59:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18F048D0007; Fri, 4 Feb 2022 14:59:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B221F6B007B; Fri, 4 Feb 2022 14:59:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id B7B206B0096 for ; Fri, 4 Feb 2022 14:59:06 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 72B191815138D for ; Fri, 4 Feb 2022 19:59:06 +0000 (UTC) X-FDA: 79106161092.10.8EA1716 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf31.hostedemail.com (Postfix) with ESMTP id 0B4FA20002 for ; Fri, 4 Feb 2022 19:59:05 +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=y6p8+MJkK+iojKvg+sCKZZ8nwxZP7FWYLeEHjHoDQdg=; b=HUL9PebXZ888AnsWESfPYxl8OI 6Gsxse1mArB4K/J80n0lO3AiO67o06XdXMtVm+ez1TWvOakfn+tE/SjJdzB4E7GIsIVoWSf+wFoaA v/egZtltIQCZKOeaZQDZvv/Nr/Gcqv+DqsaLryM1U/5yHR55YGAQ/I7gdulmJnRS7rtThwr96qw5q GOgikwcPjejGSxSeoAPHhKpX3IjBpWixuoZS/AiZ+6hGrzkCKX0navkwhB5danZBDu4P034F7csE8 ZQOtoG/glu6VSL+uDzRjMhdvs24gz5lkTKxkoP97hMtWoAg1GJ4fykYNagpfXVsd1SOQemhxm3vE2 kG2CDsXw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG4jY-007Lo5-MF; Fri, 04 Feb 2022 19:59:04 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [PATCH 48/75] mm/rmap: Turn page_mlock() into folio_mlock() Date: Fri, 4 Feb 2022 19:58:25 +0000 Message-Id: <20220204195852.1751729-49-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220204195852.1751729-1-willy@infradead.org> References: <20220204195852.1751729-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HUL9PebX; spf=none (imf31.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-Rspam-User: nil X-Rspamd-Queue-Id: 0B4FA20002 X-Stat-Signature: uhqs4tmuek8n51jf8xenco9pkwuxqqdi X-Rspamd-Server: rspam12 X-HE-Tag: 1644004745-513804 Content-Transfer-Encoding: quoted-printable 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: Add back page_mlock() as a wrapper around folio_mlock(). Removes a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/rmap.h | 1 + mm/folio-compat.c | 6 ++++++ mm/rmap.c | 31 +++++++++++++++++-------------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 00b772cdaaaa..31f3a299ef66 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -261,6 +261,7 @@ int folio_mkclean(struct folio *); * the page mlocked. */ void page_mlock(struct page *page); +void folio_mlock(struct folio *folio); =20 void remove_migration_ptes(struct page *old, struct page *new, bool lock= ed); =20 diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 9cb0867d5b38..90f03187a5e3 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "internal.h" =20 struct address_space *page_mapping(struct page *page) @@ -174,3 +175,8 @@ void mlock_vma_page(struct page *page) { mlock_vma_folio(page_folio(page)); } + +void page_mlock(struct page *page) +{ + folio_mlock(page_folio(page)); +} diff --git a/mm/rmap.c b/mm/rmap.c index 1cedcfd6105c..a383e25fb196 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -2001,6 +2001,7 @@ void try_to_migrate(struct page *page, enum ttu_fla= gs flags) static bool page_mlock_one(struct page *page, struct vm_area_struct *vma= , unsigned long address, void *unused) { + struct folio *folio =3D page_folio(page); struct page_vma_mapped_walk pvmw =3D { .vma =3D vma, .address =3D address, @@ -2024,9 +2025,9 @@ static bool page_mlock_one(struct page *page, struc= t vm_area_struct *vma, * nor on an Anon THP (which may still be PTE-mapped * after DoubleMap was cleared). */ - mlock_vma_page(page); + mlock_vma_folio(folio); /* - * No need to scan further once the page is marked + * No need to scan further once the folio is marked * as mlocked. */ page_vma_mapped_walk_done(&pvmw); @@ -2038,14 +2039,14 @@ static bool page_mlock_one(struct page *page, str= uct vm_area_struct *vma, } =20 /** - * page_mlock - try to mlock a page - * @page: the page to be mlocked + * folio_mlock() - Try to mlock a folio. + * @folio: The folio to be mlocked. * - * Called from munlock code. Checks all of the VMAs mapping the page and= mlocks - * the page if any are found. The page will be returned with PG_mlocked = cleared - * if it is not mapped by any locked vmas. + * Called from munlock code. Checks all of the VMAs mapping the folio + * and mlocks the folio if any are found. The folio will be returned + * with the mlocked flag clear if it is not mapped by any locked vmas. */ -void page_mlock(struct page *page) +void folio_mlock(struct folio *folio) { struct rmap_walk_control rwc =3D { .rmap_one =3D page_mlock_one, @@ -2054,14 +2055,16 @@ void page_mlock(struct page *page) =20 }; =20 - VM_BUG_ON_PAGE(!PageLocked(page) || PageLRU(page), page); - VM_BUG_ON_PAGE(PageCompound(page) && PageDoubleMap(page), page); + VM_BUG_ON_FOLIO(!folio_test_locked(folio) || folio_test_lru(folio), + folio); + VM_BUG_ON_FOLIO(folio_test_large(folio) && folio_test_double_map(folio)= , + folio); =20 /* Anon THP are only marked as mlocked when singly mapped */ - if (PageTransCompound(page) && PageAnon(page)) + if (folio_test_large(folio) && folio_test_anon(folio)) return; =20 - rmap_walk(page, &rwc); + rmap_walk(&folio->page, &rwc); } =20 #ifdef CONFIG_DEVICE_PRIVATE @@ -2290,7 +2293,7 @@ static struct anon_vma *rmap_walk_anon_lock(struct = page *page, * Find all the mappings of a page using the mapping pointer and the vma= chains * contained in the anon_vma struct it points to. * - * When called from page_mlock(), the mmap_lock of the mm containing the= vma + * When called from folio_mlock(), the mmap_lock of the mm containing th= e vma * where the page was found will be held for write. So, we won't rechec= k * vm_flags for that VMA. That should be OK, because that vma shouldn't= be * LOCKED. @@ -2343,7 +2346,7 @@ static void rmap_walk_anon(struct page *page, struc= t rmap_walk_control *rwc, * Find all the mappings of a page using the mapping pointer and the vma= chains * contained in the address_space struct it points to. * - * When called from page_mlock(), the mmap_lock of the mm containing the= vma + * When called from folio_mlock(), the mmap_lock of the mm containing th= e vma * where the page was found will be held for write. So, we won't rechec= k * vm_flags for that VMA. That should be OK, because that vma shouldn't= be * LOCKED. --=20 2.34.1