Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1207147rdf; Sat, 4 Nov 2023 10:21:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHO9UF+OGa7pAgYpXyYr1tQptiOf4yQkdppBV1l1nO8AjKHYj81UfNrAYaiVh6c5FsnESeq X-Received: by 2002:a05:6a00:15ce:b0:68b:e29c:b69 with SMTP id o14-20020a056a0015ce00b0068be29c0b69mr7738422pfu.9.1699118503381; Sat, 04 Nov 2023 10:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699118503; cv=none; d=google.com; s=arc-20160816; b=BFczGPjZCb3FC5QPT7Fz6rwU3caAz7aWfHIk/9KcjZY4AbQGcPAGHxDo9nBDj2UMHd 5v54+p/fiFMG6hN0Iw/zNT3oP90KsCRfUPC19nxLkzK3F5rueYwji0JCVgaX07hAXjbf zkTX6RVU0LueBxhSB4dKo79nPtDbzOOsNdAZxzWYEg+tCXi/Pt0pJYBeUB5N3aiBG2ry dfM2WQQZG9ybJMUQcDoLw6Y7fwXJk/FvC2ERCJXV9LzCswEJA5A4N93HObtY59cIp5X7 Zd4IDfG5QE6yna1rNfjTrKtXUu1WoKE4rT6nTo1JK+vifWBYm3RnsVg12cQeCT9oc0by a9uw== 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=iZ7+BGlL3zWN+SVM8jQZNXOzKUk6jFAu7ijAJTmB0CI=; fh=eORcq9QZmBCYeNUdqYkrhzxtKqHL34KExjMuSyjxCKo=; b=ITbs6DYGYp2eV9TST9XzYWdDaPs0BHAjBxLae/Bsv+pn8SHf7P/l8aloVnhGPAExVU sqirhVfrTahMyYO7nDsNHJcFCRv5Z/9Xj7nzTc2Wzo5Aq+ycWHYPkO4WU4WIP+qO7+oN 0zFwytIbLYtaiExmG5wex1OWe29JCYNTFWh46gXVUgevj1qwoQzRmJYi/rBKpNhnzNjH qiIHIKm3h877pysAznh8a9ge3iHjCwt3wedlQV5B9QHqFC8be6YcDKFKnh84oJNxCvwt bJ3LXkFVVZqtNZidUrjyM0kCFK0U0szxtkeegOyaisQf/Clyx8/UgP3ZNsa+AZgq2l8L 22og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nfkprV5s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id s66-20020a637745000000b005b95f5f8976si4222160pgc.634.2023.11.04.10.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 10:21:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=nfkprV5s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 8D8088080D62; Sat, 4 Nov 2023 10:21:17 -0700 (PDT) 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 S231533AbjKDRVE (ORCPT + 99 others); Sat, 4 Nov 2023 13:21:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230346AbjKDRVD (ORCPT ); Sat, 4 Nov 2023 13:21:03 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79F5D1BF; Sat, 4 Nov 2023 10:21:00 -0700 (PDT) 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=iZ7+BGlL3zWN+SVM8jQZNXOzKUk6jFAu7ijAJTmB0CI=; b=nfkprV5s7Ii9/+5g7i9kwyvnLm 9Gm2ylhNX07Mcj2zN9mgCu9+DxcLZ3UgS3QQxSO4OZZdQy2S7lT4iDB1F+nThKOHHsoZPPe40CYdu 3ALSQt7gJ6IHC0+PgArkPOTU5/RnPjM43yamW8uDNR3wwkqVnSTZFGf2ZJ3N5xgNtDcUrSwgnBaGK mDg0kdZxD6h98WEsw1MS8Qa3XiW2yHZvU31Tzfrs9IeM+YMEK2lw7XD+VMzqaD367KAMcuIuo+hTz Jls2hnyGZQVzlcXPoE1VZlhxf3IfGTv4V3PegJNCPA3q7QJfyzidJjZAPfPEPbpJpp2a0s/Nriv6D JAVjTYSg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qzKKM-00CZqt-UJ; Sat, 04 Nov 2023 17:20:55 +0000 Date: Sat, 4 Nov 2023 17:20:54 +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: <20231104035522.2418660-7-wangkefeng.wang@huawei.com> 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,URIBL_BLOCKED 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]); Sat, 04 Nov 2023 10:21:17 -0700 (PDT) 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()? > @@ -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. I suspect you're going to collide with Ryan's work by doing this ...