Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1868209rdf; Sun, 5 Nov 2023 18:31:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwMRx7wL3UFKfUzf960vZT5g1S/B/r7fEajuPZy8GOxsJwSnkQf3/JOuNdKifdspiuSMP5 X-Received: by 2002:a05:6a20:a103:b0:16b:b900:2d6d with SMTP id q3-20020a056a20a10300b0016bb9002d6dmr25461276pzk.60.1699237868501; Sun, 05 Nov 2023 18:31:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699237868; cv=none; d=google.com; s=arc-20160816; b=J3Afl9Oq7ktlzjzwF24rHHJIDRF/gqpiQeUuHzMnAyHePJOfonjCGc3seLZ4d0BuwK PsBcPsS/sl9UOnpOHpkL9LlomWcnhhTUV0FiMo7GPLeM5T65J28IQI+urR6FQVZsVPQW qEboZrrPlQzpuatK4WQeVmy6IVpx7JTeNBnZRuNUMG6+rXtzeER/CpxkwsvgW/oACTi5 9obnxeMeB0OPSXF+IECoccOocSh4iX9O3kpeZa4/MGUPMNjG6Kj8Ero2ylfVM9y3uG5x dPtIXD4CO9yewJpxICUDaIg9CBfubrQDziw86KkyrUN4DzhCG2Xj3pGVPjIFy012pBLO K5PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=uyfn30DISt6nhjR8mnE2FTq4hVBNgfjXk4cA6O0YfxI=; fh=CcJo0L9wfd8BA3NJ4Bp0Ui/21KhdfkaxtXe28o6dgs4=; b=oE0ORCmVjTcBxMPJVKJK3tTNY9gvsGDoCYD36iTXHIH9O6UljTNlM/yJ6xHPu0tucU AL0gaZ6IoNp+elo6HgtRPfCLdYKluibalgANOTTCr+4Jh8yWdWCndsORzTbiWHUlgIqS p+oESjuTavL2G4p21k84U0VTKGN7e8sWOr1Sr6VkPCQzIlHKXATuN2KNBzdWbpEXd1cq VgfRll7FjLiQLoZtaAsz15cxhmNvQ3jcAYHRyIj2v2TS3cbSbOma+LjhpAb/3zjqvsTR 4kiVnffK0ZGndJhzPTkDxYDp3q0BmLzqRFSuT+PqhMMLOJCtNP3pcfSgtZ9ouy8nWDzB LpFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id c21-20020a17090a8d1500b002636d222400si6768739pjo.14.2023.11.05.18.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 18:31:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 2C74280C5FA4; Sun, 5 Nov 2023 18:31:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbjKFCbG (ORCPT + 99 others); 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 05 Nov 2023 18:31:07 -0800 (PST) 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.