From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E904C4332F for ; Mon, 6 Nov 2023 02:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229486AbjKFCbG (ORCPT ); Sun, 5 Nov 2023 21:31:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjKFCbG (ORCPT ); Sun, 5 Nov 2023 21:31:06 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F637D6; Sun, 5 Nov 2023 18:31:02 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SNwM158NmzvQK0; Mon, 6 Nov 2023 10:30:53 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) 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; Mon, 6 Nov 2023 10:30:59 +0800 Message-ID: Date: Mon, 6 Nov 2023 10:30:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 06/10] mm: memory: use a folio in zap_pte_range() To: Matthew Wilcox CC: Andrew Morton , , , David Hildenbrand , References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> <20231104035522.2418660-7-wangkefeng.wang@huawei.com> Content-Language: en-US From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On 2023/11/5 1:20, Matthew Wilcox wrote: > On Sat, Nov 04, 2023 at 11:55:18AM +0800, Kefeng Wang wrote: >> -/* Decides whether we should zap this page with the page pointer specified */ >> -static inline bool should_zap_page(struct zap_details *details, struct page *page) >> +/* Decides whether we should zap this folio with the folio pointer specified */ >> +static inline bool should_zap_page(struct zap_details *details, struct folio *folio) > > Surely we should rename this to should_zap_folio()? Will update. > >> @@ -1487,10 +1492,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, >> * see zap_install_uffd_wp_if_needed(). >> */ >> WARN_ON_ONCE(!vma_is_anonymous(vma)); >> - rss[mm_counter(page)]--; >> + rss[mm_counter(&folio->page)]--; >> if (is_device_private_entry(entry)) >> - page_remove_rmap(page, vma, false); >> - put_page(page); >> + page_remove_rmap(&folio->page, vma, false); >> + folio_put(folio); > > This is wrong. If we have a PTE-mapped THP, you'll remove the head page > N times instead of removing each of N pages. This is device private entry, I suppose that it won't be a THP and large folio when check migrate_vma_check_page() and migrate_vma_insert_page(), right? > > I suspect you're going to collide with Ryan's work by doing this ... > Maybe not if the above is true, at least for now. Thanks.