From patchwork Tue Jun 4 11:48:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13685096 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 12F58C25B78 for ; Tue, 4 Jun 2024 11:49:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F34896B00B6; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0F256B00BE; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DE026B00B6; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) 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 4B0CB6B00B9 for ; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BFB5C140659 for ; Tue, 4 Jun 2024 11:49:05 +0000 (UTC) X-FDA: 82193035050.06.938F9E9 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf23.hostedemail.com (Postfix) with ESMTP id 32DA4140021 for ; Tue, 4 Jun 2024 11:49:02 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717501744; a=rsa-sha256; cv=none; b=szlu6OZETLE68qBwoT6okB1eIVLFRREP4UjHeVZ8R0VANeRISUSyAmItU03rOjC58/UIbg lrn8lX5Lg2JA2bd/fmKR1xCOWyvWsUy6P8CW8a2i8EqetSdu9TuJWnwvL8rY2PKot8jkyt nOlW5rqtl+EtdjyU1r2x6EVYb9HqV+c= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717501744; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Lh/cS7g9VuXtaH447d2bRpEPYDCi7h2AOF4bTzwnJGs=; b=hTzW6OfvGGTKG6DNWVhtJyyWIO0MAH+fiaKSCNgxy1rTMlrs2ec5tHd/TsBSKYOmCOO4yU WU2n4tjoK9xnq+mXRnH4pJBlX4drtkGSqm6dULCjyIphvxULm+dP+SNxI4bj7h/I46VP+e ZIyUYYIIdI10pk0MebIwzdZRh15Jcmk= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4VtpjX39l3z1HD5M; Tue, 4 Jun 2024 19:47:12 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id C1051140155; Tue, 4 Jun 2024 19:48:58 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 4 Jun 2024 19:48:58 +0800 From: Kefeng Wang To: Andrew Morton CC: Helge Deller , Daniel Vetter , David Hildenbrand , Matthew Wilcox , , Jonathan Corbet , Kefeng Wang Subject: [PATCH 1/4] fs/proc/task_mmu: use folio API in pte_is_pinned() Date: Tue, 4 Jun 2024 19:48:19 +0800 Message-ID: <20240604114822.2089819-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240604114822.2089819-1-wangkefeng.wang@huawei.com> References: <20240604114822.2089819-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 32DA4140021 X-Stat-Signature: uo1p8ibnixaumcwuhhj4kkpgsp7znxdk X-HE-Tag: 1717501742-702777 X-HE-Meta: U2FsdGVkX19Jw+cY+eccQUUUbV2JIEbAtKsvQk+IMBiW4tjoEpvGDvTMJohgQpDewSGBItnAwp8Ot14a74OVGiHrDYoqw8/PAN/6rA5GoE7bPpHq2jEYPcOb/USVx+m+l9Qhv66DoDGzGUyD6Zjd+tC47ijwxzYJx0UsazPZN4ttoXaIK1BJUKxpd4z2KYxlBEXIuo8Qgn2FaZ3rLVWAbOmlGrLzCHQwmjZayJZyCZj7mj/bFyYqzbedzH9gy9nMxV/Ck7kb7Zp6JIdp0Jj4UbzRbrZ/E1i3kFv8Trj59K3BnJFq/n5OL/WJz8PMgt/LIV0pozDI3rUtAWA+/QZBKEKYcEWQwSU9Tp7KlrtnlmikPDVYEQAb2MlXdONNMWD8tyYXXWX3omyW3nHw4ef2cmLWLprilUUOaIRdX8M+eIn+l9OKDq9DCZG/TMbWvcxXa9BCsTov/FF+Z7E3KnegvBQJuFDIVIPFSmknmKSBKvnijkfwQzkkG9rvw6BqR6dfNlNZLnH1UM4hEAgpvWp/yV036EgkJE9RUe2TYfg6Usq0HyD9D/r/bi0xR/YFHU3oZ9WXECM6p5CciHy6LiyZ0DkT/v0wHl1m2fn03bKMwVUCdbrPqVZx6kVB1aKU7c3ndhbQ1ZKREzA1qcjIUCLVeuW2Mk+UNFBy5nJP8clsDdBUZSyCKsHvPn1LlGGiJg2sc5gVhVHbtFDFd+exAQJkEgzjBoSF32GlFvCZD3I7fpHpyLdCVo7Sj7s3WRhCLeNlIFtBnHXcICK5ADQ8eBljBRngZM1smGN+ELlacR3XpDhJ3iHq66kaBi+Esx0dZy+ErE9Q1uNsY6+gziuGvM4x7t+rDGlMq8MEFsa73OGKbzf+gxrnyvKwoVQ2528H8JWZyTl32AyIbhfxHHpJyMZJnEZsK0+3EPNaiz+Euxxmd1oT2xk/EyzBG+9rWiZUOEzLx/InOfiBN5A5JZ2BbiE sIp6aSLv aDefuCz3AbECojbpzBqVhia6edofd7et/SKzt++YXHiBijJmRiOpgEs8+SG4NBikjea9j8lwK6AToOO9iKFWESin3k3ykJoUU2eq0ySF3q6+UIZaTim26WwyeNb7SGOddFcYB7+H/Y/vv7AwvwqfKxwgRfXBnbilh1tGBzZ7Am5zJSHQIT73+FfRkSGFWVtXO41tJ 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: Convert to use vm_normal_folio() and folio_maybe_dma_pinned() API, which helps to remove page_maybe_dma_pinned() in the subsequent change. Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index f8d35f993fe5..5aceb3db7565 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1088,7 +1088,7 @@ struct clear_refs_private { static inline bool pte_is_pinned(struct vm_area_struct *vma, unsigned long addr, pte_t pte) { - struct page *page; + struct folio *folio; if (!pte_write(pte)) return false; @@ -1096,10 +1096,10 @@ static inline bool pte_is_pinned(struct vm_area_struct *vma, unsigned long addr, return false; if (likely(!test_bit(MMF_HAS_PINNED, &vma->vm_mm->flags))) return false; - page = vm_normal_page(vma, addr, pte); - if (!page) + folio = vm_normal_folio(vma, addr, pte); + if (!folio) return false; - return page_maybe_dma_pinned(page); + return folio_maybe_dma_pinned(folio); } static inline void clear_soft_dirty(struct vm_area_struct *vma, From patchwork Tue Jun 4 11:48:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13685095 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 ED832C25B7E for ; Tue, 4 Jun 2024 11:49:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D21516B00B8; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A57EF6B00B9; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 863146B00B7; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) 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 4A11E6B00B8 for ; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D2A201A0655 for ; Tue, 4 Jun 2024 11:49:05 +0000 (UTC) X-FDA: 82193035050.01.E85FCA7 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf06.hostedemail.com (Postfix) with ESMTP id DCDAC180009 for ; Tue, 4 Jun 2024 11:49:02 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717501744; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oQcT3TSLznIifoSeUGxF3eg7iarZ5vTOkHox/JvFLF0=; b=gbHjDU3ZqTdLQ0KNgNOR0H7hEdZwbo92jMkLSgR5NEkGczNlAmf1Mv/T2yUEBn0KiG3hUN Thme5kN5MtDH2KQ1RuooZi2Dn/M7nmLmYLrT2sHOXG94/cYzMMIQC3pfD8clmAIl3tRjs8 Puq24zZyESQYfGAeGFLz3OQoVCid6oQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717501744; a=rsa-sha256; cv=none; b=Gm/5j1fALMQzSO5P2W2p2W9uuw9QGd+0v/e4rhBgGtqiudusdY0OTKPPZy41Xi5bk1CZ4r jySSvPTVIuwiJ6ntTC1h1MSttFLZSPk9dy/ZD0SBII6VY+ANfrHB9YUox8x1I/iQ+a4rtK Vw4nk6UwSS0rnwYP+rFh1zg80J4iyLY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf06.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Vtpgp6ScRzPkWS; Tue, 4 Jun 2024 19:45:42 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 450FE140FD3; Tue, 4 Jun 2024 19:48:59 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 4 Jun 2024 19:48:58 +0800 From: Kefeng Wang To: Andrew Morton CC: Helge Deller , Daniel Vetter , David Hildenbrand , Matthew Wilcox , , Jonathan Corbet , Kefeng Wang Subject: [PATCH 2/4] mm: remove page_maybe_dma_pinned() Date: Tue, 4 Jun 2024 19:48:20 +0800 Message-ID: <20240604114822.2089819-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240604114822.2089819-1-wangkefeng.wang@huawei.com> References: <20240604114822.2089819-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Stat-Signature: zc5w59hukby5kngidj86srtjghnsow4a X-Rspamd-Queue-Id: DCDAC180009 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1717501742-648379 X-HE-Meta: U2FsdGVkX1++HxEiFtTulDYzM+LDlq4liiXOJ0V02OcfYBmfT++FnStM+xDXaAERBSFoguMkrdIyJeUjhuHG/14lvAb8gHC6rsC89cSicJPKytdf8NTkWZAWc7HetdQk3hMA9GdtYF+BpDGh53A/vGyO93anpsht86nT5HEbFPd3U0IFyUhC/zAd9xcKF813qtn9467O+h2oY8Hpxvs7yr9dShXTThhCfGVPt0yXsJUpVpmakYlcb1OOv6tFfUbYkB0m88mCsfTWudBKBg+/4D4L5xQD2yrhjEzqBvCsHb2EI3btV5hGqoBetp+HdfqvGR40X+6l2o+TwTW8PozVwfdcRtuFZsX3deFNUzRFm3z42LXpSvdHXniY8immgvstxuRY94D7J78o5NqONBDxuPgCdIwnB50BtPu7bSzE/4Ur+uCBS7m/CvQ+CyTbtYW3bftqFMKsYviiCxtZ2fgJads2k+v7SSDSP3DH+Q7YkPEQpQkwdSBwtJwfHpoUaFfIVFOnTF1T80HYui02Jme6XmPBrnFE+tyWmb0WyYaKFLO1vhr8lUwe07v+yRqg4/WsY+nwfVb33OJ7x9RCAtP2sPcjDQm5JaOd4XW4o8Kdb/FFT1zbG7Nm5rQM5ro0m1OlzalWlq8/Ze2rxWGlJz4q5gYLaeIx2bZAvZlS+ePRDNsP6krqhfz/w7YnS1OvHUaPxvltk3ux1Gj71yc0B3C9wJY/7jV6UAe7T+B7OqcJwq4l5a/P67YIQ7K4LM/Eklb2HAtqAiXEffcORylid/R6GHofkTVjqO208lNw5Ind+6lA+v7Yyvwj2VJNqF9/NnT8liluvt6qcKZW4Q9Z2DXBiKikmt3VkW2WmHl5dRZ4C9V69wi3Rk0lcHkWFGD1OeMrvJlgCd9ZHKp2chi5tNGr9ME3jgC5J5bgv0YMrOz0eRivIWT14EF2aWk4jgd9D2/cugwSOkZ7FClyQMSoCBY LViWwHPt GHelXAiWsLgetqc2ycg3QcyQfDGueT58d5xuE6SRpn74M71ofh3Si17U/FVcrhDlvLkCdfax94fK0VzaYoBiFdqHJYFaWXh9b22LCQkLXhlPmDmQz4HUukf54DETzwEOskMuenVnJsPTvGq96/gaHzc1SRQwLqKXUk2eqmexUHXoroYLzGFXFWnJIZV7B+yBYuxom 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: After the last user of page_maybe_dma_pinned() is converted to folio_maybe_dma_pinned(), remove page_maybe_dma_pinned() and update the document and comment. Signed-off-by: Kefeng Wang --- Documentation/core-api/pin_user_pages.rst | 10 +++++----- include/linux/mm.h | 9 ++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Documentation/core-api/pin_user_pages.rst b/Documentation/core-api/pin_user_pages.rst index 6b5f7e6e7155..532ba8e8381b 100644 --- a/Documentation/core-api/pin_user_pages.rst +++ b/Documentation/core-api/pin_user_pages.rst @@ -196,20 +196,20 @@ INCORRECT (uses FOLL_GET calls): write to the data within the pages put_page() -page_maybe_dma_pinned(): the whole point of pinning +folio_maybe_dma_pinned(): the whole point of pinning =================================================== -The whole point of marking pages as "DMA-pinned" or "gup-pinned" is to be able -to query, "is this page DMA-pinned?" That allows code such as page_mkclean() +The whole point of marking folios as "DMA-pinned" or "gup-pinned" is to be able +to query, "is this folio DMA-pinned?" That allows code such as page_mkclean() (and file system writeback code in general) to make informed decisions about -what to do when a page cannot be unmapped due to such pins. +what to do when a folio cannot be unmapped due to such pins. What to do in those cases is the subject of a years-long series of discussions and debates (see the References at the end of this document). It's a TODO item here: fill in the details once that's worked out. Meanwhile, it's safe to say that having this available: :: - static inline bool page_maybe_dma_pinned(struct page *page) + static inline bool folio_maybe_dma_pinned(struct folio *folio) ...is a prerequisite to solving the long-running gup+DMA problem. diff --git a/include/linux/mm.h b/include/linux/mm.h index 28c40f68762e..d42497e25d43 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1953,8 +1953,8 @@ static inline struct folio *pfn_folio(unsigned long pfn) * * For more information, please see Documentation/core-api/pin_user_pages.rst. * - * Return: True, if it is likely that the page has been "dma-pinned". - * False, if the page is definitely not dma-pinned. + * Return: True, if it is likely that the folio has been "dma-pinned". + * False, if the folio is definitely not dma-pinned. */ static inline bool folio_maybe_dma_pinned(struct folio *folio) { @@ -1973,11 +1973,6 @@ static inline bool folio_maybe_dma_pinned(struct folio *folio) GUP_PIN_COUNTING_BIAS; } -static inline bool page_maybe_dma_pinned(struct page *page) -{ - return folio_maybe_dma_pinned(page_folio(page)); -} - /* * This should most likely only be called during fork() to see whether we * should break the cow immediately for an anon page on the src mm. From patchwork Tue Jun 4 11:48:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13685097 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 8EE29C25B78 for ; Tue, 4 Jun 2024 11:49:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A7636B00B9; Tue, 4 Jun 2024 07:49:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F19CB6B00BB; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7C9E6B00B6; Tue, 4 Jun 2024 07:49: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 5142B6B00BA for ; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F0B53A1A42 for ; Tue, 4 Jun 2024 11:49:05 +0000 (UTC) X-FDA: 82193035050.21.A27B5AA Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf20.hostedemail.com (Postfix) with ESMTP id 8C2011C0023 for ; Tue, 4 Jun 2024 11:49:03 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717501744; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QGKTk6InMfm56/Z1256R73pc/ry75YimMkrtNyydyLw=; b=OnXmXCXu9RXUsamNiNrieGXlN6WDdeIbAkWjdOq8ZyKRGTPjhvdTQ1Skrj6uLYn2i+pKyw wwUPEHYtHTci139FCtt1vdf81Ds9+oO1RfViyQtF26p44fM43WeMBu+Pc+yTz1fgVSoEoh 7XNfEUNLrOF5WFYOFHZNF5RNWecQ9c8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717501744; a=rsa-sha256; cv=none; b=ZhCCEiGawo+g30hPUHyVGysoU773DmSUmGi4dWT0OtSduI5YsgD0kpsHqzIk1o3F/D3VqI WutVLLZv5NBdAuhN4hX0SH8gqpZ7FOzcsZFccsWytIGie6rxc/zhZqRO+unat1SEwozalD Ufb721ATdAo6rbRlkseESiN+IVPOqjE= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Vtpg43mZKz1S9Kw; Tue, 4 Jun 2024 19:45:04 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id B95A814022E; Tue, 4 Jun 2024 19:48:59 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 4 Jun 2024 19:48:59 +0800 From: Kefeng Wang To: Andrew Morton CC: Helge Deller , Daniel Vetter , David Hildenbrand , Matthew Wilcox , , Jonathan Corbet , Kefeng Wang Subject: [PATCH 3/4] fb_defio: use a folio in fb_deferred_io_work() Date: Tue, 4 Jun 2024 19:48:21 +0800 Message-ID: <20240604114822.2089819-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240604114822.2089819-1-wangkefeng.wang@huawei.com> References: <20240604114822.2089819-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8C2011C0023 X-Stat-Signature: xu937gquingw9b7a666oa6wxdifdqfcf X-HE-Tag: 1717501743-913650 X-HE-Meta: U2FsdGVkX1+7ssUXQPhw/1oQt6oEFglpAOlHUq8ZduSpDHzcvZZ7GAvBbzRlcB6K5mQcamPSP3MKnvrukWdxf81V8EVA60Y6f2lYMikkdYS3efLqwI+8x2YkyzpqmjkPlvHCIF7ltqrTf/xfkSiBqXJrCVmdFsooogi3YyLXCPJeKYvjB4+YG6TQ/v7U3b/7PsjuojpKWBpHsHV1CnS5cYXPC9YF6Jms23o5oNgaVIk+loDgJkycOabq0jWENo1JRwPve5E2L63DRIMn+Ug54muC/ohmb+2/bpZoR1Dve80EgxhYNGUj7pbzgBjvfrgsdMSIYcgjcMt0zJvvwANikUVFoX8ZYrVnf3KzROoOqEpTegSpuE8nSY37WS5u/eizBOf6cQVyRXYqBJpRwUECrXNc9WWOnbOetHv64pFlqH4/mT2KTefaeA+i0aZ+w2XoFGljM0V65CYSw7FRC4Hjgb1cYqbV9uAOgKQBg0CbM7X5axL7TtxCJWDvocKSriHgQ0QI/wfSjr6q/B5u5Y8EmlsMu6dtyjSUyidXsEN+fzYWnXqVvmwJcJdLgGGN8HfC2p3bchH7iBK2OELVRKUvQFr7c4d72qoL3gXoLUY1Vbp6bQtxNdNjHhL8DqIjfYjlSlbXdObLVoo7MMr6Wd1Vl6GU5OJWVrvLE6BXL2bBNGW+vx8fgd8XWnB/+c4M+RSinYiiddCjUI5hWGwMZVtEncPDxRWgVdzZhe2ygh+/+yx2HTNDOdDgRaWiRkzhiZKaCmbxStauQsXjvM50EaXObOo8vxpaSlat5XsWdQWWm7Oa9nOfWL2GAI6mdi2TTO4uc3sAREUmw81P1dhUYESwnWvZMTBFPW9tTJdw6Txi743GsictYw0Igbpug6xY2cDR07Tg7WDAcZgbsyW9tiWaaSQ3lFbXGHDjPr/B1gw2KmEznvwpn1w4X5z44N+9xTqOXA8FVm2FjCao+rR9ACc d+6e3rrG //8lVgcT0XhUu7Lvq0pRcWcBuopcbZgVx1qV6/ALemKZN8BExBqgXPagNbqaPHPhnYB2PRIlZbN8NFrnUVaBuuE/Oa6XeoagYwc2hTQDKBzHmAijPh9Zqeynpo5dQ8cx90MltnB8/i6pS7sKaIdiDHBuWvKK6osG3+YhHwA+Wurv+XuggBJLNAqjUS4PkeFnQELCw 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 three calls to compound_head() with one, which removes last caller of page_mkclean(). Signed-off-by: Kefeng Wang Acked-by: David Hildenbrand --- drivers/video/fbdev/core/fb_defio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index 806ecd32219b..c9c8e294b7e7 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c @@ -244,10 +244,11 @@ static void fb_deferred_io_work(struct work_struct *work) /* here we mkclean the pages, then do all deferred IO */ mutex_lock(&fbdefio->lock); list_for_each_entry(pageref, &fbdefio->pagereflist, list) { - struct page *cur = pageref->page; - lock_page(cur); - page_mkclean(cur); - unlock_page(cur); + struct folio *folio = page_folio(pageref->page); + + folio_lock(folio); + folio_mkclean(folio); + folio_unlock(folio); } /* driver's callback with pagereflist */ From patchwork Tue Jun 4 11:48:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13685093 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 E2483C25B78 for ; Tue, 4 Jun 2024 11:49:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39EAC6B00B5; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34EBC6B00B6; Tue, 4 Jun 2024 07:49:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 216006B00B7; Tue, 4 Jun 2024 07:49:06 -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 052DA6B00B5 for ; Tue, 4 Jun 2024 07:49:05 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BDD5E807F0 for ; Tue, 4 Jun 2024 11:49:05 +0000 (UTC) X-FDA: 82193035050.03.D3616EB Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 3270F80018 for ; Tue, 4 Jun 2024 11:49:02 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717501744; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PkQxejsOikwI6KacOgOXV4wkUVrGWeEmS/si0bP/SMY=; b=KEzTFqoTkihhujmwXZQLux7PatwBDuOMClCKPxxiofoRZSRdfH/qW+s5qDgRuCR+HYI3un 0mC9XpzBruwCI0OxlFX01F99J6qIk+D6iAOltus43t92lMeub5/3N2aWFbcupecam1paSE uDCQ+C23VjoXsicjFkaMlxcrShLxKZs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717501744; a=rsa-sha256; cv=none; b=MWPWxECAttKlE+KoCafhmDaRSCuyS01woJAhTMrwgU+18w+rZDrFk8SngntFjsitw0dDck /WWeXxsDtrq6fT+1a0GFRkbr3/oz4pOQiLY2EypeUJg0BrTNCJ59NeEJ5y+BQoZFSsMS+G GLdVSW2Xi04VoSSv+cqn0////5SmqGY= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Vtpk0437Nzcl6c; Tue, 4 Jun 2024 19:47:36 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 3DEB9140FD3; Tue, 4 Jun 2024 19:49:00 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 4 Jun 2024 19:48:59 +0800 From: Kefeng Wang To: Andrew Morton CC: Helge Deller , Daniel Vetter , David Hildenbrand , Matthew Wilcox , , Jonathan Corbet , Kefeng Wang Subject: [PATCH 4/4] mm: remove page_mkclean() Date: Tue, 4 Jun 2024 19:48:22 +0800 Message-ID: <20240604114822.2089819-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240604114822.2089819-1-wangkefeng.wang@huawei.com> References: <20240604114822.2089819-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3270F80018 X-Rspam-User: X-Stat-Signature: bti4wg3zw1zh4nfww9dq1bzdrpje7rsc X-HE-Tag: 1717501742-10991 X-HE-Meta: U2FsdGVkX19QWJYaNG9POyHildu8ohoRzxQTrHhSA94Z7StosOeSZQTBLztlIURqloO6GCm2TOvDbe6QrreDGevoZs7OrUcUiS7oQKZm2ZUg0y1jqnINjXK4YqfJ+h9lhjBy3SEDl7xr35UY8jhfF64Q3HmIm6x1XNRufg6KYojKoqLK0ogjaGeOscbpt1bJQLussBxzrrYaoXvm9pJ1Bujya2st4NnBgkyAJ84/7yjhvsJzK/QAqdGOth776PBjh8ljIDwdz93uwIil0kWXjCu1rk/mzno8TYfkGUvEZk0+isfp1TvlvDRVGPt49CYiGnU364FX/uZTU1IkweNqmNFXkMQMVbvknrEYW+OqSLlpeFhZgcv2S6tHW5vuJYl0Rbp5fX5l2CeI8c64dBtrmhqXH0MCbgyBzyD7gCDsgFDeELB/i0lc6X9sXpRJO4sFAxPgxRtHdhwMW7tPtNLAnGrZ8tebnzKAENJe7/3wynZvnXcfJBbES11NL+yQY9CmoUMwCk/KCNX4kVMctxiZNryjvsKXykX2ALv4M+fPBmAfywzTD56ybh7GJ7y+87dsyeLnT7/oG3ovUvfg4za+dMevGRXrFaOT9u3Or5pZV3OVU6xhDgTTB18a+GlTjOL4BSRSeFLMUemOu2GwfwWtgZp+EQO//UQ/MFpZQ0iv7WeuLBpccVqBqTInfMzCbirwsaTLymaEqwvbzYW1Wwmb0oRLqvIozEsoFailiKIcsUKNm5DZfZsoYlm/odZjoyLmlqcQ8EsE+/muYFEPOvRRr6wcwhwhgWE4RBPO60GXQ6YPzigLtfxCg6yrPtKNX1tWG1Tez6gbFHqeiOTN9JNtappjd9Wzw7Go0ofbOutDmCIhZ2/bl11jO4lXFv1tjMjXrlpad6h+x6zNk3a+Hm25dowkn9BKD0c0hJqSogkF+sS0p4/5yqgz8fsWprj5CmTITXWZ7Lp2iixQaeCgkTY VWYUPOOs tVX8R9qqJMpUMpKzZvp6GjGnWoywq8S6mmD10/TZqgRAg23PUDodB/L4OUB9yjnYOqmWe1naSpWvUz5dOlRdctCNt9fhNGfPhOOT4eYudyTmmQu5NDKF/Psc5Vt9eC+BtRUXcLj4mwUxOhP9ecKyh++g1guyNGd1k0vmHrav1hvveH2WAGGYMYG+fk6uSphKsQSkd 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: There are no more users of page_mkclean(), remove it and update the document and comment. Signed-off-by: Kefeng Wang --- Documentation/core-api/pin_user_pages.rst | 8 ++++---- drivers/video/fbdev/core/fb_defio.c | 4 ++-- include/linux/mm.h | 2 +- include/linux/rmap.h | 4 ---- mm/gup.c | 2 +- mm/mremap.c | 2 +- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Documentation/core-api/pin_user_pages.rst b/Documentation/core-api/pin_user_pages.rst index 532ba8e8381b..4e997b0b8487 100644 --- a/Documentation/core-api/pin_user_pages.rst +++ b/Documentation/core-api/pin_user_pages.rst @@ -132,7 +132,7 @@ CASE 1: Direct IO (DIO) ----------------------- There are GUP references to pages that are serving as DIO buffers. These buffers are needed for a relatively short time (so they -are not "long term"). No special synchronization with page_mkclean() or +are not "long term"). No special synchronization with folio_mkclean() or munmap() is provided. Therefore, flags to set at the call site are: :: FOLL_PIN @@ -144,7 +144,7 @@ CASE 2: RDMA ------------ There are GUP references to pages that are serving as DMA buffers. These buffers are needed for a long time ("long term"). No special -synchronization with page_mkclean() or munmap() is provided. Therefore, flags +synchronization with folio_mkclean() or munmap() is provided. Therefore, flags to set at the call site are: :: FOLL_PIN | FOLL_LONGTERM @@ -170,7 +170,7 @@ callback, simply remove the range from the device's page tables. Either way, as long as the driver unpins the pages upon mmu notifier callback, then there is proper synchronization with both filesystem and mm -(page_mkclean(), munmap(), etc). Therefore, neither flag needs to be set. +(folio_mkclean(), munmap(), etc). Therefore, neither flag needs to be set. CASE 4: Pinning for struct page manipulation only ------------------------------------------------- @@ -200,7 +200,7 @@ folio_maybe_dma_pinned(): the whole point of pinning =================================================== The whole point of marking folios as "DMA-pinned" or "gup-pinned" is to be able -to query, "is this folio DMA-pinned?" That allows code such as page_mkclean() +to query, "is this folio DMA-pinned?" That allows code such as folio_mkclean() (and file system writeback code in general) to make informed decisions about what to do when a folio cannot be unmapped due to such pins. diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index c9c8e294b7e7..d38998714215 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c @@ -113,7 +113,7 @@ static vm_fault_t fb_deferred_io_fault(struct vm_fault *vmf) printk(KERN_ERR "no mapping available\n"); BUG_ON(!page->mapping); - page->index = vmf->pgoff; /* for page_mkclean() */ + page->index = vmf->pgoff; /* for folio_mkclean() */ vmf->page = page; return 0; @@ -161,7 +161,7 @@ static vm_fault_t fb_deferred_io_track_page(struct fb_info *info, unsigned long /* * We want the page to remain locked from ->page_mkwrite until - * the PTE is marked dirty to avoid page_mkclean() being called + * the PTE is marked dirty to avoid folio_mkclean() being called * before the PTE is updated, which would leave the page ignored * by defio. * Do this by locking the page here and informing the caller diff --git a/include/linux/mm.h b/include/linux/mm.h index d42497e25d43..cc21b2f0cdf8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1610,7 +1610,7 @@ static inline void put_page(struct page *page) * issue. * * Locking: the lockless algorithm described in folio_try_get_rcu() - * provides safe operation for get_user_pages(), page_mkclean() and + * provides safe operation for get_user_pages(), folio_mkclean() and * other calls that race to set up page table entries. */ #define GUP_PIN_COUNTING_BIAS (1U << 10) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 0a5d8c7f0690..216ddd369e8f 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -793,8 +793,4 @@ static inline int folio_mkclean(struct folio *folio) } #endif /* CONFIG_MMU */ -static inline int page_mkclean(struct page *page) -{ - return folio_mkclean(page_folio(page)); -} #endif /* _LINUX_RMAP_H */ diff --git a/mm/gup.c b/mm/gup.c index e17466fd62bb..83e279731d1b 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -393,7 +393,7 @@ void unpin_user_pages_dirty_lock(struct page **pages, unsigned long npages, * 1) This code sees the page as already dirty, so it * skips the call to set_page_dirty(). That could happen * because clear_page_dirty_for_io() called - * page_mkclean(), followed by set_page_dirty(). + * folio_mkclean(), followed by set_page_dirty(). * However, now the page is going to get written back, * which meets the original intention of setting it * dirty, so all is well: clear_page_dirty_for_io() goes diff --git a/mm/mremap.c b/mm/mremap.c index 5f96bc5ee918..e7ae140fc640 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -198,7 +198,7 @@ static int move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd, * PTE. * * NOTE! Both old and new PTL matter: the old one - * for racing with page_mkclean(), the new one to + * for racing with folio_mkclean(), the new one to * make sure the physical page stays valid until * the TLB entry for the old mapping has been * flushed.