From patchwork Mon Dec 11 16:22:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487535 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 1E2C4C4167B for ; Mon, 11 Dec 2023 16:22:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35A7C6B015C; Mon, 11 Dec 2023 11:22:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 309136B015E; Mon, 11 Dec 2023 11:22:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 183846B015F; Mon, 11 Dec 2023 11:22:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EF6446B015C for ; Mon, 11 Dec 2023 11:22:34 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C25AD1607B6 for ; Mon, 11 Dec 2023 16:22:34 +0000 (UTC) X-FDA: 81555055428.04.CDDDAF6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 0A2544001B for ; Mon, 11 Dec 2023 16:22:32 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sqO4Rkl9; dmarc=none; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702311753; 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=6/O8AxQhOc3DY3F0avx8jrFn8ZBbS1ihhWhpgyLNNSI=; b=HXhy22pw/aq/+gBxWf11upKyOrqivUF3gPX5w/m8XTu7syjF7MwBsPuylKrHT0wXwGrHnw M7lBsOeo19vzDQPsAcY94uO+ZUECGbWLHJnZNen4SuDIdRRh/JqqYSVjUDfg2GgjmGK0W7 ub+3Ox3Oyewl2NKF5DMryiWj9puDDhM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sqO4Rkl9; dmarc=none; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311753; a=rsa-sha256; cv=none; b=IYy/x7oSBz675HaAns2mY+4VKWlLNOzlGy3ds+MVoOfOO5kvusaaZg08CHNWoK+rTNuubW RjbHcPTFenmkeWJ6xY1pJzBTKfy8bxMva8Vavus98IiViv8pAV/bG0ZEUKR68Yw7N1FfTe iRQM0Rb3l/8iBd/ifH1jIDusmoS345k= 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=6/O8AxQhOc3DY3F0avx8jrFn8ZBbS1ihhWhpgyLNNSI=; b=sqO4Rkl9ug6swiCRwJCQ3KJwBD 2KOiGPD1cihCHpe6GLFNLQUMTmwYkZJ8a9U7sLFTRZXyrZhr+8n5xVUbeHtCYnt7T1eZKct4VgKXl uRFsghqrpn17YmJiCyhrZ7LeXdx2m+3Qt/HexoTORA0SPT/vAci6GnfjnQ0TDuEUaUtxAueIX5O1O 7X791Mvod35j0GJso6kh2BYZtzsgnlLiDAzTUcZit4mspNAQ+g8LhHNMnV1TPPAoD+yrf9hOVgHEP FsUskY2xNjV9T/IUqWm+kfJASUpkxuVmt+2G1blenqDXGieMPh5WUGBt5sDiY1LbrKOhAu/R2RpsV s/9uhn+A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JB-1X; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 1/9] mm: Convert ksm_might_need_to_copy() to work on folios Date: Mon, 11 Dec 2023 16:22:06 +0000 Message-Id: <20231211162214.2146080-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: kr834hje6xp5et9rjegzbqd69tm8b435 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0A2544001B X-HE-Tag: 1702311752-160514 X-HE-Meta: U2FsdGVkX1+eyN2S7FkbW96xomdzuZfPWgWpl3xQawa+Z/UTU87zY42FxFMlI3VznjV8W83JAiscd9BSO1bqNRgkKxqvWYCknHel+hFsmqtZu1EO2U8R+oo0AG4eExY3u31R5HsDk9UO1HXFsJQlupofu5XVCNqz+Z37QKaHonGc00638tUG2fHNxna5qYVNirkR+B4Tca9FwkRD9aBcUvx6B/5iuHfsVweOAHMIaKzuRrh12U9QFBRjvY7nRFF7+soYLjBv/AtxivRv57DRVEkUvQxw4JatdtWdvy0NTnB9LqItHUnqna5QMmSJkNn49QkzfGzwxRsock2dFYikcFfS/chixbHHxMTQTVR6jtY6ExK4gPzAnVlDlejEHbn0sfDgl0XoKsFq3WzPLoNNdtBxT2Z2Kvun2bUv3zXhM+MkScLlHz9+k3m5Tqu8L17I/zvTzNaKvdiwnC68GT+CB9t4TlQRkUCbLJscaqtzqTPBkVzIrAPnbhDH4/kjQkcLeXew80p4uOXuBhlTzcDfNO/J/XGRCTCAGT5LqoC20PD9eePVtpSqtjNU1gaaXZLRCKa09ny4vZRdGOjua1f4+wEcBfA0tY1sTcH9mzn/jCwQfU3fflJDNmZWxRf2CCpuiTOpXzqJ6PhQctOwt1TsRgGekWcu0jKhgllQlswDLIWErq5DT0bCgAvtigzvZB64aVkN6kSOTkPs/BwMf1Ag9ANrM+i1tgwmRm0r4qGg7PGn3uoklBCaRcaVo9HqSb7xVEkaFj0yANBZsBBrFtluKF89eLgoeK93iUK2kIAOVqONFzgRMo2g4rkvhheCssbY7iUysLVIkpAbdf7F0Eh7Ry6JpXGiR7DNBxUzOvBLZCUCMJGPFvIiYvK/OtjzBde6VhDkkw1tVBxYeFezxA/9tCusaUSd5COKIU1KO2ieskP0AhhZdZ/kJYPykyejMBKw8sDXVfK6Ylf5UO9DLQx Bc0CvKrB 7rQlIt0olH4wB93FAF/kE5VQWoZdFIk/gTTUNvfx9qAhR41mGRxu2wAJOSkRFEMZ5AqAczem+n/DpHSaAAveliGiBgo52f8hlQWKtCaeWinYHnTAe6i+R+vRmCg7g7sysl0vTRFY9MQ3nsa4B2LnO7pINBmUIjTX9NovwmG+wghQz1AT7NVcRaQaQ1Q6kB8u2LmqskQguOYxUvcVCqsbR9kp1Sq3Psodem7A7 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: List-Subscribe: List-Unsubscribe: Accept a folio as an argument and return a folio result. Removes a call to compound_head() in do_swap_page(), and prevents folio & page from getting out of sync in unuse_pte(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- include/linux/ksm.h | 6 +++--- mm/ksm.c | 21 +++++++++++---------- mm/memory.c | 8 ++++---- mm/swapfile.c | 8 +++++--- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/linux/ksm.h b/include/linux/ksm.h index 4643d5244e77..401348e9f92b 100644 --- a/include/linux/ksm.h +++ b/include/linux/ksm.h @@ -76,7 +76,7 @@ static inline void ksm_exit(struct mm_struct *mm) * We'd like to make this conditional on vma->vm_flags & VM_MERGEABLE, * but what if the vma was unmerged while the page was swapped out? */ -struct page *ksm_might_need_to_copy(struct page *page, +struct folio *ksm_might_need_to_copy(struct folio *folio, struct vm_area_struct *vma, unsigned long addr); void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc); @@ -129,10 +129,10 @@ static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start, return 0; } -static inline struct page *ksm_might_need_to_copy(struct page *page, +static inline struct folio *ksm_might_need_to_copy(struct folio *folio, struct vm_area_struct *vma, unsigned long addr) { - return page; + return folio; } static inline void rmap_walk_ksm(struct folio *folio, diff --git a/mm/ksm.c b/mm/ksm.c index b93389a3780e..16532fa85a46 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2875,30 +2875,30 @@ void __ksm_exit(struct mm_struct *mm) trace_ksm_exit(mm); } -struct page *ksm_might_need_to_copy(struct page *page, +struct folio *ksm_might_need_to_copy(struct folio *folio, struct vm_area_struct *vma, unsigned long addr) { - struct folio *folio = page_folio(page); + struct page *page = folio_page(folio, 0); struct anon_vma *anon_vma = folio_anon_vma(folio); struct folio *new_folio; if (folio_test_large(folio)) - return page; + return folio; if (folio_test_ksm(folio)) { if (folio_stable_node(folio) && !(ksm_run & KSM_RUN_UNMERGE)) - return page; /* no need to copy it */ + return folio; /* no need to copy it */ } else if (!anon_vma) { - return page; /* no need to copy it */ + return folio; /* no need to copy it */ } else if (folio->index == linear_page_index(vma, addr) && anon_vma->root == vma->anon_vma->root) { - return page; /* still no need to copy it */ + return folio; /* still no need to copy it */ } if (PageHWPoison(page)) return ERR_PTR(-EHWPOISON); if (!folio_test_uptodate(folio)) - return page; /* let do_swap_page report the error */ + return folio; /* let do_swap_page report the error */ new_folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, addr, false); if (new_folio && @@ -2907,9 +2907,10 @@ struct page *ksm_might_need_to_copy(struct page *page, new_folio = NULL; } if (new_folio) { - if (copy_mc_user_highpage(&new_folio->page, page, addr, vma)) { + if (copy_mc_user_highpage(folio_page(new_folio, 0), page, + addr, vma)) { folio_put(new_folio); - memory_failure_queue(page_to_pfn(page), 0); + memory_failure_queue(folio_pfn(folio), 0); return ERR_PTR(-EHWPOISON); } folio_set_dirty(new_folio); @@ -2920,7 +2921,7 @@ struct page *ksm_might_need_to_copy(struct page *page, #endif } - return new_folio ? &new_folio->page : NULL; + return new_folio; } void rmap_walk_ksm(struct folio *folio, struct rmap_walk_control *rwc) diff --git a/mm/memory.c b/mm/memory.c index 055647120f01..318f923134e4 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3942,15 +3942,15 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) * page->index of !PageKSM() pages would be nonlinear inside the * anon VMA -- PageKSM() is lost on actual swapout. */ - page = ksm_might_need_to_copy(page, vma, vmf->address); - if (unlikely(!page)) { + folio = ksm_might_need_to_copy(folio, vma, vmf->address); + if (unlikely(!folio)) { ret = VM_FAULT_OOM; goto out_page; - } else if (unlikely(PTR_ERR(page) == -EHWPOISON)) { + } else if (unlikely(folio == ERR_PTR(-EHWPOISON))) { ret = VM_FAULT_HWPOISON; goto out_page; } - folio = page_folio(page); + page = folio_page(folio, 0); /* * If we want to map a page that's in the swapcache writable, we diff --git a/mm/swapfile.c b/mm/swapfile.c index 8be70912e298..0371b7b3cd27 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1749,11 +1749,13 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, int ret = 1; swapcache = page; - page = ksm_might_need_to_copy(page, vma, addr); - if (unlikely(!page)) + folio = ksm_might_need_to_copy(folio, vma, addr); + if (unlikely(!folio)) return -ENOMEM; - else if (unlikely(PTR_ERR(page) == -EHWPOISON)) + else if (unlikely(folio == ERR_PTR(-EHWPOISON))) hwpoisoned = true; + else + page = folio_file_page(folio, swp_offset(entry)); pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); if (unlikely(!pte || !pte_same_as_swp(ptep_get(pte), From patchwork Mon Dec 11 16:22:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487532 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 C3D42C4167B for ; Mon, 11 Dec 2023 16:22:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68C916B0157; Mon, 11 Dec 2023 11:22:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 616346B0158; Mon, 11 Dec 2023 11:22:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43FFA6B0159; Mon, 11 Dec 2023 11:22:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2D70F6B0157 for ; Mon, 11 Dec 2023 11:22:28 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 03BE0C06AB for ; Mon, 11 Dec 2023 16:22:27 +0000 (UTC) X-FDA: 81555055176.30.F7ADB57 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 2472B140010 for ; Mon, 11 Dec 2023 16:22:25 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bBdnAJaG; spf=none (imf23.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=1702311746; 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=iBAETAIC6DR0PILlxhyqfKzerc8Q362OER7xGl6qcHk=; b=uiR4VnGKQ+2aXBuj67TkOu1DN2s3plYja21mZMXYZWk1zNMKm08MSA3RYWIwkyX22pZExy HewjhPhnGveuSQyUPa+zqm3bbwOdge76v6q7dX0JJ4rNUo93qoPEUxgptbl+WyuZguXwkM qxb3vzPi2f2vmbk/2oWlRxhaXSotUmM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311746; a=rsa-sha256; cv=none; b=A9xPRDvW/3+HYE+xijjh9LQTdnuY/nh9WktgIeV+s+vC+ORL8DPxlKuhtYu8KMvPCP4lVu pZRXo9DwogoVQHZDN0OBOaEHvkMtM6ckE2NLsAa2jCM5o8bBb5U3K+PghqnefvWl2pRv7d MrmF+4WYjcSPUljIBYfIKw2qGUri6B0= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bBdnAJaG; spf=none (imf23.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=iBAETAIC6DR0PILlxhyqfKzerc8Q362OER7xGl6qcHk=; b=bBdnAJaGRNMzhe8VwT1bFm6SQm EqG640irRvkB0L6v367hdLPLmHWIB+KRtRTtP8Y+HnJ0qhGZcBKciyG6vnormZARZIKAeNVM8RnvQ o4G8K5RVGg3nhy7wloy8mzQiPOu4eEQ4bl7FQ927u4VfaMIFyUmnpAmei52HoQgABBN4SAglXU+dM Minu2xIY6K/3ivUc9/r9Rdw4MHAF5ZYZl+k9iXDLOEzddK6UJ7Maq0vIOsvnqwbHl4Y/CFCub0A2/ HENGh3zRKjKYK1qEcqlpOocgxPcJH7xlZnjeR5EclmvgeskfSU0UUCoFLNbEuoMfm908IMUO0NsNQ g+tY8U8A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JL-3v; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 2/9] mm: Simplify the assertions in unuse_pte() Date: Mon, 11 Dec 2023 16:22:07 +0000 Message-Id: <20231211162214.2146080-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2472B140010 X-Rspam-User: X-Stat-Signature: i5wqyezqsxhx9u1rjut8cs1o48351jib X-Rspamd-Server: rspam03 X-HE-Tag: 1702311745-75239 X-HE-Meta: U2FsdGVkX1/igerGxwKY8ocVPQczKgPzpvVzyCRq6z5XVQqD1DyVeEkOjE+ohOMV0mbE1UHFvTQqkAfEr/HYZLg+zZx8XkXfMaf97SwgJ+4QNyfUnbQSVZwtqi9lCqn/G3nJmI1V4QVBgrCerlyeewXpkUpIiiBuvR0a8YoZwBXs48YM6XaC/CQ3RG3fMxTd0Hh1oyXzkeXhoLl9enYAhSAMkYZvf6PvJseJns/f2eBdkjWIRfFkUEc/nFy1FTjkZ0pcucH2bPKwewzJri+iG6l99CzvTTBEloWjJxXTb5bRZLFuB+th7cA8rS93Y1F78qnvOzooRkQRdHdFCjmprhrk5K/puAo3DX6IRCvQknsnd0MlueBXIf9c35q2C74ZiCwLyTx16BhcUE9SD58JFShPG7A3OJDeBQUr3NEevTT6opC+jNGcvqd4nrW2TuP8Dx17UrTpH5grhAB7/jTiylj3FLntGfdk7kC6HrEG6wb3aGkFdbQcf8+P3n4tw9uq4KjRMolexMc3ff8HybPQE/SZMXNbetIy8eTv83i87ZkhU+9va63GqMMTiaPbft/xD30kcn4nR87MZvu8bJ79v2xfnSJCzbgWIiYQL62e9M5TxyHGENz06qCNnj3A/xY3nFh8fak/JZt9M/N8A624ueBhlLM3FLMnBrMVpeRiuMVHfx1JkYSkWjWT1DRe72y/vIMoxZXyJYIBKHJK9U0yJ6GtJ/5ggWOOHkDzcxBNFcuAC92p10YVA0fX81O5/MJPCsQgI+UF9tiHYS7CcXaqHhukhmQ4ahFmgrdoL9aD+3DAO7dEV/dwNS+3tLF8Dd+SAxs9rMdMIYwwUhJ5Tnc45t4RW2G+0OwvoLl93we5NWvH2KosGF29xMa46/dL8SJGMt3uUUNBzsJaW5XOMENm3FLzgg/Es4ujz/IYnET2kLwHozzVD3yjm/W96R1e2YSf8aAU1NgvOPzB6qG3b8t ljn6btyA i6dO6rd0IZx0Uxl+8OMvXJDFsAFDDyHIs0hhatfF5+Qjwv6XTOH9uBDtp/6TQG0iUyEkCtje4ORz7N8IjqBTdhog9apl6Gjx7UqYHm4EQpWjR5sUSu6XV+O3aoCI0/Jaaswvp8UAt/ayjUfsYZUYAWzb6MjnDOreFjsTZg2TUaYIE4lUBVTZOsz9z2sbQOI3BOdK8W6e+hASh990nTzxVVFfLeOYGcCYsk4tt 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: List-Subscribe: List-Unsubscribe: We should only see anon folios in this function (and there are many assumptions of that already), so we can simplify these two assertions. Signed-off-by: Matthew Wilcox (Oracle) --- mm/swapfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 0371b7b3cd27..88842c6fb8fe 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1789,8 +1789,8 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, arch_swap_restore(entry, page_folio(page)); /* See do_swap_page() */ - BUG_ON(!PageAnon(page) && PageMappedToDisk(page)); - BUG_ON(PageAnon(page) && PageAnonExclusive(page)); + VM_BUG_ON_FOLIO(!folio_test_anon(folio), folio); + VM_BUG_ON_PAGE(PageAnonExclusive(page), page); dec_mm_counter(vma->vm_mm, MM_SWAPENTS); inc_mm_counter(vma->vm_mm, MM_ANONPAGES); From patchwork Mon Dec 11 16:22:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487536 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 03923C4167B for ; Mon, 11 Dec 2023 16:22:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 491246B015E; Mon, 11 Dec 2023 11:22:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 418C86B0160; Mon, 11 Dec 2023 11:22:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BBA76B0161; Mon, 11 Dec 2023 11:22:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1B3F06B015E for ; Mon, 11 Dec 2023 11:22:38 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DB21A1207F3 for ; Mon, 11 Dec 2023 16:22:37 +0000 (UTC) X-FDA: 81555055554.27.2AB9DB4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 3188C40006 for ; Mon, 11 Dec 2023 16:22:35 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Dk0qLtEY; spf=none (imf01.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=1702311756; 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=lv5/QlpFBGfTPKEhLKk7D9FZb8fAcEsAJO+HR3ZfBi8=; b=HEuQzNyk9YGhKRvooxpEkbTZ06PE4rD5spp5tooe2gvqFIEVVz9Lc3kDUhKbvwF0qAAXlh baRuRmN66SIOlxGnkWiDcHWQDjKYsMqP7mNieEczdMBWNjRe5Qqpyx0pKywga5WKKbl7a2 BocP7XsA3UyVn3mbiaPayCcq3fLQlvM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311756; a=rsa-sha256; cv=none; b=iw+TrxrlamjCCDfwvUVmyRmQUTRvFGCgafhvL9uDZPwBFPMl09/VFZ8MMlI0Ggl7ls9STt RW8PW33qMfIt5hxQMptNDV7SZdBHvMe9PQRZxjxuWYZq/rUN0aBRJTGkQbwANP9KiI6e0a d7l3b+9DcbBnWsqPJTM42f5iokxluJg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Dk0qLtEY; spf=none (imf01.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=lv5/QlpFBGfTPKEhLKk7D9FZb8fAcEsAJO+HR3ZfBi8=; b=Dk0qLtEYD8I4szbGges29A2qv1 hRNfLUGhR/JjyKFFmwSd0G8I8SvurxwaYIB7ALTc8MJqqg5OF6EKdnYaeAC3XLwLgL+W4VroTgIVQ 1JD6rAFTbDqRe6xKcN5s2/cTqbsQctrv1THorzPCuqDuCS6SfQ4lkkZctdN0L+8b1MYLqZiX2sxUA f/VgG8JM7FR0QEHdK/CgFhteUvAnt87TIdmbNJolYo3F9yYhuhTvDVJUM9F71R3uGarRJom3RtG9/ saOLk8coQKSde/hl8p1MpgB2lQubT0jv5MvMnSierftxiB66z9LO+j3uV050dXj47wLlO7ghOK0fE dgJkzlag==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JN-6i; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 3/9] mm: Convert unuse_pte() to use a folio throughout Date: Mon, 11 Dec 2023 16:22:08 +0000 Message-Id: <20231211162214.2146080-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3188C40006 X-Rspam-User: X-Stat-Signature: 7aoooije77ghs6oe1kk11nwtwnum9ccq X-Rspamd-Server: rspam03 X-HE-Tag: 1702311755-365113 X-HE-Meta: U2FsdGVkX1+AvKPH+18QaYJ8QUngvz/fA8n2bq4vDNVL3qFOnlycr5RlbJ2LJZKK/yoLQF+7xInCjY/4NKPs6eI3mD+0bdUKQPyl1EoICLuStYNW7BO2t2rkgsRhmhVnlmQs6ORq315tuVnSRj9Bv8QYDpnuIjLPogHUoXxoT3Qzx78ODakSSV7hURU9c1TbE2+1yrSA/Nzw1zKalIjrpB7fhDNVhVo1f7XDb9918XWuvhMmCPdvNmdqCiDUnPjGUrAwlE37QvPiVl1wtq8aYHt19CGKK6LFCm3UdJKETF3dwwcND9P4BDirNHf/eAoZy14IkYb+6+pU3g1jz5Y4g04qk3oxR8uiHYYgEC7xTuMerzkBAWeubV5dEYumqGKB3hby4vA7QCyz17TW2na8P8T9qARuzlWfo7fhW5E8+WSW1rex5HNm6oxzXFykrCLPUrP++YoCLivXyIk9S6wlxnJ1nCiC97UhZGtfTBFwS/0jE+dJLl9ih5J3RIMCG2XkHiHlzFpatLDBYBIcdNGEzHYpNC+5BtHI25z06rVkbgCbvE2tzUDo8eFxx8uQMMqb2AETW5piEPfovsl3wnYiSD4PAJbItjAFxZweVjH6vmaLi41/szly5YGkIH37jKyjwIn4poOfEo/q5PQ6icnWLdOc2JC/gN5rv5XAEHDHkQ2bP+kHb/lcmxnvCRQ1eykZ6eWvg9DqLzuoXdty30xJEaAsDMG2knR67+JWg9TNmJpPh5OzB5W3VSpQm+vTyiazM9FeEZP3gZE0eKyjwAup+nyCz1NbnE8t4NbQm9aVWCYEQx/DoSoqGWJ4xqU1qQ3RcuGV699OklzBc3q3KML42wUeLNwVsbXgN0GgTpZNTuixBaJtJm9ixOf9IVpnp4TCVsxLqjloaFOhHmcQOlk3TJFmnGnWGt3YsbROrcmwtZKJ3kSZfCvM0B5besBMXSRnXD5S2NcYYoKxYT3NB6Q xEdNNzRA qUbcAR+DtQtyuFB9mNs9/NiJhhRycVx8CNYHyCQGs8Qhu9V7KurXBhxo0yoUYInh2wrK+Uu12dms/6zSPiHrYfR26zEv8H48fO7HmVwJly+3FlUYfCy9pA8rM9nICi9ZJltb00OwPIXGVwz9ZpHHA6xeKxY8R5PKnmtwKoWWpB482n5Lx2zR93z5jHSQtourVMJ+xDnzY5NJmCnGAnwbx0ES4vPaAicxabKUR 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: List-Subscribe: List-Unsubscribe: Saves about eight calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/swapfile.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 88842c6fb8fe..21eced2d1f80 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1741,21 +1741,25 @@ static inline int pte_same_as_swp(pte_t pte, pte_t swp_pte) static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, swp_entry_t entry, struct folio *folio) { - struct page *page = folio_file_page(folio, swp_offset(entry)); - struct page *swapcache; + struct page *page; + struct folio *swapcache; spinlock_t *ptl; pte_t *pte, new_pte, old_pte; - bool hwpoisoned = PageHWPoison(page); + bool hwpoisoned = false; int ret = 1; - swapcache = page; + swapcache = folio; folio = ksm_might_need_to_copy(folio, vma, addr); if (unlikely(!folio)) return -ENOMEM; - else if (unlikely(folio == ERR_PTR(-EHWPOISON))) + else if (unlikely(folio == ERR_PTR(-EHWPOISON))) { + hwpoisoned = true; + folio = swapcache; + } + + page = folio_file_page(folio, swp_offset(entry)); + if (PageHWPoison(page)) hwpoisoned = true; - else - page = folio_file_page(folio, swp_offset(entry)); pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); if (unlikely(!pte || !pte_same_as_swp(ptep_get(pte), @@ -1766,13 +1770,12 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, old_pte = ptep_get(pte); - if (unlikely(hwpoisoned || !PageUptodate(page))) { + if (unlikely(hwpoisoned || !folio_test_uptodate(folio))) { swp_entry_t swp_entry; dec_mm_counter(vma->vm_mm, MM_SWAPENTS); if (hwpoisoned) { - swp_entry = make_hwpoison_entry(swapcache); - page = swapcache; + swp_entry = make_hwpoison_entry(page); } else { swp_entry = make_poisoned_swp_entry(); } @@ -1786,7 +1789,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, * when reading from swap. This metadata may be indexed by swap entry * so this must be called before swap_free(). */ - arch_swap_restore(entry, page_folio(page)); + arch_swap_restore(entry, folio); /* See do_swap_page() */ VM_BUG_ON_FOLIO(!folio_test_anon(folio), folio); @@ -1794,23 +1797,23 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, dec_mm_counter(vma->vm_mm, MM_SWAPENTS); inc_mm_counter(vma->vm_mm, MM_ANONPAGES); - get_page(page); - if (page == swapcache) { + folio_get(folio); + if (folio == swapcache) { rmap_t rmap_flags = RMAP_NONE; /* - * See do_swap_page(): PageWriteback() would be problematic. - * However, we do a wait_on_page_writeback() just before this - * call and have the page locked. + * See do_swap_page(): writeback would be problematic. + * However, we do a folio_wait_writeback() just before this + * call and have the folio locked. */ - VM_BUG_ON_PAGE(PageWriteback(page), page); + VM_BUG_ON_FOLIO(folio_test_writeback(folio), folio); if (pte_swp_exclusive(old_pte)) rmap_flags |= RMAP_EXCLUSIVE; page_add_anon_rmap(page, vma, addr, rmap_flags); } else { /* ksm created a completely new copy */ - page_add_new_anon_rmap(page, vma, addr); - lru_cache_add_inactive_or_unevictable(page, vma); + folio_add_new_anon_rmap(folio, vma, addr); + folio_add_lru_vma(folio, vma); } new_pte = pte_mkold(mk_pte(page, vma->vm_page_prot)); if (pte_swp_soft_dirty(old_pte)) @@ -1823,9 +1826,9 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, out: if (pte) pte_unmap_unlock(pte, ptl); - if (page != swapcache) { - unlock_page(page); - put_page(page); + if (folio != swapcache) { + folio_unlock(folio); + folio_put(folio); } return ret; } From patchwork Mon Dec 11 16:22:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487529 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 DA0C6C46CA3 for ; Mon, 11 Dec 2023 16:22:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B22B6B0151; Mon, 11 Dec 2023 11:22:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 662656B0152; Mon, 11 Dec 2023 11:22:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 529246B0153; Mon, 11 Dec 2023 11:22:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3FF3D6B0151 for ; Mon, 11 Dec 2023 11:22:22 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1B9431607E8 for ; Mon, 11 Dec 2023 16:22:22 +0000 (UTC) X-FDA: 81555054924.13.B97326E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 505D280031 for ; Mon, 11 Dec 2023 16:22:18 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=wSA7DBhZ; 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=1702311740; 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=ps1ZUrGA7WXV5WZey1e9J5DohthDss4AMbHUVlXoCqk=; b=NMFTUOe3j+Sm4hrWpL3EcfnhHFxsZVktaiO07MB0ZqLJnpbTEgFL5IEr+PAZit3Y8ItKeL T5R3W6O5vlWs7cIN/vJsmtfo2Rpom/lucRQo8lqJYCYYfQeMbqaCuZY8+H4iTNViEqfz3M Bhu+AN1EN3scbg6BvtmAcZeyMCq204s= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=wSA7DBhZ; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311740; a=rsa-sha256; cv=none; b=CWd4dd5AqGrK3/D8xrgckpgEUX6stYO8oQQs+vgj70CURSfWhMunMQ3JU6vBQGbrJ4plhH 4ktw5aSSxmmnK3twpT0I8eOVS7OEStOIdmf9XAiS0u++CclVM+SOEHcAZaIKzg45E54sQr ZIxJu4hR4M9CzjoU7vTRtkU65CZWtkI= 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=ps1ZUrGA7WXV5WZey1e9J5DohthDss4AMbHUVlXoCqk=; b=wSA7DBhZFfzAO/QVTA0C5/m6Ug ACEThTTtI7n3x7vM5Q4u/01lkGdNoXF7VCxIRy73RF5QNaS7zJa7Ay27TUiVnjeJMaUO13509ZV5E /YT8LLL8pli5r6T8Ob7yrJy+2mPkniqlzfCkPmRJTljKUsPxCN5tUa8dAuqV6tpvbgqplTx6TvNH5 kViCHu9gvlYUi60DrehgFM6342QFW7yEZZgstiPXY6nsAZeqm06vBWbWx+SxUWojymoYSGWTJZkW9 ALrJpcB843c/qjXqrrtwFmjvzJVNLGQp0m1hydnnQXrVOFSEBuJOLEnKV08jbxQMVoIsrpXqWxH4O j2z7X78g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JP-9L; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 4/9] mm: Remove some calls to page_add_new_anon_rmap() Date: Mon, 11 Dec 2023 16:22:09 +0000 Message-Id: <20231211162214.2146080-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 505D280031 X-Rspam-User: X-Stat-Signature: zrg3eka9haurqsaokew9j53u94ax5z61 X-Rspamd-Server: rspam01 X-HE-Tag: 1702311738-839188 X-HE-Meta: U2FsdGVkX19Mo6m8zxuhadsnb4R6qcDBBWJLBBE7IxdJMfASKPo8NbencQdp7Wzhf0J5XgNQ7oCtXXS6HW420EtN4vDK3G7mL9sorkSSf/LqapyVnZcwB+xN6oBW1GCGRr8zllFVbPl8ncLMqVcJx3Fl/Khf4LA8T2BdLDZCPxgqU0XLTphp6+q7zJusOS2MwNTiBkWl1qNyNK1HCm2icgJXPku2MgbPUKGvATxSOzmDffDmjXOTWfQxUJ5nma5aD+3AtoDgjs5O1oTsN4FuTBaat+mKycY8bMEa62fWKck6VRsW6so2i/K/dZP3ZHRXCRp6G+cZFbkNB7xyNhJrazeMvxS22pu7e0NDbsWiMVHw8UH8fJk/C9kYDvs/CHbgrHzc3OXiAbJqkPV5R9aKeg0L8o05qZHJSeew+l2yqgR2zRd6BCm4N1vtfO8dkR/i6KJkFps7I9dTIiUgzczOUlyctK1qDD79rCF8bPZd0eAy+Ua789dpQxjbeaymSSjTDECGguYmohH/Y+WuHC2gbltcmH4mJdPNBR1YTvjJC0ZobVZKiAvdM6bpsMc4p3kNVx+Zp6Deh5ARKlxReR4te14H4YJocxo3AeIXruI2DXEWXy+aO51ZqJ6mdSDkUQeqsUVLFcTS2ZXS+SEnZwYUvJXUjh1oWFcfgp9grU8zYfX0i3N7BPvKNb3jo1+x3BTG6fKAZK2qUqPaC19vPLABWY2BZ/S73TAekLMJjUoFPxPUREGQlFEdpiw6Yt5FlA5qYqGKZkjmmmJ5OH9s8nefa6FgHAZ+sjEbDEIp+OMtWaOyH/xXerAk2OBVin3Twh8nnqXXQ8r7kDrpkWxZXfa/Cv/oV1GKkfc6feAKkC7Yh8uqAbdZcYEcL9VBIcPIIqbZh3+3OS2/ZS4ywMzXQZ0EWMlVRQfh0x/p4dk23WWHpdZPH/FOZ2rfkKQjwXHhf0vIA6jhf0z/FezQmx56B9o XXLoTsqU RqrWz1aX1WfnRfhktFk+p5H2kpX+Wi/6pHjnhDZ6WSi96cKQxcYLARM2vCki6dqMjdF3FNhg0dok4C8srp41G/f4Pdq7iYar4O0DA2n9ZUvzujXXdZ0vPHueMiqbVFs+sxqDW09aE2e/7hZBJBK9E+vHw4nB5TOYSXU5FNWUon8/ez3E1jQ/PKp8uRssu7hn0fGYQB70LzTwWVaKaDJV3W+nfrP3w48fZhIfX 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: List-Subscribe: List-Unsubscribe: We already have the folio in these functions, we just need to use it. folio_add_new_anon_rmap() didn't exist at the time they were converted to folios. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- kernel/events/uprobes.c | 2 +- mm/memory.c | 2 +- mm/userfaultfd.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 435aac1d8c27..8b115fc43f04 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -181,7 +181,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, if (new_page) { folio_get(new_folio); - page_add_new_anon_rmap(new_page, vma, addr); + folio_add_new_anon_rmap(new_folio, vma, addr); folio_add_lru_vma(new_folio, vma); } else /* no new page, just dec_mm_counter for old_page */ diff --git a/mm/memory.c b/mm/memory.c index 318f923134e4..c03a7729d5b4 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4068,7 +4068,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) /* ksm created a completely new copy */ if (unlikely(folio != swapcache && swapcache)) { - page_add_new_anon_rmap(page, vma, vmf->address); + folio_add_new_anon_rmap(folio, vma, vmf->address); folio_add_lru_vma(folio, vma); } else { page_add_anon_rmap(page, vma, vmf->address, rmap_flags); diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 71d0281f1162..2d8b03a009b4 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -116,7 +116,7 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd, folio_add_lru(folio); page_add_file_rmap(page, dst_vma, false); } else { - page_add_new_anon_rmap(page, dst_vma, dst_addr); + folio_add_new_anon_rmap(folio, dst_vma, dst_addr); folio_add_lru_vma(folio, dst_vma); } From patchwork Mon Dec 11 16:22:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487538 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 9CEE2C4167B for ; Mon, 11 Dec 2023 16:22:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 222116B0162; Mon, 11 Dec 2023 11:22:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A8AA6B0164; Mon, 11 Dec 2023 11:22:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 054D96B0165; Mon, 11 Dec 2023 11:22:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E44B16B0162 for ; Mon, 11 Dec 2023 11:22:44 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C069A1C1003 for ; Mon, 11 Dec 2023 16:22:44 +0000 (UTC) X-FDA: 81555055848.24.1D11859 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 2AF9710001C for ; Mon, 11 Dec 2023 16:22:41 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="J4zVxej/"; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702311762; 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=kIcEVcsVYWLjUXGY0/7qrAb8qfK+YJ2xz3XG2UcayEI=; b=6dUxr0WpMSuNOYynja+XTcRTE0FgRD/R/SaNcZGgVJetakK9+z4tru7pWmIvAPAwN4kTrS iRjavmGzt5J0oORmCDGNKOdsbhvtWIQVxZd5RYEypM+3GSuFOUbz+UEjiaXjc9HuKLb5TA 1KJpzh3EyX/vPR13rpDTf1NaclRISg0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="J4zVxej/"; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311762; a=rsa-sha256; cv=none; b=aeHgZzAdBQrXK9BzXqFkvsRtt0JPpZXhezOFjhWRPv46ulgxavQWF2RgezN98Wq6VG5v3v aIqpLCGqX5UH57wzT/9SKKWtpivNompstC2RwggrHvL8Rz5YSDx6odW1qc5Nm8NgEf95IE JRI11Rlbj8tV+zWnI+BH3P4tTCqKSQY= 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=kIcEVcsVYWLjUXGY0/7qrAb8qfK+YJ2xz3XG2UcayEI=; b=J4zVxej/e+/3h1Q8YXWsGB+T5O G0mSywZOq1kYrbz+zFdzN0BPvmJcNGeguqqNCd2bdCGQ/Sem09mXP8VonTrsKM1dDi9ZgY2S3RX+r wLrbdWZiUN36KeZ4o7WQbA0ar9FzQcwyU9ykfiiypRKArEgw4SzhEIaHRlmGrv0TFVglnxiDqpFRo 41zrlc9GB7Gau7AmikiM+lmDpgNHCmEJZ+eEpgNWzLnTZCmS17otezi4DeA1WpMvbDqVmdCjY5KnY wHMyQaRzSivC2p4muUlDNbnJIja/tpvAYNjEANmYM4EzFhiPpM26mPh1PZZ/ByOHPg4VwLZ7Z0NDT mqr1M3+Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JR-C4; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Ralph Campbell Subject: [PATCH 5/9] mm: Remove stale example from comment Date: Mon, 11 Dec 2023 16:22:10 +0000 Message-Id: <20231211162214.2146080-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2AF9710001C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 3zy17gzna58151bb4nur8injj7xspsec X-HE-Tag: 1702311761-595092 X-HE-Meta: U2FsdGVkX19+0xBRn+rYAOZqM0FmtKJsMw2RAg9H2R4pmPGqG1/1fehNj5SnTaCcfQUKBhS3k+gLuhstp5ugtRoChuloA6rslWxio2uJ7qrDUw+ManqlNipxe0VVXwoFklnTgREZhf681hceto4mhK24kH9DTs2bamRnOKXITUmu8tiqbEkXJlW1njXq3fgixra+WurpA2fmLUt27qtljUbpAM88urOkFrGsN4IgwIYmFBzUoyk4pM+K2LYbXCMqDJemNbiD3Nx/3QttajX3QJ3VuAP+06tan1D536teh41DF4c9zn4f3/K1kYkqMlNWXR5SuhaVGGNhgLicBo2yzb7zFR/xvuzQX/ZpbYrCk2pdqs/5QBfFtFzePqDQBKOkdE4IRHQtCtFOBsaW5SEB9fz8tHWeVhcNA2neSDDfL1fdCI77n59vUoo72pFqRVToUbRZkn0qC7XzmI3r3EAILrHlOBCNbwXjcqTZevOewbiLCDB4/umrg2YOEiTJEoHyGDAUGlo5wHxjKc4f1tSd8kgiVVcoGw9srXNZS+f+lmhysLseMQbbk1QejyGaDqoDDvWwQxdjnZ2QAgMeEIraQ2ubrNWPD9zdnBUX7LSkkSWE65vci8E+ZnTjG9Mj+64x8rOZwxJBpGVFaJ3RNj7hs1dK3Vrat632iPO2Py7bKrr1rbsr2MGy6XsQTZgAnQQu71mhQE/uJl/ZEQmtDMwGAe0XpNxeTDw/9pKORdM1GUbD+2/UPqiGaZ+fBBGs8WjUZxVOatHHWa1TsMPN7Y58LiZamOA2CSarKiaOMeAl8r/QQSaxDdJ+G9JGdKYxhovMu49XIIcx8CKeEJzt+FPWh6lZfsUZkpJKEWan7Up3A/4TlPW+zy0VvdmHEhBF7CPPUDyukmFN720o7iQHR4k/Ut4tv0iCu/YCjLI94Q+Fsu/vLmI5hvnTFHQMKy+1YaRDOqFLuADDXW/6WNND8oX xPkssofX M0iqTFu8NQIgNiYyQQHjdeU2EoqYJZaZ1r0yqfYiPYMRlc2pJj0juj5LtmmaPBwsSAHfQ+N4sjCNN3ZbUiBrdRKTxGcw+Kdr/hJP2Tw87UrxGi00/Y7jcw8LS7yPEkCTca29cero6lxeuAz3lwC+s7YX+Q346R2iNGDBBrKTsKRBQp6wM3ipmBvrPLcQcTKrMh617mm0IExi9frY= 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: List-Subscribe: List-Unsubscribe: folio_add_new_anon_rmap() no longer works this way, so just remove the entire example. Signed-off-by: Matthew Wilcox (Oracle) Cc: Ralph Campbell Reviewed-by: David Hildenbrand --- mm/memremap.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 9531faa92a7c..9e9fb1972fff 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -473,21 +473,11 @@ void free_zone_device_page(struct page *page) __ClearPageAnonExclusive(page); /* - * When a device managed page is freed, the page->mapping field + * When a device managed page is freed, the folio->mapping field * may still contain a (stale) mapping value. For example, the - * lower bits of page->mapping may still identify the page as an - * anonymous page. Ultimately, this entire field is just stale - * and wrong, and it will cause errors if not cleared. One - * example is: - * - * migrate_vma_pages() - * migrate_vma_insert_page() - * page_add_new_anon_rmap() - * __page_set_anon_rmap() - * ...checks page->mapping, via PageAnon(page) call, - * and incorrectly concludes that the page is an - * anonymous page. Therefore, it incorrectly, - * silently fails to set up the new anon rmap. + * lower bits of folio->mapping may still identify the folio as an + * anonymous folio. Ultimately, this entire field is just stale + * and wrong, and it will cause errors if not cleared. * * For other types of ZONE_DEVICE pages, migration is either * handled differently or not done at all, so there is no need From patchwork Mon Dec 11 16:22:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487537 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 01393C4167B for ; Mon, 11 Dec 2023 16:22:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68F4B6B0160; Mon, 11 Dec 2023 11:22:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ECAF6B0162; Mon, 11 Dec 2023 11:22:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48D766B0163; Mon, 11 Dec 2023 11:22:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3851E6B0160 for ; Mon, 11 Dec 2023 11:22:41 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F3FE2140779 for ; Mon, 11 Dec 2023 16:22:40 +0000 (UTC) X-FDA: 81555055722.21.0F1AFF0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id 28F8014000E for ; Mon, 11 Dec 2023 16:22:38 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Lr2CTRVJ; spf=none (imf09.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=1702311759; 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=33KUUF/ySimUhV9jASeOjZ5zL4N9XyyJWR+2KJrx5Hk=; b=f6QtW8wvWEjL4USPrdX6kdfmz3DvVHHo/RWFpV9r9pZFjj5r/w9J7xRba6TfaxVES7TkhM omqPwmSpQ4zhAYWl2RFNJ3t+bEhmnJBPiUTi0XvVhPxzMBDqtQ6QDu+IKD6UwHvMvua+7C /cypiIhL4cFmIdNCvhn9+utj/rL3SuU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311759; a=rsa-sha256; cv=none; b=imKGu+xrRyxUKnXdPdClbcffbp4xVY2JiL0uu032WQXuUvb/0pQg8P045HcyQtkGfxIZHw 0QqH86Xx11USmQx4qgdxRYqc9Hjk+kIEH8b9nuzfAzZBmLfYhqG0/6GBWKbekOmKe9MX+n a1DlCbyh6FjWWR5fptpfXUqU80rE7wM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Lr2CTRVJ; spf=none (imf09.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=33KUUF/ySimUhV9jASeOjZ5zL4N9XyyJWR+2KJrx5Hk=; b=Lr2CTRVJADfs0+EaFov/fgR9Oe gSco9XGKb22BcedR5gqVmkPqCXQw3cGatZt4b3B7HnMrhBIrC/xsltH1dpGvEgowmuXr9P9p3lltY ygoAXrYCubX6QKuQD0bxj5eq70HF5Ax2j2+FngC2VsYkeZgQBdCXkf30rkexFMgTEvi0dc8ybbJoT HneM6bMuMG7BTAY7+5rUMHP5ISyDf0FtrXNkqzFDt7LzTJ99vx/B/N47H7deLxUHcO8BGsVeAVovh IPzm7hW96KcM1D5vRCXA7N8zTbYnOd8ZICgo+VWmxAJ4NS/6FOJBFziGKKaWvc9wrTdju9tPyZLsf Rt1ntwOA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JT-F2; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 6/9] mm: Remove references to page_add_new_anon_rmap in comments Date: Mon, 11 Dec 2023 16:22:11 +0000 Message-Id: <20231211162214.2146080-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 28F8014000E X-Rspam-User: X-Stat-Signature: ptmad136wdqnah8kd133ncks478x45q9 X-Rspamd-Server: rspam03 X-HE-Tag: 1702311758-802506 X-HE-Meta: U2FsdGVkX1/wn02higJFVHHwFdLcXaLWLdZvny6rsCS0uS8KfIUUaJxDjvoLx4behIz33ITUj5SzZFNTKBqPkt7aFOevXpANcw3kmxSf6asUQDx6vW1KvWZu0BI6l+xjK3UD0ZZp+KlFZRaJH0NcQmYGNYYoJHOiN232x50zdTILF+jN3PrHWe5F8projFbp+zOerDgQsrSTrSKIvPKByxvzyBnoMISWq1HS54UcglVoHX/bTnyvMpy8pNHlYNpC+GkLZqoL+51Jmt2JglFIHsHwpzWa3IYpWmbdhqv9plSeltZJaCccAA/W3b5iEvr5A7EPrjJ7hBeqGE6QdABmX28SbGXKpI/cdnn1I6zjtBhwFLnHsmcwcENGU/cypGa9pg7I50KiTZdu5jmGYm4EoHXAHelnlMkhDV8Vo1lgNC1QgGhELQa1H4PFaam3IqyywceElseSoJyk5Vg7mad6oAChPxB48xxwhYK4V6fxWBiGSKis9BG1nWe6A4tZXUKzz1ob9c67tr43b9JJqwQwJr/ZEaft8zWDjZxC720NqM9sFNf/wrJnxeDSera6C73nqU6gezhc96FHrl5WSZbP/9oZnkGmXZHnyQUwx4uSr8Pw6Ea4xTdjTDYTFvNL/bCPa9iEV0EWFWkGk2+HazY7Oz3gTFHpVfToNy9cFksQ+eGZJz3Mrii1eiq7gAKFETfEs5+SoBoIWALpPzwhPzyFCf7+lSgxGZFAsKpscFMYc3RXYEWj3xSv9X1MB6dpMONtXXNKcWt907pyzR5br/k1nFHOSRqWMyQj8Om++Xcq5koUR1VdU3AWjmOcGKVykKiWl3HS1kJzcBIWW165pwSftCf5/Alnzs2My3Ldg2b2a36rjt5On0ILloKEYtw6lJrEbzMIjVR25Vt2NEKWqScDw/i2/Pz/BFIPrWp0diNYqbFvoVnB5CVMAPeyYaeTEYBZT608YybqTpBQHak34mS sinNjVjd E4pgd5ALwhsCQjkfyRz0Wc1yIup8rGsHBqIYctr7wcjy4fOdWRvHS9B/ly9LrmOvzuXdpCxNdV+MXjZ8PqL66y2RGzNZWY1SMYBA5l0ZuMeTsZ3+xwnGZL82fyGeyy7iMW0LE6rCjGL91BTv/k1fp0o/ryWkG7hYAlCZ9SBj6AZOqE8W1poATFFw9GtpsoK7GxW+aNcIZ2aw90aS7A+NWrBC4TA3BdfRfciTFo7DJZhhEVHAoshXL//9z7uP1RvUHoyL2 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: List-Subscribe: List-Unsubscribe: Refer to folio_add_new_anon_rmap() instead. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- mm/rmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index de9426ad0f1b..f3d49ec197ef 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1231,9 +1231,9 @@ static void __page_check_anon_rmap(struct folio *folio, struct page *page, * We have exclusion against page_add_anon_rmap because the caller * always holds the page locked. * - * We have exclusion against page_add_new_anon_rmap because those pages + * We have exclusion against folio_add_new_anon_rmap because those pages * are initially only visible via the pagetables, and the pte is locked - * over the call to page_add_new_anon_rmap. + * over the call to folio_add_new_anon_rmap. */ VM_BUG_ON_FOLIO(folio_anon_vma(folio)->root != vma->anon_vma->root, folio); From patchwork Mon Dec 11 16:22:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487534 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 47BC7C4167B for ; Mon, 11 Dec 2023 16:22:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 668146B015A; Mon, 11 Dec 2023 11:22:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 619226B015C; Mon, 11 Dec 2023 11:22:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4199C6B015D; Mon, 11 Dec 2023 11:22:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 26FE96B015A for ; Mon, 11 Dec 2023 11:22:32 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 09DD4A1BCF for ; Mon, 11 Dec 2023 16:22:32 +0000 (UTC) X-FDA: 81555055344.09.D8C81A3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP id 5BA06C001C for ; Mon, 11 Dec 2023 16:22:30 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lqFIwyUs; spf=none (imf28.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=1702311750; 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=p/4ibDc02LREHfNKAqGjcw8GKUvCcq1xLtUCwg/63T8=; b=i3tjrAXYiqWlJsgPl55nfO0AZJjGJPc0h/rd4FymDuYcVaY3uufc+7Vp/ra83CyKYLVT2b +8Ov5Qz6GlkVWmkralKHdRW5otGwXibEbG9M32Fpcg8eAY8L5H+oNNtM8AEhamYEMK2BPz WOVnOeAMy0YCECmUvuUDWD145N8YAFM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311750; a=rsa-sha256; cv=none; b=XL5lo0ZGTmq5eFF8Q7aED0drazZrYT8WcAtiBbLI7n9EPQX6/pddTS7wZrPmzXAgdoGG0t FcyxRMXSB3d3LHVVLDf7WqapncFs0Q3Kc6d8Y4sLql7FgspgkZH++hHU4pVFbpE3BtQEA0 A5Nx51WXTV7RpL8+npNTDJLb75lhV/o= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lqFIwyUs; spf=none (imf28.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=p/4ibDc02LREHfNKAqGjcw8GKUvCcq1xLtUCwg/63T8=; b=lqFIwyUsA0071p54wMX7oajykx vob5x7B7L/HyhEtuFnXlDLfkh58NFnIkCM5M9yyXCW0Pcr/fzHy7hnfO0l6azluOa8ki0sT4CBxyh KhWS/v3N8s9mSgqG88pP3+oSGpxeBeWD/GlOkiN4OZnLEZCjWZUMggXaoZOhwMNCdfxbgHe5sxsGz EFU+/632GvbU7vAhQUF9exXFeasmCbVcLN1jn89N6p9OXMWPCSLo3vSkbTvluzDNr7/SiauZLlFcu jWbuVtd14xuvk3LbsFXoqeWUu2yk1q61gHWA5813glM+TBm1VDYzwO0c3PP7+qZEVRN9mbA0fEyv0 gSvi+RoQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JV-HA; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 7/9] mm: Convert migrate_vma_insert_page() to use a folio Date: Mon, 11 Dec 2023 16:22:12 +0000 Message-Id: <20231211162214.2146080-8-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5BA06C001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 3nzsfriy66e61kbzstrds8dx4pi8nqh9 X-HE-Tag: 1702311750-374492 X-HE-Meta: U2FsdGVkX1+vWNPW0y7hyUhFmRRpRMbXlzoVo8W2lGBRvtD7u49qx118p5h8nPwDay0qhRq8eabsqoe4JKjbpF+4qYxILELXVOExu5zLx7WRYBrZheOTL2AdkDHP6cNCCyMa0at5DpKTj2B9Zg/yprBmm40DwwpFGYRQe14Zi33CrUoHJjgCH+AolxjYypU/8o+Es087d8SxOkwPAuMQc82HMGtrHaVz9QhrVQRo+p/DlhPosq4tA9Jm5ECtGS5HVTJJ583cP7W+KVFo/0Vnzu16rayZQSlTs4rw6+7kPBTNZfHJgEoJD1fG+wFuAE0iAa54y2+ZXwKMpjs6FBWL3atYgWlAQsqnM3X+MF3DYHeEek3FiONRQoQmhFMLYjYcWPt+5IMWwtCvwJjlHMN2y0Qls95y45HnXZ1bZupc4o0Ip3N14KBUy06dhTv2Mz5GVDTtbJ3RnD+wJcwv71uEErVgU9176kBgtWKZga/sbtHTJnDFl2a7ODqVZ++QtETAiZbtC7X7ukz0IbJRS9gEUjhP8K+5egXMivYmuKvBcRY53eUQeazGx7TGh8LLGmv+3+a22FRJEPmzDZ6yYXjpjFR1x6KwTatIkDYEyLma71nBO4Bhw+L+hzDIZbGn2Bo3kb3WVx5jbXkRfDG3Y0UkLMlUs/JKp++R1l74PtYoG7a4LsseJO3CHOk6qUZWybaktZwcTjVlOfUbAGP3vqZNvx6c5gBh4hSSUBukuWenM533e7CGLMhfouYncIlNPeoPbVuVz82U6L4p8Q50xnlw/u1WAZHRm90ywZyRoC+mwVfD3QLipNG2G6FjK6XwgFvufjFvmV9d9NPjz7cwSVtVZcmDfGF9EaJxS0YS60LNqV1j6SyWpL9pFtM+QXFpGMYthNTUzOtrUjOdDU8A5WL8S8Pr9hh73EK0uEZcG6jEhnuNCD5bciDQy3v6PQ5WTBrD7LhCdgO7T7jYXRylqRW /sbnt/Pt sLsedqF7Ta66N+7NQ9RJadBRZP/b6LHivpdnx718dRrJhwO8818DNIhB9nVq4MQ35BRYyIYxbFCqlGEV6SnCvzW7xMTWuQwPL8OTCop0dy0O3b008394T1S3jTwhdjPb+N3qg//Am8FOrQqZa2SSQRrC55GsKaJFeG2Lmud/8ClKJ7WMn7mtVO0t4YLwS7X6NY5mMk2SPAmJcPeXrKu+XBD2AtK9pm4NGgqoV 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: List-Subscribe: List-Unsubscribe: Replaces five calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Alistair Popple Reviewed-by: David Hildenbrand --- mm/migrate_device.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 8ac1f79f754a..81193363f8cd 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -564,6 +564,7 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, struct page *page, unsigned long *src) { + struct folio *folio = page_folio(page); struct vm_area_struct *vma = migrate->vma; struct mm_struct *mm = vma->vm_mm; bool flush = false; @@ -596,17 +597,17 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, goto abort; if (unlikely(anon_vma_prepare(vma))) goto abort; - if (mem_cgroup_charge(page_folio(page), vma->vm_mm, GFP_KERNEL)) + if (mem_cgroup_charge(folio, vma->vm_mm, GFP_KERNEL)) goto abort; /* - * The memory barrier inside __SetPageUptodate makes sure that - * preceding stores to the page contents become visible before + * The memory barrier inside __folio_mark_uptodate makes sure that + * preceding stores to the folio contents become visible before * the set_pte_at() write. */ - __SetPageUptodate(page); + __folio_mark_uptodate(folio); - if (is_device_private_page(page)) { + if (folio_is_device_private(folio)) { swp_entry_t swp_entry; if (vma->vm_flags & VM_WRITE) @@ -617,8 +618,8 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, page_to_pfn(page)); entry = swp_entry_to_pte(swp_entry); } else { - if (is_zone_device_page(page) && - !is_device_coherent_page(page)) { + if (folio_is_zone_device(folio) && + !folio_is_device_coherent(folio)) { pr_warn_once("Unsupported ZONE_DEVICE page type.\n"); goto abort; } @@ -652,10 +653,10 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, goto unlock_abort; inc_mm_counter(mm, MM_ANONPAGES); - page_add_new_anon_rmap(page, vma, addr); - if (!is_zone_device_page(page)) - lru_cache_add_inactive_or_unevictable(page, vma); - get_page(page); + folio_add_new_anon_rmap(folio, vma, addr); + if (!folio_is_zone_device(folio)) + folio_add_lru_vma(folio, vma); + folio_get(folio); if (flush) { flush_cache_page(vma, addr, pte_pfn(orig_pte)); From patchwork Mon Dec 11 16:22:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487533 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 A5251C4167B for ; Mon, 11 Dec 2023 16:22:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1EC06B0158; Mon, 11 Dec 2023 11:22:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA9F06B015A; Mon, 11 Dec 2023 11:22:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 949416B015B; Mon, 11 Dec 2023 11:22:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 83A236B0158 for ; Mon, 11 Dec 2023 11:22:30 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3F0F71207A3 for ; Mon, 11 Dec 2023 16:22:30 +0000 (UTC) X-FDA: 81555055260.08.5891D6A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 51B5D14000B for ; Mon, 11 Dec 2023 16:22:28 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=oQVjwU28; spf=none (imf23.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=1702311748; 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=zoQam+lgSCVKznPzA1mgGP6oN8kp6O3aIFrPBTA1x1E=; b=E8GuWW7JcqTkDJCmDddARC88lBm7ck6VoHdNwajSASSfUfCj61Ajl/wwjIkO3BV0DVU9HT MjVqRM/NhsJNf8US5aUsBHQW0v70RPTnV7i9RGrNLFpoa0YrQM9hJMxQHXHjejs/pw5Xi8 2V2FDaPwVTVB3MjRyO0+dXwXspgu1gQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311748; a=rsa-sha256; cv=none; b=0h7NJ11QQXf1YLIY6c05l+D3vz+h/HTqgwdtzfJosZDVFopCVpq3LQ3jHnZFsSFbmVmail 2f0c9hjjdBGWwNyvj8T/U7NSQ1bmWSIatXnXz5+jf3hcqsyvh2OqqPRayFc9bs/uP/wsJn 2/8aL2AVNF2Tfwe6b2iAUtml67lpPyI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=oQVjwU28; spf=none (imf23.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=zoQam+lgSCVKznPzA1mgGP6oN8kp6O3aIFrPBTA1x1E=; b=oQVjwU28l1GLpq5GtrmYSry025 KTC4QC4rtkH1XvS0Lwz8opHa0Byprx9UDf6+IJddV80WT78Docn6bEOvYPqVUZDOBLnLovYacmmer EqHAaThJ87Qy6A23VYAvcOpr3jek6wh2aqin31ywlEyjmnPO4Y0NjyMVc7YngoRg9HUGnl4mxJGbv qLDBlgQwmoOLcMNXo0UPo4mIgAmBbYpCqWtpjuulyEHdcd9N/UJMbM5YZuYx+NqNF0vrb4CBpu1rb vJBzF6bhSr39CZX0iPh9RD799rmUnnaLYjqX7QS9gVLlDv6UgWYiDVo2Npxz4Y9nVx9iyBKSeOrpe Z/IkXLwA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JX-JT; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 8/9] mm: Convert collapse_huge_page() to use a folio Date: Mon, 11 Dec 2023 16:22:13 +0000 Message-Id: <20231211162214.2146080-9-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 51B5D14000B X-Rspam-User: X-Stat-Signature: 3pf8599w959a5k73gaxw9dgr9mt8ugyy X-Rspamd-Server: rspam03 X-HE-Tag: 1702311748-462447 X-HE-Meta: U2FsdGVkX1+koJTe+i+/5siPTkg0wVDRBIYBbDAvpKEoMONFCllw5QPjWzzcAXRYVfYCcX88th4txARJ5pONGPxoPD5QXlLiOPbWbq1tjwTUJ/8slUd5FZjaHtfWN8TmS3qCNKXT60Z3gCCk5oNms3ghYDV4j2l9Trv0RzCvtm8tJ/+IZSmIQZRuzOO0fQcYcZ3nfjGSng4dcCLVxMqE7qxYbTFb+dI1TXr/bfqNnjzswIUBqiUx92hOlfaRxcMwRhmbCDhKN0zzhyaKH8Ap4q4QCGgusmAIpkz/8DV/toArwD9Ykt85BNo5ZmKKaM9VCwcwTBsBfH9+O2D0CzHiFj3v5Qis6NuCjMrX0m9VqDgkJzBVmYSWYLvbMVZN0Q2xnCPWPn2S8Tk/FHDo7aKzcj6k8MO+4Noc4ziKFfE4dGQX1Mw0I/GmBp+oTO4sagMLZ0onE91eiDgmZ5qTHwPtXHm/VfDcOf9hkENEG/NvMvilFoR3dGx5i1Y+Ca5rbBtHUdRcDxgfMdmS/QU2mUDOclLtZGSdTlIEuPznORUPC1uTGl2L7nfP96PhJlSUJW3jnFUknNHs4WKY/OX6c3V3VLvxeZan+d2ovxqr6pDRj5uvoTgVz1TkmoWELt44mCJOzzowSwg84O+v769wAT3A9Bx12gajJ0d2Q4gZyWS6rZR6JD7RCdVX83LQ7LYb2VKpfeduirGeMCyMahqni9sjCpagnqdnlaK9NuHA9nfgT1wwX9K5CU7ietRUMHbkaIebZnh0TN3M5QC7edBWv3rHnc7nexCVqECrWGrAXZg8W3tZtwLLxK2jaOLSSjatiH4tAw4mm4ZqgaLVqUtwwnylV+8IzjQDX5hu4pOcPhpkCDqgfRzQniBfeytQXvMQmZq6TdtIHsXhz9zwyaVe/zl0DiEquKYm2DYP/kzcc88i+4AB6Mt/hMpq2ZB+YM+rhP4HJE3hz+5UZ2ns962fXYy OlW9kHHd SghL3Sf1yEsAgDEiNVdGaWe8jqTQ3uqiwjrjyyFmBwXqWAf9QkVBxD9qfgGQVmipC3WXjxuRc3saguyAB8Upz7R85DPCfWlTMqHhF8p4kD52o1PKVPdJohJFHXsmnvQsWt9PqE7r7tdcBvsw/KwETelS7I7W3XYNOX06nmyAcDg1QaJgu08y7pxEkP5a/VnDRSKIYdc0BNJPffAzvjiYZMzjI/K2D6WAo0Vrk 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: List-Subscribe: List-Unsubscribe: Replace three calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- mm/khugepaged.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index e722f754797f..f7ec73976c38 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1087,6 +1087,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, pmd_t *pmd, _pmd; pte_t *pte; pgtable_t pgtable; + struct folio *folio; struct page *hpage; spinlock_t *pmd_ptl, *pte_ptl; int result = SCAN_FAIL; @@ -1209,13 +1210,13 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, if (unlikely(result != SCAN_SUCCEED)) goto out_up_write; + folio = page_folio(hpage); /* - * spin_lock() below is not the equivalent of smp_wmb(), but - * the smp_wmb() inside __SetPageUptodate() can be reused to - * avoid the copy_huge_page writes to become visible after - * the set_pmd_at() write. + * The smp_wmb() inside __folio_mark_uptodate() ensures the + * copy_huge_page writes become visible before the set_pmd_at() + * write. */ - __SetPageUptodate(hpage); + __folio_mark_uptodate(folio); pgtable = pmd_pgtable(_pmd); _pmd = mk_huge_pmd(hpage, vma->vm_page_prot); @@ -1223,8 +1224,8 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, spin_lock(pmd_ptl); BUG_ON(!pmd_none(*pmd)); - page_add_new_anon_rmap(hpage, vma, address); - lru_cache_add_inactive_or_unevictable(hpage, vma); + folio_add_new_anon_rmap(folio, vma, address); + folio_add_lru_vma(folio, vma); pgtable_trans_huge_deposit(mm, pmd, pgtable); set_pmd_at(mm, address, pmd, _pmd); update_mmu_cache_pmd(vma, address, pmd); From patchwork Mon Dec 11 16:22:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487531 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 3AF27C10F05 for ; Mon, 11 Dec 2023 16:22:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5523C6B0089; Mon, 11 Dec 2023 11:22:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 504A56B00CE; Mon, 11 Dec 2023 11:22:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 355D36B00D8; Mon, 11 Dec 2023 11:22:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1FCA66B0089 for ; Mon, 11 Dec 2023 11:22:26 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EC4F31207A3 for ; Mon, 11 Dec 2023 16:22:25 +0000 (UTC) X-FDA: 81555055050.30.156FABF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 359E5140011 for ; Mon, 11 Dec 2023 16:22:23 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sb+Qm9Wi; spf=none (imf23.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=1702311744; 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=le0USapLJTOUpisSmyaKwJhkSbvDdgs9+BngrNFfDug=; b=mj5E7NqKH56FA13btqT74vG0QjeBrrR4HRQZHF3K4nTngzs5zpnla5ipMyLHgQNaOyOtai iL4VpymweGIqsVvg+gRrHSFW2FntYVOr5CiIX3KMCHPJhfYiLaE4GZ97cCyERFCKpmXFN9 Qg0558lxuHt4TmB6xDB9j15w0ww0zOU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311744; a=rsa-sha256; cv=none; b=lJHy4Mtmfqdlq4yaaB6A986kzC7tEEbiGct1U4OpaLbzddKXvmCpcUrZS22FQ3P/fdMR8e sDbD8XCjnb5mEcYltNAZkG74a/AdHbluArik0z6YTVBr1A+4dVgMDUxxQK6eSe9zy3x2ax Vq+5NzVuJjnOoVQdN2kSmgQCusj8lSY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=sb+Qm9Wi; spf=none (imf23.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=le0USapLJTOUpisSmyaKwJhkSbvDdgs9+BngrNFfDug=; b=sb+Qm9Wic9anOrhNK2hJ7MBiCx 93Tcx3a3pUeMck4UFVlTVZ5OY81c6o2tKW72j8dO1IYYAGt8gfPt9OU+Z7Syi5asiCvNNTD+87+k9 ctoBPzyMPK4Ln/JNd+J+Cc6CETJEuVzsvfpVicfRS26GxD3aeDnhrGFUkXHOpWjAfTZmNYNRItRQ9 /YaiuKqpH6VlowASX3WCee/WVOlcy2zYTo24nH4l/P4pNwymkFaHlRz+qhPKf+8AsImtfsQOjQ20s b+XqH7b+RRuJ5/+NptEPs3SfHCNSEoV/1nnhvVZzwigrXJ1Ft2BeaLQhLWuhpqMdWU8zjm0W5JIiA AmQIdbSA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JZ-Lb; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 9/9] mm: Remove page_add_new_anon_rmap and lru_cache_add_inactive_or_unevictable Date: Mon, 11 Dec 2023 16:22:14 +0000 Message-Id: <20231211162214.2146080-10-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 359E5140011 X-Rspam-User: X-Stat-Signature: rtersrz9xmbzu7j4yz7hokhgbbskjjtx X-Rspamd-Server: rspam03 X-HE-Tag: 1702311743-652976 X-HE-Meta: U2FsdGVkX18nDC+U+r8qCday671c/TcIOjz66MGSrPPKzOdX1WBVeD0Pa4w/wA+NKdbZXA9jNCZ64pyKbL683qjZoCWoQy8ysIGtrf7RMtyiiAsAWKoKJ/N91Csox63KxBgum1QJUVAlkUgXv0y8pcy5OHmb4LUsaH9PHujYrZRTMQWFFT6lzD6RbeprJ3n1f7DBnoU09ytAfI0sao+ToGaOl6QyQG9BsZsy1EXGTguZhUUdYf4Bx3Fe3X5Kq0E4qpf4s9mlmQS/SB9fovzZ8UBub7+RTxlIm23HejK5Q2Chb0QVs05VTktpZ3s5P5wD+LK83QubJxDcSwRPZNc/PQqEpV9vt0H2J72thWW10jHJY9UBZDv3qsIqS/fK3IqDEepKID2i3wf8Ww/plJlBwjvZkBgnpzgBXxv7bKGUanyJTnuKsYhx5Gpo14mBd2TVa5ZTWCWVFq5VI3Y8Ud1qojSfRyT3f8uFz6Ua5vvdzJ+gJPaM1xv0cY+niUkUsYU/8doWLARD1+cC8qEBv0aZIO5XGLqDmZuI4nLr5nyXXFTsW5CW7ORrX8wDNjdvBEMolgbbOXqREF5Irx6XDGsvjSXB81i8MlJAoC6A7wmhjH8+8n8Tkb0hGJHCU8xZYn2Pb6zbKBalU6HE4ItUsLc7XwgOgH5VdKj/hWQqB3SBo5yd7PDif6HeafIY7CR6TrBFk0naY/F0OToNQulVboGvaUWSAGez7TbDyI5dT6GhZ13EQmxbWLn4L9PNchPxYUXZ89RnR1YIJSaMRX4Ng+N59rCnrmT7mwM/pXgt37i9bqeTIPSdpxPfXWhNz47+nGXQuHiG0wIDj5hy7QzOtt6qdS9GF1C6nZsS/ozz9Ffq7ftqp+4BTSLCz02LGFsylrNbcu48I9nKK5Wnz/puD/8/qh6BXYGWiug9Pnm2LH2NJ7vu8aul4CYW9lipCZ2KCaPoNJOiK4aKUcdzlKxrA3T HDhyYQWP Q1VdS5jqvPkXLbsx4P2Bokcx4oxqHdDUbngpAjbb5gS1VLfOfagTDWjp3MAc8KYMjSv3D+/pOohoS+SA4RHgdIqltwK2zId+VuaCak3UczaudlYhnouJJnTydhkK+y7pqVRMUkwtLX8DhVbckM0XSnL5lTgJJHVcVkU3s6Vn6znVu7rUjswF7RNsNEDPTxcrJqJdYKowxK8aUnwT21pz/sxVVSisI3Q7USVbK 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: List-Subscribe: List-Unsubscribe: All callers have now been converted to folio_add_new_anon_rmap() and folio_add_lru_vma() so we can remove the wrapper. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- include/linux/rmap.h | 2 -- include/linux/swap.h | 3 --- mm/folio-compat.c | 16 ---------------- 3 files changed, 21 deletions(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index af6a32b6f3e7..0ae2bb0e77f5 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -197,8 +197,6 @@ typedef int __bitwise rmap_t; void folio_move_anon_rmap(struct folio *, struct vm_area_struct *); void page_add_anon_rmap(struct page *, struct vm_area_struct *, unsigned long address, rmap_t flags); -void page_add_new_anon_rmap(struct page *, struct vm_area_struct *, - unsigned long address); void folio_add_new_anon_rmap(struct folio *, struct vm_area_struct *, unsigned long address); void page_add_file_rmap(struct page *, struct vm_area_struct *, diff --git a/include/linux/swap.h b/include/linux/swap.h index 4f25b1237364..edc0f2c8ce01 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -397,9 +397,6 @@ void folio_deactivate(struct folio *folio); void folio_mark_lazyfree(struct folio *folio); extern void swap_setup(void); -extern void lru_cache_add_inactive_or_unevictable(struct page *page, - struct vm_area_struct *vma); - /* linux/mm/vmscan.c */ extern unsigned long zone_reclaimable_pages(struct zone *zone); extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order, diff --git a/mm/folio-compat.c b/mm/folio-compat.c index aee3b9a16828..50412014f16f 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -77,12 +77,6 @@ bool redirty_page_for_writepage(struct writeback_control *wbc, } EXPORT_SYMBOL(redirty_page_for_writepage); -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) { @@ -122,13 +116,3 @@ void putback_lru_page(struct page *page) { folio_putback_lru(page_folio(page)); } - -#ifdef CONFIG_MMU -void page_add_new_anon_rmap(struct page *page, struct vm_area_struct *vma, - unsigned long address) -{ - VM_BUG_ON_PAGE(PageTail(page), page); - - return folio_add_new_anon_rmap((struct folio *)page, vma, address); -} -#endif