Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1658952rbb; Mon, 26 Feb 2024 17:58:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVcaXxHcGPvkiOc+qa9ZQhU11dC8cOHoxI3jarSlVre451jsGVN5VxVjVa60noAl40XTtxgl98G+kq3S3ctomU9TaGJtjrTBOcqQWDlBA== X-Google-Smtp-Source: AGHT+IElgzmqsTyg4k2gQ1w4biMA0iN+FqEZRjgrfVqiB+R+i26lWdeeODzELdPsdQr6Bv0twZ35 X-Received: by 2002:a17:90a:4c85:b0:29a:8c78:9a7 with SMTP id k5-20020a17090a4c8500b0029a8c7809a7mr5955030pjh.40.1708999091389; Mon, 26 Feb 2024 17:58:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708999091; cv=pass; d=google.com; s=arc-20160816; b=TeEG5H/RSNKxsmVgxv3+lSqQA8Xq3cLWQaPIRYDoBt9mp4kfJBEv3WRqWqx5oeVbe+ gKrYT16tITYJAFv0LhSCd5nO7EgBJbcng5NhddPiRQg7eDmb3amPgBXuVm3z+jA4jSA6 M6BNUwj8d2d0lTHqFAOxYD4MRLbKM71BDyyTkrehIRJCQIaNFYJWtpQljy25sx4NFY5B KxCPEVTAhUVb1Tw7qzAT0XXXTNFC7EmdBLHnw2KeYdUz4fC1F6bJwBqsR0HObj3T7/HT hCbwbG3diq80gxbpbQ4HHAtAYeYQFWZnQAnwYHzLpM1DWtyzuzBLMWv5XOew44SSDokU XMXQ== 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=3Q3okeBK/888jP630KPQ8RoIb8Z1wYCvm95ViNJwrqE=; fh=LbU4mmxMPAV/UVdjpH7qTtEKq3OeWOTr7fP9gQwmOzs=; b=Q5Cj0n70J/HQPdOfZZYhmq+p7p+LUKviDUVcZwFcr6CbEjHI5oCJSU91jRBrGeSxQx 3aE6eXNOfDwa7Fhk6xCiuY+3pPVMwjU6P5gYjF1dkBaT16wjE3WLmZ/D4Jtt7vqADLgI Fb0onhE6Fg62zQssWvooPc1Xp9zX2lQ3tD2V4nEO1gF/iUvzuBikvHrmq/MfzZaj16l/ 28kgQLwhWHSRnztLbqr9G+UjDYjNkhu5Sqg3KNVde7ZScdKbKs5jJIAJaCv9X3rWY8Ur 8/s/5GEsTaMQwdgFnzlYwVzZE58Jh5vD7et9kDd9GXFQRPwbFw4a5oFUUmWd9imemlDA TJKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cWfWTPvy; 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-82563-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82563-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. [139.178.88.99]) by mx.google.com with ESMTPS id fy8-20020a17090b020800b00298fdee2dfesi6504944pjb.165.2024.02.26.17.58.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 17:58:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82563-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=@gmail.com header.s=20230601 header.b=cWfWTPvy; 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-82563-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82563-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 1BA2E28E3E5 for ; Tue, 27 Feb 2024 01:49:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D110EAEB; Tue, 27 Feb 2024 01:48:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cWfWTPvy" Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.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 92ECC746E for ; Tue, 27 Feb 2024 01:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708998528; cv=none; b=lL5mZszv5fzaIwljOgeOUJql40s+aMGeWoVHL0THOpe5K6+bwWdEUvsD9zZAbKY7kiWpCEBkMp7pt0EcdsjbGGaGOTKJBLnAPbGME6xmRgR2xZUDMBbOU/4Zi25QDxXPCJcNmgQsOcRa+1Aqz1sh6vjPFB7jvYT6bIs+5KxOkC0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708998528; c=relaxed/simple; bh=V2zldjz7rPR5UN7z800aW/ADOx9Os94VdT725S90kkg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=aI5rq7KC8mSRkTOYEra4ESMgnGJJ9+4ou4OlR90uDwf8Dkz2r0aIQ+pjzjhZNhpxG2Icvclzn1lyIgPNu4qeOozVNdyUK/25ZTWMStsz68pdaO/aJTKQx4eu5WZxQgVoXjqTxQF8ADUd9WdkQQ1I+7AODrQUeunXT3YltCUK2o0= 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=cWfWTPvy; arc=none smtp.client-ip=209.85.128.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-yw1-f172.google.com with SMTP id 00721157ae682-607dec82853so39871727b3.3 for ; Mon, 26 Feb 2024 17:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708998525; x=1709603325; 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=3Q3okeBK/888jP630KPQ8RoIb8Z1wYCvm95ViNJwrqE=; b=cWfWTPvyZvOrhJon00Jd6XXeWCSIz4vAxIUZEYz8YA4IVnkwtN4TS7a4BVu1MhF43p IQmFMdQCFCmQHOQ44at4msPNcKHM8F6djmO2DWk5x+X/gU0dXS8depn863B8wtrISlHX 6xwBSBUR83X83JEmgJXUzbIHKR4rdIBumPo3k+KHtDWf5VPfKdwditzdbpiYYN6nx24b NNRuSFZkO0ubMnEEkE+IJq6H/zd4p1Axv6bgeNHQyvK4RZ89B3VZwNmyo12Lb7vV132A /XPZl03BdDATYrRlzThrJh16pCR3M2o0XsFzHqPoacoJI2o/naffeMicPjRkyN7InVGu Sd2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708998525; x=1709603325; 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=3Q3okeBK/888jP630KPQ8RoIb8Z1wYCvm95ViNJwrqE=; b=r4paQJXh1Smchu/w5/XJws4vUAd1gYkRkFSfZp/GkQUDhsDmBiF/L1tmTob79mB5K3 Yt6alUxn8Ee4bwGKChEQDSCduBkYoQAiPgAV/VkO2glYb2Yk6In//J1SC+J7iRjtBdN8 gP5CN2r0MjvX22K87pp0iLL0S+3GjrLbR3qfujeu0DX6DFoIxVvtheLTLYcGO5ZRa8qA GqJuYnSiyhYUVF0xq78c4YZflWNI/R+bWQQAKsLOSa+G4AI/HDpVKvYCfMvkx2EK3HQY iE9XTQkIQkG1x3q05dQWA2M1WpPdKuJpUAGyvVsg+idNTNJn0YEVgG88LcrIrcy6U2b7 WEBA== X-Forwarded-Encrypted: i=1; AJvYcCUgiGts9ja6iSXvYxNL+ke32Vc4dxbTILVKPaGdqrd3R8+v4/xr3dkWBilbDH45WNAVkZfJlhR4fKKYqcGn3E/OzCwG7WELILOunm8p X-Gm-Message-State: AOJu0Yw7bWDUdnIyBGJslGWe0xTiJNoLqmzVvQ02TxfgxLT4ebpktknO /+iauqUDqcoutarcDDAdQVpE3dVxOotitmabsI37nvSICmsQuDFs5aICzHe+yWT3paTxnS37ZyM KxjIXOj64F4J4VLwS4I1ed3FlNVY= X-Received: by 2002:a81:a9c6:0:b0:608:15e8:9283 with SMTP id g189-20020a81a9c6000000b0060815e89283mr824256ywh.3.1708998525650; Mon, 26 Feb 2024 17:48:45 -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: <20240227012127.174048-1-21cnbao@gmail.com> From: Lance Yang Date: Tue, 27 Feb 2024 09:48:34 +0800 Message-ID: Subject: Re: [PATCH 1/1] mm/madvise: enhance lazyfreeing with mTHP in madvise_free To: Barry Song <21cnbao@gmail.com> 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 9:21=E2=80=AFAM Barry Song <21cnbao@gmail.com> wrot= e: > > > 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. 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 i= t > > MADV_FREE, MADV_PAGEOUT and some other modules might need folio_pte_batch > 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 *fo= lio) > 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 bi= t. */ > +#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 p= te, fpb_t flags) > * If "any_writable" is set, it will indicate if any other PTE besides t= he > * first (given) PTE is writable. > */ > -static inline int folio_pte_batch(struct folio *folio, unsigned long add= r, > +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 >