Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp668558rdg; Thu, 10 Aug 2023 15:53:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSva3zN7Ft1MVnsp/dxJrcxIf3DJ8xJJVHehzCyeXQG5X4qMRL0z1sQy+ExJd9cHG6jIwK X-Received: by 2002:a05:6a00:1891:b0:67f:2ba2:f741 with SMTP id x17-20020a056a00189100b0067f2ba2f741mr122759pfh.24.1691708005637; Thu, 10 Aug 2023 15:53:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691708005; cv=none; d=google.com; s=arc-20160816; b=IePUrrcPB8iZW2cIg02Vc7Yi/AlKaJigrrbE5irzLZvLclrg2bfisxUuQEEfw3kXbB cJcn5KdXqBhtLELSKWUiF9dHtcF4kilC8kJhZWidlQBR4cNOgeEle7C7XniW3rH9RmD7 vUkF6WXKtO7EAeIaESoETW3ugqGKgrmQsA9vQTuvoNKW1bVa1iSwvwQw+v5Pyts/fANE +rj4X2nvx0ctixvm4N+xpwozJ4p6FtB28YAoxZbc8bnnMTp3T242qol0SDtwsfXwbjXw HoPhLqWtpGZlBG01UAHa9KztQS23S5vO/BdMICqK3OVLJ5m6AglJah4x2xkzdEo9Lf+F hCCQ== 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=RU0sXhO2RQNDDSYdL7EeIXZJPLuZxUwbT9QsXnScSII=; fh=JQVOzAVBzVWg9GoXTbQm1i4gskpsfbJEp4DT+MYOqZ0=; b=xzN9euSmrEK5zujnBReYnKXmKqCqqzF5Nu1eQH0AhCUOLtthE+htYAnza5/tj7Vnk7 v98d7AxT0lrMhYBsdZuEvKKLY6TMlYSYLsIHQGSYl1dkP2jWNIhga2FZhhC2vEYAN7VR w7qzpbuT2MQ4qAIBPhjrcsS7rRflVCJ9+xiBCxTcwcRnT3uvQvHbVsx/1qYu1t0DFnoe Dn88kt+fYX41gqHdNPR54t5+jOPIyrgZHKF+XoVXvqWrZn+gaUPsmrN7Ry5Tgc6PH5BG 8FqCl0im+gqZNfzVh5e3nTvtNhwvgmqEE97G0EeVqGj5rX95TKmJnNXfHs9UlEMkeXp4 kENA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bRUN9usC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h185-20020a6383c2000000b005600a533c7esi1720652pge.89.2023.08.10.15.53.13; Thu, 10 Aug 2023 15:53:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bRUN9usC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbjHJVyR (ORCPT + 99 others); Thu, 10 Aug 2023 17:54:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231254AbjHJVyN (ORCPT ); Thu, 10 Aug 2023 17:54:13 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11AABED; Thu, 10 Aug 2023 14:54:13 -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=RU0sXhO2RQNDDSYdL7EeIXZJPLuZxUwbT9QsXnScSII=; b=bRUN9usCQLHI82STQKPErTe238 j/e39iuEoltOdwRI4bvxOhW5+5HNFoWGzXga6QrC2eiUbxsdmrioGMxJoQx9t9rfEaqbXJPUKsPnQ iXdE7dfMGCuAShDLVrcGHkLBRrf8JxdXOp75lGbF/AFeTP3rVFCWdsshp1dfPcipglz1UFzbEngWp UKifiajJlzW7zG2FwDQQ6alxoV9JW1+l80uJLaN1RsJhmqhuP2ox5eFBM+YibPBJbf2Vu+C1sCFFA +n7LJ/H5cKWikDfiMz1JK8hvHk7hNdd7MRqvNq5U5rlnEFHZhCjZ7yfyRkO3pnYhKaUtSJx9J3Ve2 ANF3F+gg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qUDbZ-00EvTN-Re; Thu, 10 Aug 2023 21:54:06 +0000 Date: Thu, 10 Aug 2023 22:54:05 +0100 From: Matthew Wilcox To: Peter Xu Cc: David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Andrew Morton , Jonathan Corbet , Mike Kravetz , Hugh Dickins , Ryan Roberts , Yin Fengwei , Yang Shi , Zi Yan Subject: Re: [PATCH mm-unstable v1] mm: add a total mapcount for large folios Message-ID: References: <20230809083256.699513-1-david@redhat.com> <7e31254d-8889-7e79-50e1-2630bd493d59@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 On Thu, Aug 10, 2023 at 05:48:19PM -0400, Peter Xu wrote: > > Yes, that comment from Hugh primarily discusses how we could possibly > > optimize the loop, and if relying on folio_nr_pages_mapped() to reduce the > > iterations would be racy. As far as I can see, there are cases where "it > > would be certainly a bad idea" :) > > Is the race described about mapcount being changed right after it's read? > Are you aware of anything specific that will be broken, and will be fixed > with this patch? The problem is that people check the mapcount while holding no locks; not the PTL, not the page lock. So it's an unfixable race. > Having a total mapcount does sound helpful if partial folio is common > indeed. > > I'm curious whether that'll be so common after the large anon folio work - > isn't it be sad if partial folio will be a norm? It sounds to me that's > the case when small page sizes should be used.. and it's prone to waste? The problem is that entire_mapcount isn't really entire_mapcount. It's pmd_mapcount. I have had thoughts about using it as entire_mapcount, but it gets gnarly when people do partial unmaps. So the _usual_ case ends up touching every struct page. Which sucks. Also it's one of the things which stands in the way of shrinking struct page. But it's kind of annoying to explain all of this to you individually. There have been hundreds of emails about it over the last months on this mailing list. It would be nice if you could catch up instead of jumping in.