Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp847470rdb; Fri, 2 Feb 2024 06:04:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWBme8Ihu1XDb2Tfu8cQfoD1FhwMNas9KTAMYZPVNxHr4BSGr34q/EcnsqmIvbvS6QsVRl X-Received: by 2002:a17:902:a3c1:b0:1d9:2665:61c with SMTP id q1-20020a170902a3c100b001d92665061cmr2118800plb.8.1706882645313; Fri, 02 Feb 2024 06:04:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706882645; cv=pass; d=google.com; s=arc-20160816; b=xTOglVJvKkvxTZroZ/BiQeP0JnX0YtnUTUc1M6EXKeefviDNgfkUgzCd4X+EH00wSs h1CDsfvEAz1OiL1LAEYQprB5rdj9DaOiE/JkljoKWQG3T0Ztc7umTecmOrgRqheT1IY2 bgNdwQCpum0yeQdmp2He7rTGbKhOOwNphx9eHyZsCNXZpTqWkXIrtLeNBggugMIGFPUd S1xcBkJgDSckrM2FHJSK7Sn0gkk9PXb/TYlfHohRqLPqGytLH25A/WFQplc6JYFoUnCF xm7eKxwqyWxEdCSdvOPsmQUKyTy/uWW7jH5m6uU7onlEgDV7ZiyTnNrptXgmmVI/cO0A gMag== 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=o1y5HKtPqsFZrIHkvUvd/hYmvD5sU0rdmW57LkYYBH8=; fh=2QYsiqrxu6Q0NjlZBpdLwAmvjR/qcavpivOCA2lQi/k=; b=f54Qqr/wLMHMzetesEZm40Kon6N8iyhN8n/3CosdMKYUSpVn5Sw96o8bdel9XPTZ7J OrsFzvgtzzDj4kR9ldpe3Iu5R6M49rmuea9NY2PEofbqBugrmFRu3nGfa3qkzbzqb84G 5uHWi62+KhYhgVLZjQjBuUtLHl6g0PbAivm/YgAtPpYSjAgr4rrdhRi61EJloC/V0wBn E/lsAAbBNDkjBq5B9M7DTqq5Vj+3Cg4CROt/yq7uwgN0z94vPGP8691yRkSuc3pZJpV+ QyGeg0uk3FZ/RJPdKa2tIlDch4tv9LBrNOmisPyDNJEgJaER7s4vBv5Yp8DpSIzdNtzI kvcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VSQUCLkO; 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-49916-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49916-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCV1YPVTnuJoHqT+nuxNIQv1lqhp8EryRaftf8Uah+XHSR5NPwkzclQcXLhXFWTh1bj4bTH57u3DD6qvuidc+KKOGzQBeltBmjLb24aLLg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g13-20020a170902c98d00b001d9773a196csi758712plc.609.2024.02.02.06.04.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 06:04:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49916-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VSQUCLkO; 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-49916-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49916-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3BE26B292EC for ; Fri, 2 Feb 2024 13:47:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2D6A47768; Fri, 2 Feb 2024 13:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VSQUCLkO" Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (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 8F96E1FCA for ; Fri, 2 Feb 2024 13:47:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706881622; cv=none; b=Fg/s96+vME491sUt0RL/jgMLqf+BjSr0xsHBrvUL8aCGrBelIPuxfXV8qXZWkdlytwvXTVfma0EUWEG1jTISP3oDUPHWZKRh3wCPU/Fo4fE6okKQL806hADUTd41xwPUWMiQqHduemfwg0Ezkc2uGJjGPCM/zceNjHmkjteyOP0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706881622; c=relaxed/simple; bh=o1y5HKtPqsFZrIHkvUvd/hYmvD5sU0rdmW57LkYYBH8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=U+L20cr84VOvpPCSEkrFF7J1pKkpsR7qylyD+nFiQiyajTObBCpJtXAlUjU71Btw3+t/nd5G2CoH6YNYMBBpHYI+ZzCj3sNVf7PqM2JsRsn2OUf+hjBi/XFRrsdSDvLhKTyMQTzR1zsEVy+kcwbQAV9CLovif3VTb8YhDwS7Uto= 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=VSQUCLkO; arc=none smtp.client-ip=209.85.219.172 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-yb1-f172.google.com with SMTP id 3f1490d57ef6-dc6d8bd612dso1774416276.1 for ; Fri, 02 Feb 2024 05:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706881619; x=1707486419; 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=o1y5HKtPqsFZrIHkvUvd/hYmvD5sU0rdmW57LkYYBH8=; b=VSQUCLkOIeBVFs6vhAbK4VoUgp1I9yVZnPMV/uvgePmniq9P/Tbf3aPnayB4hP6B+r D9GhA0YZ5w6QfY39aZltJeL5e7zcGMuPCgRku4tB7oANIgFDYVOlwwV7nPR2bjoZYw2P X/DGReYQoxAWGtYEnN9U/3ML7bG3zQJ9ZLWAyr1toYyETOokjoHN7Apl2nYMcT+VIUOf bPdaRVDPmTL6dgFjp3rn4hY499FlB27h+yD8T1SGlSuOC7XbhxZcbiabbwHFxmolXs+F kol/FCOWcZO6GUTHjjnO8A3mhEYw58SfK7xrGv7xaHtPSfNB6ENn5q9Ax5UBA8VXY6tO MAsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706881619; x=1707486419; 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=o1y5HKtPqsFZrIHkvUvd/hYmvD5sU0rdmW57LkYYBH8=; b=E+g1s4/SRlftavyfexXRMGUEe50HIoQ3M04Akd4UbSqcctqLhd1R24MXhHCHCk8C4L wDZGg6i153J6eTGQKk5TkfyBWLY9uDydGmC1qkxBBW7dlZYL8aF/Z/R9b2YzYVhTZuud Zt2mb0rJhyH1cGlH4HotylIR8sIOG+lY57ikl92hvm30XOFVU+e03Db/Aa2Eu6djijpp fUmYN0FPY7rqcZnwFB1fyB0XJfSZPAwrq6i3/McjDcpsKGIF6pK+JPlp9NrsCXIhVTlJ tiNMOPvZREtAAzJ7UdTbti4RsRUpfXN6CrFcSooYKRRXNvgHPR5YfGCefJ8weVIX5a4H x8iw== X-Gm-Message-State: AOJu0YwSDJmmAyO/HMTB+dfMeF0YGemp6YG+LcaxStKxqJEckKPqloKH J2GZADJZhb54OlcigZjripAwg+6uXV+Qsad3jPuzOPDLQRDHmvUhVhKxsnhaBZKF4NGgFnxrHv6 G0yybSQuzI1Qa8JMdMEFIJQ6ntIM= X-Received: by 2002:a25:8701:0:b0:dc6:a128:55a6 with SMTP id a1-20020a258701000000b00dc6a12855a6mr2251493ybl.46.1706881619461; Fri, 02 Feb 2024 05:46:59 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240201125226.28372-1-ioworker0@gmail.com> In-Reply-To: From: Lance Yang Date: Fri, 2 Feb 2024 21:46:45 +0800 Message-ID: Subject: Re: [PATCH 1/1] mm/khugepaged: skip copying lazyfree pages on collapse To: Michal Hocko Cc: akpm@linux-foundation.org, zokeefe@google.com, david@redhat.com, songmuchun@bytedance.com, shy828301@gmail.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 Here is a part from the man page explaining the MADV_FREE semantics: The kernel can thus free thesepages, but the freeing could be delayed until memory pressure occurs. For each of the pages that has been marked to be freed but has not yet been freed, the free operation will be canceled if the caller writes into the page. If there is no subsequent write, the kernel can free the pages at any time. IIUC, if there is no subsequent write, lazyfree pages will eventually be reclaimed. khugepaged treats lazyfree pages the same as pte_none, avoiding copying them to the new huge page during collapse. It seems that lazyfree pages are reclaimed before khugepaged collapses them. This aligns with user expectations. However, IMO, if the content of MADV_FREE pages remains valid during collapse, then khugepaged treating lazyfree pages the same as pte_none might not be suitable. Thanks, Lance On Fri, Feb 2, 2024 at 8:57=E2=80=AFPM Michal Hocko wrote= : > > On Fri 02-02-24 20:52:48, Lance Yang wrote: > > On Fri, Feb 2, 2024 at 8:27=E2=80=AFPM Michal Hocko w= rote: > > > > > > On Fri 02-02-24 19:18:31, Lance Yang wrote: > > > > IMO, since it's treated the same as pte_none, > > > > perhaps lazyfree pages shouldn't be copied to > > > > the new huge page. > > > > > > Why? The content of MADV_FREE page is valid until it is reclaimed. > > > > IMO, if MADV_FREE pages are considered valid until > > reclaimed, treating them the same as pte_none might > > pose a conflict. > > What kind of conflict? > -- > Michal Hocko > SUSE Labs