From patchwork Sat Jul 1 03:28:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13298863 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 4765CC001DD for ; Sat, 1 Jul 2023 03:29:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B384A8E0065; Fri, 30 Jun 2023 23:29:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A21FD8E0059; Fri, 30 Jun 2023 23:29:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89B308E0065; Fri, 30 Jun 2023 23:29:09 -0400 (EDT) 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 694068E0059 for ; Fri, 30 Jun 2023 23:29:09 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 34D81120476 for ; Sat, 1 Jul 2023 03:29:09 +0000 (UTC) X-FDA: 80961612018.11.6E594CC Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf15.hostedemail.com (Postfix) with ESMTP id A3D02A0009 for ; Sat, 1 Jul 2023 03:29:06 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688182147; 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=hrDDcmHnpynXqyvywojhzhzT6+fSNeluiHTRPRkvoKM=; b=PHkrfODVxQm5lupNDq/Aeu+f7VkAVxuDfxf++AD2cf1wQ6rip/65ZSTkFSF5oxjdgAabQ+ wM55zW5BoNUBAJduxG+nrs41QBwfFCdWv0lemqQvB4Bhmz7v0nNfStKGJdDSdA7NxpYZY4 f8hjVbwNR9hZxJfvrjta5Q/Z4Vk6x/w= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688182147; a=rsa-sha256; cv=none; b=Dl3BQy/dASulbLfNAQzL5o4jb1jOeZPvjs9G0qH0F3l88ZApeIWx4zXgkwWMvhnps8DpOh FAkugc7+s8PTLWazCzDlc07jAwb5NvA2cpZMzNDdXvZnahWMhxiKr5qCQbpHhAMtvlY1Xl U+rPVMkI+X0AI7UJd73A40AtVx6B4qk= Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QtHfh1HWqzLn4k; Sat, 1 Jul 2023 11:26:52 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 1 Jul 2023 11:28:59 +0800 From: Peng Zhang To: , , , CC: , , , ZhangPeng Subject: [PATCH v2 1/2] mm: use a folio in fault_dirty_shared_page() Date: Sat, 1 Jul 2023 11:28:52 +0800 Message-ID: <20230701032853.258697-2-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701032853.258697-1-zhangpeng362@huawei.com> References: <20230701032853.258697-1-zhangpeng362@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: A3D02A0009 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: hhc8tqwxr1zbjiphw9dokahur5qb7hgs X-HE-Tag: 1688182146-26796 X-HE-Meta: U2FsdGVkX1/c6DPOZm1awvmR5A2JpfFeOUfHoTwbzVZUDiIujU3mhIWRRPKVjq7knPWW0YXi3ul5IbfGJuqngF7lR/pNbIw1cq+MiqwyJlYHCTprJaHfFGWAbcI1L4OH/LbtFf6PQ9MZ7Zmj6+/dSWDiBBuaQUF6eq5pOFrKk37+Uxd6btrROVzvGomRI77ZWbtLQBB93lFZdzLfq/+t2EGgbB/OyS0UjvtwLv7uIY38jC8KKeSGxMDiY60DbOFXzhuXVk+Et+cJOPmkxkLfDMoLwY6WtcSUN/NKIjkVsf1CeUGoaPKJ8ccl+CVA1C9UTN75Zq4lyY6BvdB9dV94e6sdlF57snPaWOjBP3dRjo1hXn30XMyEGGNj2R469Mn6u6dvTQpoBNhk5VXVVuxnt8D6oEt92bcEC5YiTIznXR216ez75g+9HHb3h6fRu6wTi4yuUuVZ4Y9Fj4tGvZ5ZtKCr0kF55b/JrvRfxFBByk+xH56GzPLmV/WLXISetIvxfeIn1YffyO/Zm38fMsIOZgskk/WK8FbFrgwKbVmTKD15y51HSrjhIFEd86g8HU8c+C8dVpttC+iLRMfBQb2eSJRD24XJTgIpMkoU4WXiksvBS/h4inAiEesYIw59r9CQ4Z0eb19L3xqpwKBhy18HItRLoOYg3cIzBaCsLYBjEuH5060vNxCHj8tYoVSPeJa2uLM8ZKv1P++AztB859/61JeS5DOyDTfLMCpOo3nIesHxtRxphSMDRWC7HenaqcIP8USTsmMy/WFFqtC9BbzyUM9yQgfcBX6msv3YKqANq3b8KXnoC7suEDw3zK/6T0RLWVsU4FO8o/fpk4ZlXWjxFSiC8Lk57FuhElVQjp5BonoUPZZtv5HRFkTIrOvdmFjfe2tEKOp5gQrLgqi0gwaYDd9athXgCLlrn+r5SD6ieFhyn1WI39AaA/1GtVqmF0i+J60gJBLZqHA1AbEwQNk To3bESA8 N66trGSwWWbSRE9FPRnpfhlKxuZJyfMWkSK417ULVKFDxKQx9YkgcWgT6I06kH/0u2Wy4kZFrCjoUTW+hj489iFQskuBSmKjURYYTyKzqkwUnK6ql11TujEONqPwef5Hi7vk1tq7suP3cluiB06bIkERMa3mSheASw3AWX9G0P4doMcqTq/rqPu/vshc/OjAuw6W+Uy/S2/qvuoagdzxw/5ww7Q== 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: From: ZhangPeng We can replace four implicit calls to compound_head() with one by using folio. Signed-off-by: ZhangPeng Reviewed-by: Sidhartha Kumar Reviewed-by: Matthew Wilcox (Oracle) --- mm/memory.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 765e5d8ed1f4..9a2f4dab872f 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2968,20 +2968,20 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct address_space *mapping; - struct page *page = vmf->page; + struct folio *folio = page_folio(vmf->page); bool dirtied; bool page_mkwrite = vma->vm_ops && vma->vm_ops->page_mkwrite; - dirtied = set_page_dirty(page); - VM_BUG_ON_PAGE(PageAnon(page), page); + dirtied = folio_mark_dirty(folio); + VM_BUG_ON_FOLIO(folio_test_anon(folio), folio); /* - * Take a local copy of the address_space - page.mapping may be zeroed - * by truncate after unlock_page(). The address_space itself remains - * pinned by vma->vm_file's reference. We rely on unlock_page()'s + * Take a local copy of the address_space - folio.mapping may be zeroed + * by truncate after folio_unlock(). The address_space itself remains + * pinned by vma->vm_file's reference. We rely on folio_unlock()'s * release semantics to prevent the compiler from undoing this copying. */ - mapping = page_rmapping(page); - unlock_page(page); + mapping = folio_raw_mapping(folio); + folio_unlock(folio); if (!page_mkwrite) file_update_time(vma->vm_file); From patchwork Sat Jul 1 03:28:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13298862 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 3AC16EB64DD for ; Sat, 1 Jul 2023 03:29:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 518408E0064; Fri, 30 Jun 2023 23:29:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C93E8E0059; Fri, 30 Jun 2023 23:29:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36AAA8E0064; Fri, 30 Jun 2023 23:29:08 -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 236B38E0059 for ; Fri, 30 Jun 2023 23:29:08 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EB8DE1203A5 for ; Sat, 1 Jul 2023 03:29:07 +0000 (UTC) X-FDA: 80961611934.19.C80ED47 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf27.hostedemail.com (Postfix) with ESMTP id C609040010 for ; Sat, 1 Jul 2023 03:29:05 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@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=1688182146; 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=ujxWhUdZ8e95tYxZPweIspq//YcJm1P8WVFMF78gXQk=; b=AAZB/R9xoBMcYK/bLsqdewlfWcc0HdJyA8LhKTcR0zePPZ8b8FG5kQRTKhZlo2haMfUmZ2 mLVuwWI6d5ytOMg/sOiEycaYQOtc2CDDOty5b36RLjDN3BgxLOYLRUrP3eplI+qHYFV219 9xKDm/EUv1FunvD3WEKhkIaA6j2Q22w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688182146; a=rsa-sha256; cv=none; b=h8yxjpdjfDOXcq11QcWP6Myp8enxzMcqGarTMK07XtMQVfl2bm5CUE2Dmb6PVGi5q8dw9s LawBro+k+kbOULaWAnHKPLzY5K9ZkitDuhtYm6lQRfbSZLVTXs8n8YRLK7HFWrusF6arTW ANXiv1fWuP7cgsJUl4zCdocTJQ+6Cy4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QtHdS5jrzzMn2K; Sat, 1 Jul 2023 11:25:48 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Sat, 1 Jul 2023 11:29:00 +0800 From: Peng Zhang To: , , , CC: , , , ZhangPeng Subject: [PATCH v2 2/2] mm: remove page_rmapping() Date: Sat, 1 Jul 2023 11:28:53 +0800 Message-ID: <20230701032853.258697-3-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230701032853.258697-1-zhangpeng362@huawei.com> References: <20230701032853.258697-1-zhangpeng362@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: C609040010 X-Rspam-User: X-Stat-Signature: 8qy3tqu3e5orq689y4sw9jb9sjgoxa5t X-Rspamd-Server: rspam03 X-HE-Tag: 1688182145-302131 X-HE-Meta: U2FsdGVkX185YgXUv+kmC6F5FTDh+yXTVN77CXjbiQ7+sQdwcjM2o/fOB2QrSoTqHHMfIrAhnW9womUbYr1aTSngVnOUnem67PE1+yHw/QRzCSr9Si+l1arNVYNuMdUq7/y3hHa/kxzypfOUap6dAZIAJDdfx46uHK5ojQoWp/Kzik9Z10VWj9fwAccpkKvR3f6d5JlF8gJq4dANS+WxICUkPaNXp1xxm6RBykJSroRgwMvDWdesvK5dXGCPQdIFfEEXaD6WXyY87YUBbqb0FCJ9UknhTubSLmX8ZjdmTncfcegO5VwwbwJ88ALqnfYjBJtbxVVoxvR6mT2JJ7rXuc+lnzhJ3VZCVRoXQBVW1SOUu7qHNiraXIeDiOpH/pPKZTQ4e2vLtRdiRu+VrUlZphrQbK6EVrxUEqWc5a8jQ3h6kIwKEMQiwQtRLsFKrlYKPjwc+X9FYqzGCC10tvlAmPkUfqvvFsVRKHOlITlDmOfCf9KkcnBN5RwwDg+HzuMSTkugcspmuUzaPRSX979rNB6Zxn325/Q3aysO7/Y7tLrq4qLn/x0xo7QrTvwYthBVzCZ2kOyeOcnQklfNP2ZKMyNxTVT52Kcl09x5dik2EB0Php+AOu+9Jizs8WAzSnRGxwPEtECaDMdWMwp/td3jSuWkmqJRYFqS8+pDay5f8KzN2VUDmUqH+WK5t0haocikcgn4GzyjCq18aQR8/uPOkr5i8h81KE9IHpBi1IFtbze9D3Fm8QS/9YpmGik8LODBxazZjNxP0vHkPyTVOsRMfkOWUsopCdcOa8w7PgV+WoxqJ+hMO0Seo3guK8ag3LTInziktyBkl8WFyFLdi5q0P8eEz7tNecDpC9kKIYl2zrJKnhF/BMsuKJq8CEWCwcc2owQrz2KF5laHRjHCc+fYZQggegUnX+EFyervBoyCrTN7y7Uqbe/Y6bMbRYYixYcHLzsAH4hmiVeLi2db51/ odOdbWWX s/BYj40yJJuJuA8EqbEDo/jXoN8VsEQd1lX6tmmhDs1go1cCjgYGGg5hMSRHXlvkCPVwWAhOdCJCkp9VaDfyPtLEu7vn71lmm001j/CozMPP7OoLnPd9nIQQ/4J0rUeh6pWLA+HUAhFL2rGcYrt1SKyBIrXPxnoocY88kzdBfLu+07e4cLQc1DNUTkWMzUK2GrnmIQC+YnaAZsDbQJGl7KjUx7A== 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: From: ZhangPeng After converting the last user to folio_raw_mapping(), we can safely remove the function. Signed-off-by: ZhangPeng Reviewed-by: Sidhartha Kumar Reviewed-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 1 - mm/util.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 39aa409e84d5..c849419c6b51 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2151,7 +2151,6 @@ static inline void *folio_address(const struct folio *folio) return page_address(&folio->page); } -extern void *page_rmapping(struct page *page); extern pgoff_t __page_file_index(struct page *page); /* diff --git a/mm/util.c b/mm/util.c index dd12b9531ac4..5e9305189c3f 100644 --- a/mm/util.c +++ b/mm/util.c @@ -734,12 +734,6 @@ void *vcalloc(size_t n, size_t size) } EXPORT_SYMBOL(vcalloc); -/* Neutral page->mapping pointer to address_space or anon_vma or other */ -void *page_rmapping(struct page *page) -{ - return folio_raw_mapping(page_folio(page)); -} - struct anon_vma *folio_anon_vma(struct folio *folio) { unsigned long mapping = (unsigned long)folio->mapping;