Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2155639rdf; Mon, 6 Nov 2023 06:21:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHus7dTbFlBAnXlBVE7e2kgXslzdPmhp/gC+z7/663/lG7liszyt6cFVjLBKwT3D8kOBHhG X-Received: by 2002:a05:6a20:7348:b0:17a:eddb:ac6a with SMTP id v8-20020a056a20734800b0017aeddbac6amr38560913pzc.6.1699280481753; Mon, 06 Nov 2023 06:21:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699280481; cv=none; d=google.com; s=arc-20160816; b=QaBzHU30auVk79uVxhRmeoVKKWZvAlpQwF7rILpfHinqIxng40T3mGpPqLWMiM36dR xfKz380uYe1PATI+UIyi7KFuC39smI3ENk5WrrAffFDSrwwG32HZTHNf/8k07GxABld+ MbjpQaZhNveoQUFQtqh6GmGnw7lhmWCAES1cf8quWVw4VLXSxewzh8ITRib6aMHYuWUR /36r0aC+VBPME/JEDIgwJc/nowjT7rOhcmXj1iZ7PdUbJy1d8nqzeV4+QTV/2WC0A0ao IWQ/Tr1VhC3qh3bziqsY429pQkmKGrNXN0nb5mnzYiGC/RdcaYTInopAgymcYKWi7xo3 L1Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/gY9fga25uHFBNLVOlYk1hPjkWgJ/qz19kZMBIAL1Vo=; fh=eORcq9QZmBCYeNUdqYkrhzxtKqHL34KExjMuSyjxCKo=; b=Egqpgtpcek3+mwSlJ1KZuq9FX4CaiENd0/Jp71vwwEVjKnX5Lot+zejDnlJIzpNyv0 MrUfZc9QcKw5iN7eMXGSMozSWB9LRc9sdVbTgkPL3eJ5f2UGgAgK5UI5tuPHhvB81NHi nUxcREQwlYhywY5rWdFtjXxh8O80mkGLhez0jdY+bl+kmpz6KGosSo10QOpgndLcrU48 MppLLY1z7SosGbt5avPQmxXvodyxw7OZNXH9QKojrQGZ+mI/ycFpQ2y826QG4T7w65Sr h6iD36Uxgxy8N9kcoSoFqaI9Vk5ZdURZ77L7Cfh4rhENpzsxmC244hovon9eNWoROwjG WkQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CAdjhNR1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l69-20020a638848000000b00579926e0863si8047551pgd.159.2023.11.06.06.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 06:21:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=CAdjhNR1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 328018077446; Mon, 6 Nov 2023 06:21:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231332AbjKFOVJ (ORCPT + 99 others); Mon, 6 Nov 2023 09:21:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230146AbjKFOVH (ORCPT ); Mon, 6 Nov 2023 09:21:07 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D634DC6; Mon, 6 Nov 2023 06:21:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/gY9fga25uHFBNLVOlYk1hPjkWgJ/qz19kZMBIAL1Vo=; b=CAdjhNR1EZ8085YVz3JlS3KoB/ bBNrRZ8WgWC8elYdcpofIF/Zx535WalMf4qgPcvPIXHIgyxfpRw4t9Tu6X08E4Cg2j1B4xxiaNoPU nZYeYESZ3shQQC6Y7Ft8HYGMnM7MYBWRxSkgUV88zm6tfDZ83cWTLsQLIlvQtauYdtgeNpao8ovLY whVheuP+VGj9QRFsB56coApjfcJb3Nv2OYU26VobdO8e0EgCDeQljjDkDeads+NU0/ZoHAmOXzKJC M1jdC2J9KKUCE96EeKaDGMqRNCat8JZTPwm5G3fDAPp5SSQZqFv0cr11wXK1uuNUYSZRc2QW1pAMb O75yTjqw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r00TI-006OrJ-2n; Mon, 06 Nov 2023 14:20:56 +0000 Date: Mon, 6 Nov 2023 14:20:56 +0000 From: Matthew Wilcox To: Kefeng Wang Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , linux-s390@vger.kernel.org Subject: Re: [PATCH v2 06/10] mm: memory: use a folio in zap_pte_range() Message-ID: References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> <20231104035522.2418660-7-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 06:21:19 -0800 (PST) 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.