[-next,v2,17/19] mm: convert wp_page_reuse() and finish_mkwrite_fault() to take a folio
Message ID | 20231013085603.1227349-18-wangkefeng.wang@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1751982vqb; Fri, 13 Oct 2023 02:00:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHF3bFRNQMUQugT9HX8jTncaV7mPNg7WBDN2aSM+7AmE/Eyzd7LUxIpBeRU05zyjxzuBPz3 X-Received: by 2002:a17:902:ce86:b0:1c4:2b71:7dc9 with SMTP id f6-20020a170902ce8600b001c42b717dc9mr29432075plg.4.1697187599789; Fri, 13 Oct 2023 01:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697187599; cv=none; d=google.com; s=arc-20160816; b=oIWqcnSP4Qw1OWMw0GnFRvhW3dNewKDIl776Jrf/Xm7A4H967E05g+TJA3obqKfDJj jL0h/1O7nFbOcF/M1pbmIur+ObeKpfIFqZ87z6g2G9Hd5SmbQvOlsf7n2sNHGep2wdjQ 9KuUkL+8e2I3u6vbCngVp/9yI5vY1Dl5wPofq+cpoBoCKyBa9Iooyvtb7cL+Lbl9mBBX i+AHeQcehHWZiKMzL3rINjTJwwCL3Ig3H5IIFUxkkcDiBPVLHR2KbwYAGcKZshhFr7Tt NexmC8GC5AfYwB2l3sye1rp8/aGA3fMr2k5cIJcPY4HA7eF+NQ/UZfOl7U0CdlhWl7gL mprg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cXGe+ZxAMCbzmhr4nz4OXGUo6DR8hOC6Ngyljy3RdKg=; fh=Q+Hibf2y+6rOlBpt37Lm5i0wTMmcQsnxMBqJTtvbZCs=; b=Ah/mWXLAnWkhNFqvVN4hrhzuMcKUjUnwytQfMWxKG94+Nrxpx4F1vuvLjQCoAraovm yXlICdgCBYTJEranZS+zdSROqgfAJqJ4JIFB1BLjGhAxJkarvcL5oUu9dEbgjKV/iK3C A+ke94kZ+sox5QACM/so1np7+L214VpjNW/N2K0k799tbXusDTJQbpQT14AlIpR+BP6t m6DgFFjaadL5LmBiECmY434thO1mqLq/vG9T3ARW9TZSVRlO8VmiDf3JKHy7ogPcqnyW OSEBmWapRELYmB77PALdRiAlKcHx3Ic/57B2Yvo8Z41dJXrSqny7kSMNwerdVXYixT5H oaQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id m14-20020a170902db0e00b001bc674914b0si4284884plx.472.2023.10.13.01.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 01:59:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id CCA6D82B90FC; Fri, 13 Oct 2023 01:59:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbjJMI71 (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Fri, 13 Oct 2023 04:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjJMI6f (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 13 Oct 2023 04:58:35 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C70FE4 for <linux-kernel@vger.kernel.org>; Fri, 13 Oct 2023 01:58:33 -0700 (PDT) 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 <wangkefeng.wang@huawei.com> To: Andrew Morton <akpm@linux-foundation.org> CC: <willy@infradead.org>, <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>, <ying.huang@intel.com>, <david@redhat.com>, Zi Yan <ziy@nvidia.com>, Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Juri Lelli <juri.lelli@redhat.com>, Vincent Guittot <vincent.guittot@linaro.org>, Kefeng Wang <wangkefeng.wang@huawei.com> 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 13 Oct 2023 01:59:53 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779630184635644177 X-GMAIL-MSGID: 1779630184635644177 |
Series |
mm: convert page cpupid functions to folios
|
|
Commit Message
Kefeng Wang
Oct. 13, 2023, 8:56 a.m. UTC
Saves one compound_head() call, also in preparation for
page_cpupid_xchg_last() conversion.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/memory.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
Comments
Hi Kefeng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Kefeng-Wang/mm_types-add-virtual-and-_last_cpupid-into-struct-folio/20231017-121040
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20231013085603.1227349-18-wangkefeng.wang%40huawei.com
patch subject: [PATCH -next v2 17/19] mm: convert wp_page_reuse() and finish_mkwrite_fault() to take a folio
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231017/202310171537.XhmrkImn-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231017/202310171537.XhmrkImn-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310171537.XhmrkImn-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> mm/memory.c:3276: warning: Function parameter or member 'folio' not described in 'finish_mkwrite_fault'
vim +3276 mm/memory.c
2f38ab2c3c7fef Shachar Raindel 2015-04-14 3258
66a6197c118540 Jan Kara 2016-12-14 3259 /**
66a6197c118540 Jan Kara 2016-12-14 3260 * finish_mkwrite_fault - finish page fault for a shared mapping, making PTE
66a6197c118540 Jan Kara 2016-12-14 3261 * writeable once the page is prepared
66a6197c118540 Jan Kara 2016-12-14 3262 *
66a6197c118540 Jan Kara 2016-12-14 3263 * @vmf: structure describing the fault
66a6197c118540 Jan Kara 2016-12-14 3264 *
66a6197c118540 Jan Kara 2016-12-14 3265 * This function handles all that is needed to finish a write page fault in a
66a6197c118540 Jan Kara 2016-12-14 3266 * shared mapping due to PTE being read-only once the mapped page is prepared.
a862f68a8b3600 Mike Rapoport 2019-03-05 3267 * It handles locking of PTE and modifying it.
66a6197c118540 Jan Kara 2016-12-14 3268 *
66a6197c118540 Jan Kara 2016-12-14 3269 * The function expects the page to be locked or other protection against
66a6197c118540 Jan Kara 2016-12-14 3270 * concurrent faults / writeback (such as DAX radix tree locks).
a862f68a8b3600 Mike Rapoport 2019-03-05 3271 *
2797e79f1a491f Liu Xiang 2021-06-28 3272 * Return: %0 on success, %VM_FAULT_NOPAGE when PTE got changed before
a862f68a8b3600 Mike Rapoport 2019-03-05 3273 * we acquired PTE lock.
66a6197c118540 Jan Kara 2016-12-14 3274 */
60fe935fc6b035 Kefeng Wang 2023-10-13 3275 static vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf, struct folio *folio)
66a6197c118540 Jan Kara 2016-12-14 @3276 {
66a6197c118540 Jan Kara 2016-12-14 3277 WARN_ON_ONCE(!(vmf->vma->vm_flags & VM_SHARED));
66a6197c118540 Jan Kara 2016-12-14 3278 vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd, vmf->address,
66a6197c118540 Jan Kara 2016-12-14 3279 &vmf->ptl);
3db82b9374ca92 Hugh Dickins 2023-06-08 3280 if (!vmf->pte)
3db82b9374ca92 Hugh Dickins 2023-06-08 3281 return VM_FAULT_NOPAGE;
66a6197c118540 Jan Kara 2016-12-14 3282 /*
66a6197c118540 Jan Kara 2016-12-14 3283 * We might have raced with another page fault while we released the
66a6197c118540 Jan Kara 2016-12-14 3284 * pte_offset_map_lock.
66a6197c118540 Jan Kara 2016-12-14 3285 */
c33c794828f212 Ryan Roberts 2023-06-12 3286 if (!pte_same(ptep_get(vmf->pte), vmf->orig_pte)) {
7df676974359f9 Bibo Mao 2020-05-27 3287 update_mmu_tlb(vmf->vma, vmf->address, vmf->pte);
66a6197c118540 Jan Kara 2016-12-14 3288 pte_unmap_unlock(vmf->pte, vmf->ptl);
a19e25536ed3a2 Jan Kara 2016-12-14 3289 return VM_FAULT_NOPAGE;
66a6197c118540 Jan Kara 2016-12-14 3290 }
60fe935fc6b035 Kefeng Wang 2023-10-13 3291 wp_page_reuse(vmf, folio);
a19e25536ed3a2 Jan Kara 2016-12-14 3292 return 0;
66a6197c118540 Jan Kara 2016-12-14 3293 }
66a6197c118540 Jan Kara 2016-12-14 3294
On 2023/10/17 15:33, kernel test robot wrote: > Hi Kefeng, > > kernel test robot noticed the following build warnings: > > [auto build test WARNING on akpm-mm/mm-everything] > > url: https://github.com/intel-lab-lkp/linux/commits/Kefeng-Wang/mm_types-add-virtual-and-_last_cpupid-into-struct-folio/20231017-121040 > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything > patch link: https://lore.kernel.org/r/20231013085603.1227349-18-wangkefeng.wang%40huawei.com > patch subject: [PATCH -next v2 17/19] mm: convert wp_page_reuse() and finish_mkwrite_fault() to take a folio > config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231017/202310171537.XhmrkImn-lkp@intel.com/config) > compiler: m68k-linux-gcc (GCC) 13.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231017/202310171537.XhmrkImn-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202310171537.XhmrkImn-lkp@intel.com/ > > All warnings (new ones prefixed by >>): > >>> mm/memory.c:3276: warning: Function parameter or member 'folio' not described in 'finish_mkwrite_fault' > Hi Andrew, should I resend this patch? or could you help me to update it, also a comment(page -> folio's) on patch18, thanks. > > vim +3276 mm/memory.c > > 2f38ab2c3c7fef Shachar Raindel 2015-04-14 3258 > 66a6197c118540 Jan Kara 2016-12-14 3259 /** > 66a6197c118540 Jan Kara 2016-12-14 3260 * finish_mkwrite_fault - finish page fault for a shared mapping, making PTE > 66a6197c118540 Jan Kara 2016-12-14 3261 * writeable once the page is prepared > 66a6197c118540 Jan Kara 2016-12-14 3262 * > 66a6197c118540 Jan Kara 2016-12-14 3263 * @vmf: structure describing the fault > 66a6197c118540 Jan Kara 2016-12-14 3264 * > 66a6197c118540 Jan Kara 2016-12-14 3265 * This function handles all that is needed to finish a write page fault in a > 66a6197c118540 Jan Kara 2016-12-14 3266 * shared mapping due to PTE being read-only once the mapped page is prepared. > a862f68a8b3600 Mike Rapoport 2019-03-05 3267 * It handles locking of PTE and modifying it. > 66a6197c118540 Jan Kara 2016-12-14 3268 * > 66a6197c118540 Jan Kara 2016-12-14 3269 * The function expects the page to be locked or other protection against > 66a6197c118540 Jan Kara 2016-12-14 3270 * concurrent faults / writeback (such as DAX radix tree locks). > a862f68a8b3600 Mike Rapoport 2019-03-05 3271 * > 2797e79f1a491f Liu Xiang 2021-06-28 3272 * Return: %0 on success, %VM_FAULT_NOPAGE when PTE got changed before > a862f68a8b3600 Mike Rapoport 2019-03-05 3273 * we acquired PTE lock. > 66a6197c118540 Jan Kara 2016-12-14 3274 */ > 60fe935fc6b035 Kefeng Wang 2023-10-13 3275 static vm_fault_t finish_mkwrite_fault(struct vm_fault *vmf, struct folio *folio) > 66a6197c118540 Jan Kara 2016-12-14 @3276 { > 66a6197c118540 Jan Kara 2016-12-14 3277 WARN_ON_ONCE(!(vmf->vma->vm_flags & VM_SHARED)); > 66a6197c118540 Jan Kara 2016-12-14 3278 vmf->pte = pte_offset_map_lock(vmf->vma->vm_mm, vmf->pmd, vmf->address, > 66a6197c118540 Jan Kara 2016-12-14 3279 &vmf->ptl); > 3db82b9374ca92 Hugh Dickins 2023-06-08 3280 if (!vmf->pte) > 3db82b9374ca92 Hugh Dickins 2023-06-08 3281 return VM_FAULT_NOPAGE; > 66a6197c118540 Jan Kara 2016-12-14 3282 /* > 66a6197c118540 Jan Kara 2016-12-14 3283 * We might have raced with another page fault while we released the > 66a6197c118540 Jan Kara 2016-12-14 3284 * pte_offset_map_lock. > 66a6197c118540 Jan Kara 2016-12-14 3285 */ > c33c794828f212 Ryan Roberts 2023-06-12 3286 if (!pte_same(ptep_get(vmf->pte), vmf->orig_pte)) { > 7df676974359f9 Bibo Mao 2020-05-27 3287 update_mmu_tlb(vmf->vma, vmf->address, vmf->pte); > 66a6197c118540 Jan Kara 2016-12-14 3288 pte_unmap_unlock(vmf->pte, vmf->ptl); > a19e25536ed3a2 Jan Kara 2016-12-14 3289 return VM_FAULT_NOPAGE; > 66a6197c118540 Jan Kara 2016-12-14 3290 } > 60fe935fc6b035 Kefeng Wang 2023-10-13 3291 wp_page_reuse(vmf, folio); > a19e25536ed3a2 Jan Kara 2016-12-14 3292 return 0; > 66a6197c118540 Jan Kara 2016-12-14 3293 } > 66a6197c118540 Jan Kara 2016-12-14 3294 >
On Tue, 17 Oct 2023 17:04:41 +0800 Kefeng Wang <wangkefeng.wang@huawei.com> wrote: > >>> mm/memory.c:3276: warning: Function parameter or member 'folio' not described in 'finish_mkwrite_fault' > > > > Hi Andrew, should I resend this patch? or could you help me to update > it, also a comment(page -> folio's) on patch18, thanks. I'd assumed a new series would be sent, addressing Matthew's comments.
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; } /*