Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2186367rdf; Mon, 6 Nov 2023 07:09:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWntbzNffZyibyke+PpxgzQK+Tapg6J7jCfj/+LECNaa0HWmm5/jhe5/hkGlIVu/avj7kB X-Received: by 2002:a05:6a00:1488:b0:6be:b79:eca with SMTP id v8-20020a056a00148800b006be0b790ecamr35405173pfu.32.1699283347679; Mon, 06 Nov 2023 07:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699283347; cv=none; d=google.com; s=arc-20160816; b=hWyPoB2X5ToLgZfngtpCaZb+m8v2CWvMZWop/HSoiHmp+Z/Nx0FWZ+PiZLN4zMKryD hlHB07bQfpZaQ+18mQE9B/8Rkvnf1N/nBspOIx7dDUyxC8nwGApNJBn5VnS6XNj5Z60G nSvxPuIdYaqx+5bl3y/9UJQC3dyA3AkM8eOnR3k23PdgsEIkM9gcehhlDTJKZfJwEsIf Lq9B/Cxtx2Ug5u/OfZasEdP4C+v3OMew/P7ilGcw+LbQadH5Ezk+NnhcNOnFPqfhUaOU pS8pAUrn+MFPF23wZGSxESguPHYbgCsZmh6pbe9fjkLdRkT0K3lDZTbtHfELNHwFnJGW 2Cjw== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=4iL7rHa1HPuu0gn0giuNhzEkjB8eWx4bSCmW7ISuIAY=; fh=CcJo0L9wfd8BA3NJ4Bp0Ui/21KhdfkaxtXe28o6dgs4=; b=XzD/LrCMLmbtgaB5WuaBBH1oZv5YH9opNL6PuZOigFAQQ+/yKEH1THorBej//GFUb0 XmN2mSxzOheN+F+GMEAjjPKC0+zz1BFpU0nP/pbYZzkdOvwEMVawN2b8wsVGn82jvQJM 2UR83V8pIl0x3zhkwZz1ZvX2kux4bd5UzKQRrfYzi86VcniJGxkCP3yhYwzaZ6TUEj7i VmHGKpvJH5pkImVVyGxLi3D1WPP3RFKKZv3idJDzccwlx6GyhrMyptvG/nt/+yTURZTX 0z0V3xIvkgXIdQE+PadWbmhYh77fRCSUun8WhXlhDinclaS6YCbyM8Cwk9r5+AjMmajV yC8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id z128-20020a633386000000b005778df5647dsi8223419pgz.401.2023.11.06.07.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:09:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 3DFF08048689; Mon, 6 Nov 2023 07:09:06 -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 S231767AbjKFPJE (ORCPT + 99 others); Mon, 6 Nov 2023 10:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbjKFPJD (ORCPT ); Mon, 6 Nov 2023 10:09:03 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CFEDB6; Mon, 6 Nov 2023 07:09:00 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SPF653GN6zrSNy; Mon, 6 Nov 2023 23:05:49 +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 23:08:56 +0800 Message-ID: Date: Mon, 6 Nov 2023 23:08:56 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 06/10] mm: memory: use a folio in zap_pte_range() Content-Language: en-US To: Matthew Wilcox CC: Andrew Morton , , , David Hildenbrand , References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> <20231104035522.2418660-7-wangkefeng.wang@huawei.com> 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: 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=-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]); Mon, 06 Nov 2023 07:09:06 -0800 (PST) On 2023/11/6 22:20, Matthew Wilcox wrote: > On Mon, Nov 06, 2023 at 10:30:59AM +0800, Kefeng Wang wrote: >> On 2023/11/5 1:20, Matthew Wilcox wrote: >>>> - 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 don't want to leave that kind of booby-trap in the code. Both places > which currently call page_remove_rmap() should be left as referring to > the page, not the folio. Sure, I will fix this, also page_try_dup_anon_rmap() for device private entry in copy_nonpresent_pte of patch5.