From patchwork Wed Oct 18 14:08:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13427154 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 35157CDB482 for ; Wed, 18 Oct 2023 14:09:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20B7180017; Wed, 18 Oct 2023 10:09:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C4A06B0206; Wed, 18 Oct 2023 10:09:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 031A180017; Wed, 18 Oct 2023 10:09:32 -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 E46E06B0205 for ; Wed, 18 Oct 2023 10:09:32 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BEE961CBC28 for ; Wed, 18 Oct 2023 14:09:32 +0000 (UTC) X-FDA: 81358764984.05.10A1928 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf07.hostedemail.com (Postfix) with ESMTP id 13BA44001F for ; Wed, 18 Oct 2023 14:09:29 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1697638170; 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=Ydl5R/Os1oCYcNiMi7C125hjKrYLYWYSyaLxBm8zeC0=; b=tR6zJ0y55rv3qfAQm4etf9TwrhHEHHGcSoo0ninht7u7MiWHNytfEqx3nKLI1l2jOaTSoc GqaqjfTO1CEDurotkUWT4f+9O7h7r3yXEBYtma6G8s0QuF1/kf8G+XcB7HNiyRrCoBDeeO mE1vuEcjxZ9CgLw22Duh3TWp36B0m1I= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697638170; a=rsa-sha256; cv=none; b=Lssp5Bhos3r/JV18bwCAzjOBXcuTqbPssj1cGwGL0a904RWvo9oP0xkqkEtxGQrwRRIJH7 Ga/OWgKnp/F/TD/kIt71VX3RzBTszu+5tsRXkiq9GY+8Kdo48Be4nEJbIXY+AOO7/5uY9B XyB7akycwkiK4i/ckA42uO8JrWi7jW0= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4S9XhL5QYkz15NX8; Wed, 18 Oct 2023 22:06:26 +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_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 22:09:09 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Kefeng Wang Subject: [PATCH v3 17/19] mm: convert wp_page_reuse() and finish_mkwrite_fault() to take a folio Date: Wed, 18 Oct 2023 22:08:04 +0800 Message-ID: <20231018140806.2783514-18-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231018140806.2783514-1-wangkefeng.wang@huawei.com> References: <20231018140806.2783514-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 13BA44001F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: f6zc7hmy9a1ce3fmhwticmfjumhea5yw X-HE-Tag: 1697638169-414265 X-HE-Meta: U2FsdGVkX19ILv5iMJ+5t7dFJjkG/2l9PLmzHHZlDj+D5FGWuUUtT1f/YSn1Z3I9lZZLrzpCDQL/hoV4P3hrHf8xMDE2WOGP9ICLTXdtS/ov9nRuR6/L9hLlvRMcEOcbgqGgxeFwP3S/L6bS1wzfFqDQ7eVWG9vVRZwxOpuYAHnRoANJaKmdNfx5ufmQiMUpwTIsn5PIQ62pdcracfN+4w2PIgk9OGR4otbY6iNx2DeDAaKTFvttyldOAysilz0qEYjeRZebbN5BzrTWZACpYBFtq9BHDvPnqJW4S1iIB+4jwQFx7z8stw9LK6OmJbm2Cf6c5fxZ5dZNjWp8izDO3UGOe6yJQTM7Ft+uITdZncse56xrGr+ju1N/RIqej4ZOuUbGYXLAUjnRDEpwccDiAEJiHUqCWaEhZmI7cuwIrFSoTEA8F65shg0CFjHGRI+fOZqqIEQyB4Pd53bzBv4qu/SVD4pgHIIKfNw2oDTFhZhMq3QczfqEqDdYHJdO+D2qAO3vgOyjKezDtAoJKolpp6Q0WapgGgg43T8wIQpApAQsjHFgUGG4HbgLjol4Bb3Oa1dP3sZUIncJAqJTcPAWs/lLlpWcNxmy+6OuKH8+XOchdF7rnkWVbD37++QqvnMav4H7TVmzF4hZeId5/TxcAj+w2/KpxJjIElfSXM8nNWdk2dVzIEo7l421X4r/GTmqHwr6veVsa94hhDEPSlzHvh20MRO2g0mhwmiPPBcJinz/TsDVBe91lYLYm7PjYN6YdiwJ5Yh7gtSBBO/HlfDyVzH9Uz6hInzOvkpnjzdo1vEXRTI8SVfBy4fem66wSjFyBOI9McLsDtPhN+ktu6YFXKG7edD79499zbwn4uxJ60gC5qGv4H8j/AOubr0dnaY3I1MPOlOXuoHSJY6uOmSB46GwcIuaYBQ0rV3h8D9EvJ8kqQLIOHUxjtU0oezQ+NMcvpkfrgOvbnxnloIjx7H wibZbzF9 pN5JSzQnmPRgXXXUZALJv/QLhiFbk+r7juVNSYm3DaHmfoHpS05Og3SkIJeSnEkcrdGtc5ujMTTUgs4zOr1j9TuNmvN39BqXiEf+jOqHOZpSLPagKPdEAH6gbv/EJByldQ9cIQnedTGxwOauDhilx9lHII8yi+d9JdysaP+8HY5XNarF9QFzxVSXNnFhsOlpMsl/F 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: Saves one compound_head() call, also in preparation for page_cpupid_xchg_last() conversion. Signed-off-by: Kefeng Wang --- mm/memory.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index b6cc24257683..037da118f1d1 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3018,7 +3018,7 @@ static vm_fault_t fault_dirty_shared_page(struct vm_fault *vmf) * case, all we need to do here is to mark the page as writable and update * any related book-keeping. */ -static inline void wp_page_reuse(struct vm_fault *vmf) +static inline void wp_page_reuse(struct vm_fault *vmf, struct folio *folio) __releases(vmf->ptl) { struct vm_area_struct *vma = vmf->vma; @@ -3026,7 +3026,7 @@ static inline void wp_page_reuse(struct vm_fault *vmf) pte_t entry; VM_BUG_ON(!(vmf->flags & FAULT_FLAG_WRITE)); - VM_BUG_ON(page && PageAnon(page) && !PageAnonExclusive(page)); + VM_BUG_ON(folio && folio_test_anon(folio) && !PageAnonExclusive(page)); /* * Clear the pages cpupid information as the existing @@ -3261,6 +3261,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) * writeable once the page is prepared * * @vmf: structure describing the fault + * @folio: the folio of vmf->page * * This function handles all that is needed to finish a write page fault in a * shared mapping due to PTE being read-only once the mapped page is prepared. @@ -3272,7 +3273,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) * Return: %0 on success, %VM_FAULT_NOPAGE when PTE got changed before * we acquired PTE lock. */ -static vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf) +static vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf, struct folio *folio) { WARN_ON_ONCE(!(vmf->vma->vm_flags & VM_SHARED)); vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd, vmf->address, @@ -3288,7 +3289,7 @@ static vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); return VM_FAULT_NOPAGE; } - wp_page_reuse(vmf); + wp_page_reuse(vmf, folio); return 0; } @@ -3312,9 +3313,9 @@ static vm_fault_t wp_pfn_shared(struct vm_fault *vmf) ret = vma->vm_ops->pfn_mkwrite(vmf); if (ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)) return ret; - return finish_mkwrite_fault(vmf); + return finish_mkwrite_fault(vmf, NULL); } - wp_page_reuse(vmf); + wp_page_reuse(vmf, NULL); return 0; } @@ -3342,14 +3343,14 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf, struct folio *folio) folio_put(folio); return tmp; } - tmp = finish_mkwrite_fault(vmf); + tmp = finish_mkwrite_fault(vmf, folio); if (unlikely(tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) { folio_unlock(folio); folio_put(folio); return tmp; } } else { - wp_page_reuse(vmf); + wp_page_reuse(vmf, folio); folio_lock(folio); } ret |= fault_dirty_shared_page(vmf); @@ -3494,7 +3495,7 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); return 0; } - wp_page_reuse(vmf); + wp_page_reuse(vmf, folio); return 0; } /*