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);