Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp186268lqd; Tue, 23 Apr 2024 21:15:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZLapJsNp23/CJ/nzVJDmZYIziTVUdFV6TuAcgyZ8ZA12kdEdhebTxfUF4JrFAZJ7lF+qlEY6EradTRK0P8M4PH4dznEIhNNQbQrs05w== X-Google-Smtp-Source: AGHT+IGuhAPArErfgKVb12LEF9cCzfMP/Vzdt6OtMRs7jNQYAZR/1+pkXkTMN2P5BFJtI/IMrwlX X-Received: by 2002:a17:902:d4c7:b0:1e4:8040:d2cf with SMTP id o7-20020a170902d4c700b001e48040d2cfmr1623814plg.68.1713932137093; Tue, 23 Apr 2024 21:15:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713932137; cv=pass; d=google.com; s=arc-20160816; b=mVtog/Elhe8TVDonxRNatA/bZ0pD5G+8sbrkC1Vozb49ZJx3LMbdaYD9GMdYCABGMr mK6jwIq+mTy66vJ6dA0TTUu/W7mAi7HGl7Ec7g0/cXPXQK4Otnd0s6r5c15TCyjosN+r jqL+9UhkUGS6FylnchVqzR4VloMCNNGQc+TZzLTyxU2N9IEHuqb1NKIM/kgoOz4smkaK yK7hadVahiO3n6DvYuto6YHwQrcMo3ehRxiICHMgvfxfGAD+2g2RYar6tPZDG0WopX41 lIhxXRmkvsqW7tC/ctQgqTLoOE6lN20dfnJH0lvlApOFoh7541ZFQxbh5cvBBbKZA1lw gtRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=viymBDCrvjKdxY/tQOLTnCZyFrlNtSCuDcsjtwmyXNA=; fh=u2UuwxzpyeUnaqC5y1FP8ZumY+B7g2GZbFM+0hnNTI0=; b=eigl3oaTMCP3Un8ndVSK1aXH4gEdPL6kbXx2k/nzzB2qDu3hoJeM2wCVC743o5zHQT vPONgf8/EEETqoWolKLgxOSxzh/LKooSOn0Ag8QEzMsRHuZI0VQtoOwrZEh8G3Li06W4 6wqSPgUqpVMSSPXt21BicdeKJDjZcZOisf/+i8rdshDB/FuyB9+ncMJEDJHnHRg3w35q HATWxoFJxRhMhxgh9qZm5fQr/rmKGS1gkxaf2PDru7cUjlBfvU7EWc308JnQzJsEvzJp v6ouCAL8es7Uj8lZmGm+W306HOq85vPLNtlw5/Om/NtFBvRZ82vtwP6rW3UdzgsfdWCE mZ/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="Pa0jSMF/"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-156264-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156264-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c12-20020a170903234c00b001ea0d861e65si2611274plh.140.2024.04.23.21.15.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 21:15:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156264-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="Pa0jSMF/"; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-156264-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156264-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2935A281DDF for ; Wed, 24 Apr 2024 04:15:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6609142916; Wed, 24 Apr 2024 04:15:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Pa0jSMF/" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A28DB142659 for ; Wed, 24 Apr 2024 04:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713932124; cv=none; b=Z4NUQ9LECIGjukThCDKCz6LX4r0BztkwRgf4UT+b8FYHK3T3QsKfIrXCGbozadtQrplYf4HTdxiupdAq0WjDRx8inzSR5Py17tAXvyDV4iNTVXN1j8hzCC5wn5hDT+vAvpXjdfgWQdk0LqaYUFbyoZZ/YhL8FLc6bauCpSxSpSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713932124; c=relaxed/simple; bh=k4lLCbg6edPJctKYJR5wVgV6a2Y5lzMPhruQhJ8dWgI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nmQbRhHN6VatyADMhfCaYPnKlsS5rfpth0jlCiPhm1I9kQV6QQqBDUHLZI8MG4UXcjsolO3ucLAR3cxyuCHUZyYxtIpUNiLEd38ujnpK18p5kpXUmzVLvsf20iZbmXEf3EQqhOKF8kl9+k3DHX93NtTQlBtnoPisvNni4VKWxVc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Pa0jSMF/; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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=viymBDCrvjKdxY/tQOLTnCZyFrlNtSCuDcsjtwmyXNA=; b=Pa0jSMF/krI6acUWmrQTlbuXP+ Ixe/53+Exzh2YbMszXNUt7Fb7XOHiiPbSGyUs0xa62vLR3eyO8VKJI8L8yjnTnhAiawwx96JZXv3f cveQIL8B4NCcf3xkquIF30vei3mwsldKRMHaqmbC16L/RoDxa0NboQXn9kv1YMkUCKX7L8cTjNIfW dPbVk6Wo+56zHrCTXpb1B3wYxtnZZ+rPA6eqbSP1TZFCAbRa0/DhLjWNSMsF6RCQyIJYXsHAN67kq l2j6xGG7WT8hKe+Iqe9Mk9N/lgd3wER/3NdSDbnwQ8Crm38lvCQTLXhU4feH7spBwBzOzuo7+2oiY dwAolfrA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzU2F-0000000093z-10Cy; Wed, 24 Apr 2024 04:15:07 +0000 Date: Wed, 24 Apr 2024 05:15:07 +0100 From: Matthew Wilcox To: Lance Yang Cc: akpm@linux-foundation.org, maskray@google.com, ziy@nvidia.com, ryan.roberts@arm.com, david@redhat.com, 21cnbao@gmail.com, mhocko@suse.com, fengwei.yin@intel.com, zokeefe@google.com, shy828301@gmail.com, xiehuan09@gmail.com, wangkefeng.wang@huawei.com, songmuchun@bytedance.com, peterx@redhat.com, minchan@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/1] mm/vmscan: avoid split PMD-mapped THP during shrink_folio_list() Message-ID: References: <20240422055213.60231-1-ioworker0@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240422055213.60231-1-ioworker0@gmail.com> On Mon, Apr 22, 2024 at 01:52:13PM +0800, Lance Yang wrote: > When the user no longer requires the pages, they would use > madvise(MADV_FREE) to mark the pages as lazy free. IMO, they would not > typically rewrite to the given range. > > At present, PMD-mapped THPs that are marked as lazyfree during > shrink_folio_list() are unconditionally split, which may be unnecessary. > If the THP is clean, its PMD is also clean, and there are no unexpected > references, then we can attempt to remove the PMD mapping from it. This > change will improve the efficiency of memory reclamation in this case. Does this happen outside of benchmarks? I'm really struggling to see how we end up in this situation. We have a clean THP without swap backing, so it's full of zeroes, but for some reason we haven't used the shared huge zero page? What is going on?