From patchwork Fri Oct 13 08:56:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13420533 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 D6A63CDB47E for ; Fri, 13 Oct 2023 08:59:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6CB38E001D; Fri, 13 Oct 2023 04:58:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA6FA8E0018; Fri, 13 Oct 2023 04:58:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C46A28E001D; Fri, 13 Oct 2023 04:58:51 -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 B11418E0018 for ; Fri, 13 Oct 2023 04:58:51 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8D31EA019E for ; Fri, 13 Oct 2023 08:58:51 +0000 (UTC) X-FDA: 81339838062.02.29275BB Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 1631640005 for ; Fri, 13 Oct 2023 08:58:48 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.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=1697187529; 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=cXGe+ZxAMCbzmhr4nz4OXGUo6DR8hOC6Ngyljy3RdKg=; b=TyaP38drOUuWdukEcbEuIPBgvlEgIBf3obKtUH7ofOAHe3bh7y4/MEEDd0M1y717OjoSI4 IsrH1BBW5QC5C15KFkpavJUO6UrmUD+TT8DZFYsN72nuK6+iShMJd7bLD2bNFlSDI6S0QC WEn/7NRnR3Lhv5ag6JJKU71n/katEds= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697187529; a=rsa-sha256; cv=none; b=npqYPw+lcQjFprQaqoyG7Vf0nGIABLjLkWRzpbo6GyIMuHaKexxvQ+CLf+TSp9fYfqIByB vtmEEP20HhluFBLO9gleMJByEq0ZFZmvFqqdZoru/fVEhYYeqBjXIUbBj+lgdHM6t5cJfv BGZM9hSHh0JzE9kGHL4mgjJM70rf5F4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.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 dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S6L0p19gNzLqNj; Fri, 13 Oct 2023 16:54:34 +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; Fri, 13 Oct 2023 16:58:30 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Kefeng Wang Subject: [PATCH -next v2 17/19] mm: convert wp_page_reuse() and finish_mkwrite_fault() to take a folio Date: Fri, 13 Oct 2023 16:56:01 +0800 Message-ID: <20231013085603.1227349-18-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231013085603.1227349-1-wangkefeng.wang@huawei.com> References: <20231013085603.1227349-1-wangkefeng.wang@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 dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 1631640005 X-Rspam-User: X-Stat-Signature: 3dwuig5jgeqwzbabgobs4f18oa7uc6x6 X-Rspamd-Server: rspam03 X-HE-Tag: 1697187528-646479 X-HE-Meta: U2FsdGVkX19cFYvJd09C9Fo1D9gHDHBtauStPyjL+BnbiECu/5+VLOMdjAPw2UtspVBKd7QIxqPZQQGdzF7oTHPyWWr0LuWKUwuEECDA5MxNEAcX8uhpm3KYn81ij883wQ18Whrec5aar30CQHI46O6KFsHqWPNUjiF/NpqVc+PK0S+RYl+cIDKMlZMNu6i9tkNWWw4LvwVwYCeVpu4x22cST8AVUBhJtlMhTs+yamI4HjmZCwCottNYnIcMziXnGpSuJpSncEVeSL6JXpyLerQji3tDxuRO99bNziJwFMek1TmZpW/AlX+DkcRS1qOdaaJhvJEiNuhLyHFlHQnrnBe6qfBld49HDtes2oUQXSsXDAFSfueZuqm+8BMyHWh8YJAIEq/jsesuEGsUSieKGYoWeHv5GaDCYDO5LgKAUTFLVBStVhDYsgGZPj1fWLZyLDlzuCgBdBwoZk994095ehaCNBS5G8PpFLYaCaso/PmW2nLKAXBJu/5YWVGUlfp/mFeMKj6JhX49zoK4IsO0XLx3WqxFrlnfvTpfXEO+18+G+UvGg20emWMuy7QDdQWqSit4Umsrp/kabaejd0rm3kH6X/bl4nBmUmpleAdkOPjAfQuLSP8xWKNM+cdh2u7bB2CGyvc4Z/uaJKr/a5NiWTwIoFLYzgFdgZfZH7D1mtdExlbyOfTxfwOVr99LmQFVurqzJB0jo3RFWTJQBeYVZ+wTxHRqU0PL+Jo6aBhk/wk5qDBXb35jsgNr1m+OwpSWc3E+nFQdlvQAz6iHDQjSpaz/8XPz4ARqf1I0nc/slqMFcXE36R3ng15vyhFiSIU95RGT3gl4tSwv6aJKlG7O+0lPjh7EX6IaAxnZnOrYnutc2ssxd1L4NYpfpxQ5tU7y1yZ5a9y6b84lGIRoU2VTz05FfNS6MoNgekdMRHTdZmpTzbXLJiArGEg8lq1GFHy5OjkyNhHId5QH+VUIAeO 7wtZPXgP wiCLLl7kyxbrjEUSSs4m7ZZ2q9dP8fPxbl53DfKzOxnNkxHOUOiOxko0fULjbhBbAqqDC/XUbiCCrvjDyKR7IStXdJU/XTozEU7gnqtMn7TglTqzQgLhmwGVdvr7cCpF1EabaZ8jeON5JkQcDxP+qnmR9keyetX81LhZh+U3ROnmr+9oIK3+mWwXtHG1D4P29nx9/cSrS18OvRd8= 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index b6cc24257683..6b58ceb0961f 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 @@ -3272,7 +3272,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 +3288,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 +3312,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 +3342,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 +3494,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; } /*