Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1664591rbb; Mon, 26 Feb 2024 18:13:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVypdOD4DlI9xTGxKC36rDjhEdakszTkNfKX6RdiNTJ/Mr7tAfICPh9LQW+1curODFw8wIhUEC32P8lWrXqBzCS8R/xK2flZ2tME+8/YA== X-Google-Smtp-Source: AGHT+IH+9HexBI4xMfWExgUg7zW7kL8qWjpLS29fjiVW4IppNzBHs2w09qcTgwS+cAtg5TcG3KOc X-Received: by 2002:a05:6402:354a:b0:565:98c5:6c38 with SMTP id f10-20020a056402354a00b0056598c56c38mr6906497edd.7.1708999984582; Mon, 26 Feb 2024 18:13:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708999984; cv=pass; d=google.com; s=arc-20160816; b=PDfjEc50a6YH6wcuxBTglPCjeauu4Tc8fRXmfhBR33J7GNtv0eed2pDtLhk2wxmnow O9ddJ1YOKKI8IBvoVIRP4HzfZx1iBm6lMmZbWNTxw4O0oOPQT3mK4nKkNfIfvLyFv62/ j8scmFIHoSZoNrT2zEOvCQMkwDhXMr9avgrnAUjvx1X5RmU9HwySDTIRMMxnBqjiRl4u mOFW418O2JvAxSbWxxQu5gi6pyoHIPesozcKRP8e+Mjj6D1PSbYcM7n5tz4RnjZe1r7x r6xmJjrropxekq9khrfBQgFRiBjQ0Slorq8JdfaTtXaElavxdnJlfZVi6slgBF/naa0J 0BGw== 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=p4AL21Kby9XJrGNwCYh+T8ly2jOpVTK59tg/4cTmKhs=; fh=qLQAIZzFYa8lT2ScHveGLNxlRHyJ3OEhPzAl3gEXOWs=; b=Vvg01uI36I77TIRSl4rs8xLOtlROKQNvjNDvO+g82aRz9bQgAVOJ/cYpCAVj7PH7eA B1ML4ct+DvdQWEdD4vdVKWMPZjPXYBIPDpX8WgP970UB4isFVlotwFAHGarxh/uMZYVC c76OGCnP3QGJHjnoCWkRWPRzrjG9jPqXkHXN79bF/FDP4fAoKfrnUF7gGngc/LfLZ5kE z5J4VlY5Xls3/LhpKtsESy+uG2uaSuIUt+woOgMFTdW2lGsN7Xrbrd62DUHPazOdXwO3 Em0ZmSOxPyva/V6VyZ288I0H846dlAemNsdcdNIGZ6PxGQRjCBjjCLI346eTSYPqo5EC Y8dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M9NG9NOB; 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-82579-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82579-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h25-20020aa7c619000000b00565b744b3aasi263859edq.469.2024.02.26.18.13.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 18:13:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82579-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M9NG9NOB; 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-82579-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82579-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 229B91F23649 for ; Tue, 27 Feb 2024 02:13:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 666BBF4FC; Tue, 27 Feb 2024 02:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M9NG9NOB" Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) (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 1257437E for ; Tue, 27 Feb 2024 02:12:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708999975; cv=none; b=oejqWE3+yTgL6gH9n8IfDsldKqp5olRiG3h/Sb9AIBCYcVBhmCmiocWx3wZJtUe5ndJFkqYiSztSNyS8wSbbmbHznweD1eRltLhDHSIXhF/krAek01v9GH/m4cP2BXqKrbL6FhMq71AT9JEx1gXtvjKHKx95a7qahEwAuPYax40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708999975; c=relaxed/simple; bh=vESwIVXswi9nugB34EWR/L/vu4C3av3Yags8x4JfyzI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IK7VBOv8uf7+Iz4I4fOcyF4/MOvBTrha/FA4P3WaNF8glccjqfNM7Nk6Gx/y2NGR8B7D7UMcRmVysOAeJIrJjtm/sm5vTt5rmb0kAYOfD2d9snd50cFVstwynzeW1jSkzn/U0yvy2ocrCv+eQ54muiuyoh1ddPNAwiBe0GWPZ/E= 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=M9NG9NOB; arc=none smtp.client-ip=209.85.217.46 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-vs1-f46.google.com with SMTP id ada2fe7eead31-4704c69a3d9so508503137.2 for ; Mon, 26 Feb 2024 18:12:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708999973; x=1709604773; 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=p4AL21Kby9XJrGNwCYh+T8ly2jOpVTK59tg/4cTmKhs=; b=M9NG9NOBduBHFeoHYAJLCig10IzcrUxFnz80qJ39jORH0oFRyr1zLjwhPTgOYPf+X0 BRafs9vA0rVYmYzR8mrZFRF5KmFu+kdmcrspsWNu01rclwDF8tK+9x9FNAAR2LU4NR1M eHsfKo/3NtMYIg2Q13RrKFY4mdWXRMGejILFxOdT+RQxHHZWg8kXb2uiYN2ziUqsoADu yXoGZ449a7KGIc5eahM8KwFBubYPJ9+QZNwK4QmZEmLLAbbHtehwwOOp7EmwGgruQqVx KSgbYpa6TX/d/XzcSTF93UxFKimGDrbRZsfGm3Pecdm4lV0tU/eo8hqdkzz9sSWkluFB Nzxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708999973; x=1709604773; 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=p4AL21Kby9XJrGNwCYh+T8ly2jOpVTK59tg/4cTmKhs=; b=HSmTW5xoEPikI4hwGQc/RW7/Q6bjNHvpfzvYWrEM4wmbBiM8ANSTrLtxwXs1YPjKfS WbNg5Xl/A9cQOa+esNEz+mL+p7AJwxqM3kXJxPV3WOVUbQ3r49Nrk4flvO5BO3I0HeCu ZG3mWOiAg5M1HBTXBk+vDrnlGOWzIRZEI8MV6dRUQutUdVR1NRW6cURnucFhLWOSpdTK 7y+Tv83rKxWopfzVBkjR7HiGE+Slheb5/B5CYHIM8Pybc/vCEpQbzkw/ZzAQiHivkQKj XTctvnoFJjNlzapPmE745xGmV0TGbpMdscfs+sA8IJnIOIcBAxfzOZUW9d7LkinXakVJ nOWg== X-Forwarded-Encrypted: i=1; AJvYcCWTBrgK1Rui36rAkEWXJzswHFNaHuGniWI4H8AKE+RL3Dt19Uxm0CO0JbTYg8byLp2KqNrlhAj5IVGCloEj3ab7kU8Qgj9HAvoxXxvj X-Gm-Message-State: AOJu0Yw9ND+EeU1tOYmYjJ29VD485Y0KogujhL3qI62xSwxvdSnBa+Or ifaVhvQLqNat64/QNZMfPrkZ3xW6X4RClOp2xuF2tunFEHqiqJY7pcPv+1eEpMDeEy9YF/ZIuAS BtBK7ngDblugzMcK2enl3y9fr5rU= X-Received: by 2002:a67:fc84:0:b0:470:3afd:81dd with SMTP id x4-20020a67fc84000000b004703afd81ddmr6274013vsp.4.1708999972959; Mon, 26 Feb 2024 18:12:52 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240227012127.174048-1-21cnbao@gmail.com> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Tue, 27 Feb 2024 15:12:42 +1300 Message-ID: Subject: Re: [PATCH 1/1] mm/madvise: enhance lazyfreeing with mTHP in madvise_free To: Lance Yang Cc: akpm@linux-foundation.org, david@redhat.com, fengwei.yin@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhocko@suse.com, minchan@kernel.org, peterx@redhat.com, ryan.roberts@arm.com, shy828301@gmail.com, songmuchun@bytedance.com, wangkefeng.wang@huawei.com, zokeefe@google.com, Barry Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 27, 2024 at 2:48=E2=80=AFPM Lance Yang wr= ote: > > On Tue, Feb 27, 2024 at 9:21=E2=80=AFAM Barry Song <21cnbao@gmail.com> wr= ote: > > > > > Thanks for your suggestion. I'll use folio_pte_batch() in v2. > > > > Hi Lance, > > Obviously, we both need this. While making large folio swap-in > > v2, I am exporting folio_pte_batch() as below, > > Thanks, Barry. > > Could you separate the export of folio_pte_batch() from the large folio > swap-in v2? Prioritizing the push for this specific change would aid in > the development of the v2 based on it. I agree we should make this one pulled in by Andrew early to avoid potentia= l dependencies and conflicts in two jobs. > > Best, > Lance > > > > > From: Barry Song > > Date: Tue, 27 Feb 2024 14:05:43 +1300 > > Subject: [PATCH] mm: export folio_pte_batch as a couple of modules need= it > > > > MADV_FREE, MADV_PAGEOUT and some other modules might need folio_pte_bat= ch > > to check if a range of PTEs are completely mapped to a large folio with > > contiguous physcial offset. > > > > Cc: Lance Yang > > Cc: Ryan Roberts > > Cc: David Hildenbrand > > Signed-off-by: Barry Song > > --- > > mm/internal.h | 13 +++++++++++++ > > mm/memory.c | 2 +- > > 2 files changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/mm/internal.h b/mm/internal.h > > index 36c11ea41f47..7e11aea3eda9 100644 > > --- a/mm/internal.h > > +++ b/mm/internal.h > > @@ -83,6 +83,19 @@ static inline void *folio_raw_mapping(struct folio *= folio) > > return (void *)(mapping & ~PAGE_MAPPING_FLAGS); > > } > > > > +/* Flags for folio_pte_batch(). */ > > +typedef int __bitwise fpb_t; > > + > > +/* Compare PTEs after pte_mkclean(), ignoring the dirty bit. */ > > +#define FPB_IGNORE_DIRTY ((__force fpb_t)BIT(0)) > > + > > +/* Compare PTEs after pte_clear_soft_dirty(), ignoring the soft-dirty = bit. */ > > +#define FPB_IGNORE_SOFT_DIRTY ((__force fpb_t)BIT(1)) > > + > > +extern int folio_pte_batch(struct folio *folio, unsigned long addr, > > + pte_t *start_ptep, pte_t pte, int max_nr, fpb_t flags, > > + bool *any_writable); > > + > > void __acct_reclaim_writeback(pg_data_t *pgdat, struct folio *folio, > > int nr_throttled); > > static inline void acct_reclaim_writeback(struct folio *folio) > > diff --git a/mm/memory.c b/mm/memory.c > > index 6378f6bc22c5..dd9bd67f037a 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -989,7 +989,7 @@ static inline pte_t __pte_batch_clear_ignored(pte_t= pte, fpb_t flags) > > * If "any_writable" is set, it will indicate if any other PTE besides= the > > * first (given) PTE is writable. > > */ > > -static inline int folio_pte_batch(struct folio *folio, unsigned long a= ddr, > > +int folio_pte_batch(struct folio *folio, unsigned long addr, > > pte_t *start_ptep, pte_t pte, int max_nr, fpb_t flags, > > bool *any_writable) > > { > > -- > > 2.34.1 > > > > > Best, > > > Lance > > Thanks Barry > >