Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp541678lqd; Wed, 24 Apr 2024 09:32:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXImaG3mv4/CnXUwJGLMFC6b6VnS4+vX2b5NE40A4F7QwI2alh5yvncobG+huwNoHrr6khXP0T/FwYyRj+5+vdLwzdMf39LsPY3ftf9zw== X-Google-Smtp-Source: AGHT+IGbLVcymHgLfX0s+lTcQ3Q7MIW4xH3xO6GPPSd2AJlZrSogNjvI0Audgo2ZtFgQFJDpDziG X-Received: by 2002:a17:903:22c4:b0:1e5:d0e3:b960 with SMTP id y4-20020a17090322c400b001e5d0e3b960mr3029354plg.11.1713976364572; Wed, 24 Apr 2024 09:32:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713976364; cv=pass; d=google.com; s=arc-20160816; b=yyeC+Z1fb5uDR5oN8fcRa8z8HsLJqbuShIdTFhP8hqhOlUia/E2b9QCxcshgt0Lu/M eyStq0kPrM53flSDCdY0ccwIjUnt4K3QLYTJ2Qe2WXtK32RZ775iNQIe9fRr7S7UUZ/U hEmfrFSTeeU/VO0lHqvxFdCnLGsWXQEFPIDrLVfo7Sw+O4NMVd59Ir0OIxXTYBzZrvVe 6+PiiTu3+8qdVIij+c8B4XVcS/z+yNBIW0henm/6Fhisc4kxRsi1dGKx4ZAfxpeO2TGu NiMovgY/zSV83WIC6eHSos7zh2txPYumK208srtGRGa8RUe8e9g7VflUT7isBKbpjN4R MuQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=XCifhvSmEG7DOCXgTsfn1cm9CMTgVX4fQMep4eOKQI8=; fh=mczFvn7FvXU08kaZC70NwL3UC0EuWuYOCMiAAo1//6o=; b=gqXTWKV6IYFK5CdE1DoRA+AmpaStrPH+YjiJ0E4Q0MXslYKsl+IIE+Gxyq9gaeJyaK t8c52EqE5+jtijqw2MzuZ5/JvNyRmnf2UfaCqaMeOtPCW/yFjNk+B3Aufq1HO4R2SAYM St/RLe6NMT4RzHl9mtwTbuY0j9rjprhdJmxWZGc4bidVMLsWqer9YW6r3WYPqWUwpqg2 CA78TcTESzawreIe8hFF25P0O60Mh+2HyETYrbIaPnAXo3Bd8TjeVQSWw9bgeKhriqER rhkjfIUkPq30ej/zXiri9x0XMCfuEBcMlLKdusgtb+in/rLf8Jx9n8YpgsqFNhZAXpJE MdCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VTuPmSx1; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-157237-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157237-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f9-20020a170902ce8900b001e84bbfd510si12065633plg.513.2024.04.24.09.32.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 09:32:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157237-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VTuPmSx1; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-157237-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157237-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 9CFBF295061 for ; Wed, 24 Apr 2024 15:47:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DCAD15FCE1; Wed, 24 Apr 2024 15:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VTuPmSx1" Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E7D41422AF for ; Wed, 24 Apr 2024 15:47:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713973634; cv=none; b=m5PP4+SQy/E/w93UAU2TsSoCWuTK66NuS35EkQCkGwVpH8QC9iasZ6Om/N1eQq7UbIqlsQ5eU9BufDXa7BD/SaSQD97aOz5fkWY16ldKQidMI7uXmjcGaQb3We16yHpsUO8OvFWcKc9fd+PvbBLeS2k1ubiQqevXIvo/W8hOS24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713973634; c=relaxed/simple; bh=vO1WEk1IfrQ74RLtZrMBSriX+BAuVhG8i7srJ7+E87g=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=LLMHwyvY/uMHxD7mKqwfBteW4HjXl6Q8VJlrg/C61/YeZhZM0QySakmSaqhfsiqydoHofzZrb6NspNjPN9r9zglRwkvJyCzu85yiH8wKYqafrbN6fxUqrGe4y+emE1wMMvA49CjbL7szpC7Z3amglj45KJFuIIltguVDgvkdQeA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VTuPmSx1; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-572040691c9so70743a12.1 for ; Wed, 24 Apr 2024 08:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713973631; x=1714578431; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XCifhvSmEG7DOCXgTsfn1cm9CMTgVX4fQMep4eOKQI8=; b=VTuPmSx13c6Pzv+WVa0ZgMVGvoyirEcgsGTiOhUMmzHtZhZKYSpUbJiTwqYWeR4zlx Xdo8SzaZVy6ruZgu153yFtvSKpLA7lopUXpFAyyBqujYcth1qUn8iHJp29d4vFvK4FRh vUpAO6GpH9C2vsdjLzMfp62E+2nOd1K7Vgc/zc3iE/PKsAcQtqT4ZLjkTODLMoL+6YS6 QgwlauBjPp1/9+DC0lFOLB/sp4sQgY3S2sLawbKCJr3Qzg8ey9/ZHtdEc/J5n+yZbYGj FXFvr4mzaCpVZVXcZWjVkkTGD5UzVQaGi9tx379z9u6MhtuvxSq/qvw6Z0SAbqZe6bGQ 1+hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713973631; x=1714578431; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XCifhvSmEG7DOCXgTsfn1cm9CMTgVX4fQMep4eOKQI8=; b=uTZS5NVQlhfcLkT5Q+xevWVlGiOPBEJ9R2u3Z/YkhFPDjIQAlqo+9ckg5ZhqqftBHC WgTeWtC4c3R6+tr5p0wzBXDjZEIs+60+xttyO5TIWMHIACgQqgLYLjzg+6Bps3puVXP6 b3dPLK52CKxznRAfns2Oqgdvqp/AnJVBhMTOy5RWZesSmCe9jTAGyCoVhTTcAZ3VOv6L J9mJiPUjTRzv1Mjlvo+Bsj+bkB5TfqvwiAmXx+XNe08mKISr28ssKxvI9KroA2DsOHOl QmJzWBPcylYFMb62j2/WLYM1IALKvBzU1Hs0D18UH2W//kiitmzTWBt6Sb6wKgyU9CyY J05Q== X-Forwarded-Encrypted: i=1; AJvYcCVbuH10dOGcjKOcE9yFIBmP/pFHrH9GDCJhsC4hSO8GipDrokhaS0/FhNejNN5eJBwpEJiQaA9uav8SRVG5WCY7aBthUIp3O8EfwbT5 X-Gm-Message-State: AOJu0YzrcyoP/TzHb0wY+HZ0TROFG8vUsHuD+bNVLRcDqcFHBkC+PO3N JKQ0yzG7BtxbZUCZb6yyMYxsmFaxXc8Dmy/IQya/oSHN2MnKRNSBs5/phyMC1bsEFoOtGpP+QUo bpqYUw0JTNSIRzAgOq8pg0S5vL6A= X-Received: by 2002:a50:d543:0:b0:56d:fc50:ec50 with SMTP id f3-20020a50d543000000b0056dfc50ec50mr43929edj.13.1713973631300; Wed, 24 Apr 2024 08:47:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240422055213.60231-1-ioworker0@gmail.com> In-Reply-To: From: Lance Yang Date: Wed, 24 Apr 2024 23:46:59 +0800 Message-ID: Subject: Re: [PATCH v2 1/1] mm/vmscan: avoid split PMD-mapped THP during shrink_folio_list() To: Matthew Wilcox 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Matthew, Thanks for taking time to review. On Wed, Apr 24, 2024 at 12:15=E2=80=AFPM Matthew Wilcox wrote: > > 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 "If the THP is clean, its PMD is also clean" can be confusing - sorry. It s= hould be modified to "If the THP and its PMD are both marked as clean". Thanks, Lance > > 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? >