Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp890971rdb; Tue, 30 Jan 2024 01:27:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLKXgTABX/FNRho03s0WbnuOwYMcuMMw2FLWc8cbJIaOLzc8gDH/I+DpNSfZRrzbv5V70X X-Received: by 2002:a05:6358:340b:b0:176:5a5e:4bf9 with SMTP id h11-20020a056358340b00b001765a5e4bf9mr5753340rwd.22.1706606849831; Tue, 30 Jan 2024 01:27:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706606849; cv=pass; d=google.com; s=arc-20160816; b=E5kigyLyV64N8RsbA8qMHEij2nTnIap6EoS8KbnwmrdhE09VLn/3/IMmx1VCTaLy/u IApTqrtFbGH5t0fkolGy3ggc8mjNtyqhzV9TCgrIg1t8uymwo3gyLrLMgZLiWcYV1Q4R TtncVOHsozeBSARo3KeVi+T4YDkZiARYrhWVDU/hcoPbnvOOywBEGEXsMtObTFYeufj4 TlOVob3y8haqcSicDOVxMTocfzMjySyy/5slq1CMNPlJFDrcnCMiZddG8Jc0xBYfTqYT 7IDSPkvTFp6CS6recQbDjNxWx8vIID5QVXX48VweY1Uz7OQg10W5Oz5M/Vc5oJSO+fLM MQlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=5xUotLVW3we8anIsEYo4JkFes0Xc3edpjtRnWXJ9Peo=; fh=VVjuivqjwQTGD3KqdtfMHM2u5ZCac4G8eN8eVGHfbQw=; b=XaAYe4L5NKOCpV8s63n7dIT2MUSFOAM3Fmj3SjCjExzP4CyRBGWnremiVjjeTi/jyf uAfvciNEa+PpfIwOAs3+WPzw9JFtMQezjv5L3BpI1SYxV8Hwi+PfPysscNWyoAxmmM3K D3thScLglE7/Uq8GCtqMCfCkPmaP50GrxI3wprCACrCxh7TfvR48ppQwzemYUNVixZjk SUM20ZRwMaqkhmcDZNTdbLQykGziCRxmK9V+ykAAZ/Dzpnu1SSC6qYjGIFkZ0OMeEYWI GfNkgY4WYr5FpNJMznl9jHl9EOSapAXKsDLhBQQKA5hFgdRVf8BXAx3WXQGF4eKdm654 B1pA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-44174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l124-20020a632582000000b005d747d63541si7050273pgl.471.2024.01.30.01.27.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:27:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-44174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 838F5B2BF74 for ; Tue, 30 Jan 2024 08:48:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A3E758133; Tue, 30 Jan 2024 08:47:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 437AE38DEC; Tue, 30 Jan 2024 08:47:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706604462; cv=none; b=GHK7E3suw/70eyLhVpQ5HucrlUS1JIPq/nPWIL0KnvbohDP80CzTjs1PEJD6l7LphO9cav5Su+5iaP6CSUdtAMgpKHLMn4MN0O8HO1V9/TYB8OMAzJ99BfC9ySv0r+hcflNIxJFBHrHgSzAaO9D0sOTKggW4NN9VMbSOVv70nXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706604462; c=relaxed/simple; bh=+gC5XUeYUuFw+soxH/D3b8jk10TJuZtORaXfBsnPMBo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=r0RSYAIwgMlRBxwAJM5x9zeF/gzAUtNvblbki2qOVjZvfszRTnK5BGkEAo2FvfNf3kKxVQpYTFodl0UQ3Lq5/5H587o9gGE7i2ATuI6t6Ll5fGu9bO4l5brUL5FfA3PkRBfJO2khWn44KP8p+mPA/d8m7mzMBggJx1c7D/dCjkQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E3AA139F; Tue, 30 Jan 2024 00:48:21 -0800 (PST) Received: from [10.57.79.54] (unknown [10.57.79.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF4953F738; Tue, 30 Jan 2024 00:47:34 -0800 (PST) Message-ID: Date: Tue, 30 Jan 2024 08:47:34 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 4/9] mm/memory: factor out zapping folio pte into zap_present_folio_pte() Content-Language: en-GB To: David Hildenbrand , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Andrew Morton , Matthew Wilcox , Catalin Marinas , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Michael Ellerman , Christophe Leroy , "Naveen N. Rao" , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org References: <20240129143221.263763-1-david@redhat.com> <20240129143221.263763-5-david@redhat.com> From: Ryan Roberts In-Reply-To: <20240129143221.263763-5-david@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 29/01/2024 14:32, David Hildenbrand wrote: > Let's prepare for further changes by factoring it out into a separate > function. > > Signed-off-by: David Hildenbrand Reviewed-by: Ryan Roberts > --- > mm/memory.c | 53 ++++++++++++++++++++++++++++++++--------------------- > 1 file changed, 32 insertions(+), 21 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index 20bc13ab8db2..a2190d7cfa74 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -1528,30 +1528,14 @@ zap_install_uffd_wp_if_needed(struct vm_area_struct *vma, > pte_install_uffd_wp_if_needed(vma, addr, pte, pteval); > } > > -static inline void zap_present_pte(struct mmu_gather *tlb, > - struct vm_area_struct *vma, pte_t *pte, pte_t ptent, > - unsigned long addr, struct zap_details *details, > - int *rss, bool *force_flush, bool *force_break) > +static inline void zap_present_folio_pte(struct mmu_gather *tlb, > + struct vm_area_struct *vma, struct folio *folio, > + struct page *page, pte_t *pte, pte_t ptent, unsigned long addr, > + struct zap_details *details, int *rss, bool *force_flush, > + bool *force_break) > { > struct mm_struct *mm = tlb->mm; > bool delay_rmap = false; > - struct folio *folio; > - struct page *page; > - > - page = vm_normal_page(vma, addr, ptent); > - if (!page) { > - /* We don't need up-to-date accessed/dirty bits. */ > - ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); > - arch_check_zapped_pte(vma, ptent); > - tlb_remove_tlb_entry(tlb, pte, addr); > - VM_WARN_ON_ONCE(userfaultfd_wp(vma)); > - ksm_might_unmap_zero_page(mm, ptent); > - return; > - } > - > - folio = page_folio(page); > - if (unlikely(!should_zap_folio(details, folio))) > - return; > > if (!folio_test_anon(folio)) { > ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); > @@ -1586,6 +1570,33 @@ static inline void zap_present_pte(struct mmu_gather *tlb, > } > } > > +static inline void zap_present_pte(struct mmu_gather *tlb, > + struct vm_area_struct *vma, pte_t *pte, pte_t ptent, > + unsigned long addr, struct zap_details *details, > + int *rss, bool *force_flush, bool *force_break) > +{ > + struct mm_struct *mm = tlb->mm; > + struct folio *folio; > + struct page *page; > + > + page = vm_normal_page(vma, addr, ptent); > + if (!page) { > + /* We don't need up-to-date accessed/dirty bits. */ > + ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); > + arch_check_zapped_pte(vma, ptent); > + tlb_remove_tlb_entry(tlb, pte, addr); > + VM_WARN_ON_ONCE(userfaultfd_wp(vma)); > + ksm_might_unmap_zero_page(mm, ptent); > + return; > + } > + > + folio = page_folio(page); > + if (unlikely(!should_zap_folio(details, folio))) > + return; > + zap_present_folio_pte(tlb, vma, folio, page, pte, ptent, addr, details, > + rss, force_flush, force_break); > +} > + > static unsigned long zap_pte_range(struct mmu_gather *tlb, > struct vm_area_struct *vma, pmd_t *pmd, > unsigned long addr, unsigned long end,