Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2238786rbb; Tue, 27 Feb 2024 15:51:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXy+mP0D/h0hj7CrGu0QiGhZS0d+P8wU1bCubDaET5hYM+Pb2wmpfn9E03gpGTA9b3TogwYxQoz/BFzYbNfoLt5r50a/XCoz8cLXNMIXQ== X-Google-Smtp-Source: AGHT+IFvMV6oT7e882x+8Vzc2x+Rj9bGumm2pZzvJ5II3hFB/cC381hB73ylTAKzBWlXajcr6Dtd X-Received: by 2002:a17:90a:6d61:b0:299:e898:ed30 with SMTP id z88-20020a17090a6d6100b00299e898ed30mr8556153pjj.37.1709077867844; Tue, 27 Feb 2024 15:51:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709077867; cv=pass; d=google.com; s=arc-20160816; b=Q92v2gi/bX7ANm5bpGp54q6BLn6bVY7oJaNZJT42oglpVZA3KlyTkbP3O0Lfb7Hb30 avy3oKdnwF82ds3llOzxUdbh/K9m3tikIkkTF5ARBN8pGyhNYSmwfvxEfk8cTYsfye4a qIr4Ndec2/96A3vtHq9QYtptCKv0Emil4uoVtvm9oRHII14n3dFDCe/rno8+1RjX0iFS /bsG9gQXWLSzdKeULzc2KSoym6v9ZHWkEM20mFf/CW28r0dAxvoflwkt6HOgQemf1Teq Dl67hKHb+LckwY61bvS2O+Rcl4q1mWEy8WnOMB+yic55/U6BJvpPCbL/6Qzcj8AKir27 qqPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:cc:to:subject:message-id:from:dkim-signature; bh=k+BpDIFupl9L47GEChtRc9Hw8hU3e9sbyTct+1KRPXE=; fh=MPQdH7louWzPrD/3hQRqxA2hjsmBB0Y95C1BusriFXE=; b=dS7gqwGpd28yvrt/F8ZQW2GcZHgLR9uyRQJsegX9kgTUCaOybCK6ggKBUIsXXlPcpD hE75a1kQMvVC4zIYYdiT3tHJAlo7kK1BOAFaLdndNaos0B1lTK+SHU1TGp/Jpb+Dcjkl rnDQSN8/9Lc5Y8H5y5GZDHElf96xKygKkmKjnLDvOJ3UZzgxwUaczbIYoFFXcf6sZcC0 g44hp+cwjJG2v/wpvDVs1+Aa2Q+bagTdxCTOvcLcfSHyK3afSRg/MMT9MXwARDsjGJmE dFqiJ+0BHxxrhFrK8q9xGtJPVcWFLDcyHB7azUucBeF12+qlc1ma5HYhBGx3wRhJXBTC TWqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iTBWZuZ3; 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-84188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id r13-20020a17090b050d00b00299521eddabsi197194pjz.85.2024.02.27.15.51.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 15:51:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iTBWZuZ3; 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-84188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84188-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 D01CAB2B5C9 for ; Tue, 27 Feb 2024 23:19:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CDA856442; Tue, 27 Feb 2024 23:19:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iTBWZuZ3" Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 D8F7C55E48 for ; Tue, 27 Feb 2024 23:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709075943; cv=none; b=FowdKV2eCl8ZyotQ7RCL1Bqd1CYQkm3mPuOsxnDjZldQhIHTxeGI1GAbTY1nrfXW6DyTWZCRddu4rOOZtPIE/RNp1c/d89z/CjunBO0RWBUfJF8IYDs+6spTvCWDAtS0JQYgNsD37fIqphwgJikwjP4rQFDA+HmIK4OHpiWXeDE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709075943; c=relaxed/simple; bh=J/rjf5tMaNcfUn9YYabsx8GieQtnyoqfDdDiShchyvM=; h=From:Message-ID:Subject:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=I+GP0bnWqYeb+49i0zzsmeqWw6Bmexxt58Acj1oEmmXdKmTcpwtBZ4H9XxbCNftEXYyFGGo8Fl+T7LGz8p9sRwGF5GMWtOjWFsSmC1qLmlZ2n1jIZKfm+SaSCuse+IwsZl8GwYuNDHjnkForFDSKc5NHCCJaxTh95xpM/mOEEZA= 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=iTBWZuZ3; arc=none smtp.client-ip=209.85.214.173 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-pl1-f173.google.com with SMTP id d9443c01a7336-1dca8b86ee7so22856315ad.2 for ; Tue, 27 Feb 2024 15:19:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709075941; x=1709680741; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:subject:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=k+BpDIFupl9L47GEChtRc9Hw8hU3e9sbyTct+1KRPXE=; b=iTBWZuZ3HUMStn2YNcucsOT64KCl9zFEEBwRP0shgdNUmXiCR/CYVIrElaNIA5xsZu q8ceZ/ev69Y4B2pC+FCQ2v0ss76DUXl3OpKl9SpzYboMWqnLVQCR8g+Eq4phSk2CsJle DCmxxrtGJksTpiVvO5/bplsZw944DtHcwJPG/5MLQE3VIT7QvD7obrHuUTcKE8SLcOty B0wMTxStHDvhg6eHs6EpM7KXw8XQlEaKtgaHZ9LSUnPPlk2dk8PUILHgZ5IY07Jhq05I MdDNWZLyO3LcVAOG2yzRhL1PnfSkRYPiaM8Egpt+DX7v5K8BrNhtsszj7IV2eR4lsbBE Phhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709075941; x=1709680741; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:subject:message-id:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=k+BpDIFupl9L47GEChtRc9Hw8hU3e9sbyTct+1KRPXE=; b=p1E5gZGYPCzWDzoqrZN991FAbjni2V86Yu38JBDqNOVMGWodIfGMupuswBC9dvCdKD IgJKTjllLjve/adX19qTTDTRmESS8RwhTYETkv/qPs+JgkuMXtxbI47KK6cxV6eiVfU2 g+9T4YOCe9QMtBQn5lxJJAMFrbSiNzsPv8/c0Ov6ZQ0sEXAhmAeOnwfmsfwNc1uBUZyF ThjkDGvEB/LH3EgVoV88G1SmYv0o5JPBo0oZuIg9dCbFF6uWWJ/Ma9UV0Hbd9dh/oj0J +ZdoP8+mvZKHBav1Dc0dHlLZb8znLV9Hy56u68+hd3LqZzzBewJ4bbtYwlKg0bxDJw8g 5ytg== X-Forwarded-Encrypted: i=1; AJvYcCUOUbYkLiymSwwcH8saMS0dHn+uVUVm8cHm4WXAI8z4eXZ6fr84QGWKQgjFelgi5y+K0I6TuAdPHITKh+sRWTHht3U56/ecK/b6eQNH X-Gm-Message-State: AOJu0Yw77WjgbMY0o38PakfdxgbrsEO7NbiQ3k5+HM9LihyYcD1OjPHm 2ValnMYvGRKALPql+fKk4ROS3DwQefj5T8ySBNxRl2Vqc5EpI9uY X-Received: by 2002:a17:902:8349:b0:1db:5b41:c5ac with SMTP id z9-20020a170902834900b001db5b41c5acmr9865212pln.68.1709075941149; Tue, 27 Feb 2024 15:19:01 -0800 (PST) Received: from [10.239.156.40] ([148.87.23.13]) by smtp.googlemail.com with ESMTPSA id az2-20020a170902a58200b001dca920ae40sm2030171plb.203.2024.02.27.15.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 15:19:00 -0800 (PST) From: Khalid Aziz X-Google-Original-From: Khalid Aziz Message-ID: <661e519bc7753d784449931876a61f34bc8ad6ca.camel@oracle.com> Subject: Re: [PATCH v1] mm: convert folio_estimated_sharers() to folio_likely_mapped_shared() To: David Hildenbrand , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Barry Song , Vishal Moola , Ryan Roberts Date: Tue, 27 Feb 2024 16:18:59 -0700 In-Reply-To: <20240227201548.857831-1-david@redhat.com> References: <20240227201548.857831-1-david@redhat.com> Autocrypt: addr=khalid.aziz@oracle.com; prefer-encrypt=mutual; keydata=mQINBFA5V58BEADa1EDo4fqJ3PMxVmv0ZkyezncGLKX6N7Dy16P6J0XlysqHZANmLR98yUk41rpAY/Sj/+dhHy4AeMWT/E+f/5vZeUc4PXN2xqOlkpANPuFjQ/0I1KI2csPdD0ZHMhsXRKeNv32eOBivxyV0ZHUzO6wLie/VZHeem2r35mRrpOBsMLVvcQpmlkIByStXGpV4uiBgUfwE9zgoOSZ6m3sQnbqE7oSGJaFdqhusrtWesH5QK5gVmsQoIrkOt3Al5MvwnTPKNX5++Hbi+SaavCrODBoJolWd5R+H8aRpBh5B5R2XbIS8ELGJZfqV+bb1BRKeo0kvCi7G6G4X//YNsgLv7Xl0+AiwIu/ybxI1d4AtBE9yZlyG21q4LnO93lCMJz/XqpcyG7DtrWTVfAFaF5Xl1GT+BKPEJcI2NnYnGIXydyh7glBjI8GAZA/8aJ+Y3OCQtVxEub5gyx/6oKcM12lpbztVFnB8+S/+WLbHLxm/t8l+Rg+Y4jCNm3zB60Vzlz8sj1NQbjqZYBtBbmpy7DzYTAbE3P7P+pmvWC2AevljxepR42hToIY0sxPAX00K+UzTUwXb2Fxvw37ibC5wk3t7d/IC0OLV+X29vyhmuwZ0K1+oKeI34ESlyU9Nk7syc1WJmk71XIoxJhObOiXmZIvWaOJkUM2yZ2onXtDM45YZ8kyYTwARAQABtCNLaGFsaWQgQXppeiA8a2hhbGlkQGdvbmVoaWtpb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HdwtYsHpGmNEVn0hJKvUP6lAGGSuDDmwP+Q+ThOq6b6uIDPKZzYSaa9TmL4YIUY8OTjONJ0FLOQl7DsCVY9UIHF61AKOSrdgCJmN3d5lXevKWeYa+v6U7QXxM53e1L+6h1CSABlICA09WJP0Fy7ZOTvVjlJ3ApO0Oqsi8iArScpfbUuQYfPdk/QjyIzqvzklDfeH95HXLYEq8g+u7nf9jzRgff5230YW7BW0Xa94FPLXyHSc85TE1CNnmSCtgX15U67Grz03Hp9O29Dlg2XFGr9rK46Caph3seP5dBFjvPXIEC2lmyRDFPmw4ywKQczTkg+QRkC4j/CEFXw0EkwR8tDAPW/NVnWr/KSnR/qzdA4RRuevLSK0SYSouLQr4IoxAujnniu8LClUU5YxbF57rmw5bPlMrBNhO5arD8/b/XxLx/4jGQrcYM+VrMKALwKvPfj20mB6A== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.0-1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2024-02-27 at 21:15 +0100, David Hildenbrand wrote: > Callers of folio_estimated_sharers() only care about "mapped shared > vs. > mapped exclusively", not the exact estimate of sharers. Let's > consolidate > and unify the condition users are checking. While at it clarify the > semantics and extend the discussion on the fuzziness. >=20 > Use the "likely mapped shared" terminology to better express what the > (adjusted) function actually checks. >=20 > Whether a partially-mappable folio is more likely to not be partially > mapped than partially mapped is debatable. In the future, we might be > able > to improve our estimate for partially-mappable folios, though. >=20 > Note that we will now consistently detect "mapped shared" only if the > first subpage is actually mapped multiple times. When the first > subpage > is not mapped, we will consistently detect it as "mapped > exclusively". > This change should currently only affect the usage in > madvise_free_pte_range() and queue_folios_pte_range() for large > folios: if > the first page was already unmapped, we would have skipped the folio. >=20 > Cc: Barry Song > Cc: Vishal Moola (Oracle) > Cc: Ryan Roberts > Signed-off-by: David Hildenbrand This patch adds clarity while retaining current behavior, so looks good to me. Reviewed-by: Khalid Aziz > --- > =C2=A0include/linux/mm.h | 46 ++++++++++++++++++++++++++++++++++++-------= - > -- > =C2=A0mm/huge_memory.c=C2=A0=C2=A0 |=C2=A0 2 +- > =C2=A0mm/madvise.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 6 +++--- > =C2=A0mm/memory.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 2 +- > =C2=A0mm/mempolicy.c=C2=A0=C2=A0=C2=A0=C2=A0 | 14 ++++++-------- > =C2=A0mm/migrate.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 8 ++++---- > =C2=A06 files changed, 51 insertions(+), 27 deletions(-) >=20 > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 6f4825d829656..795c89632265f 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2147,21 +2147,47 @@ static inline size_t folio_size(struct folio > *folio) > =C2=A0} > =C2=A0 > =C2=A0/** > - * folio_estimated_sharers - Estimate the number of sharers of a > folio. > + * folio_likely_mapped_shared - Estimate if the folio is mapped into > the page > + * tables of more than one MM > =C2=A0 * @folio: The folio. > =C2=A0 * > - * folio_estimated_sharers() aims to serve as a function to > efficiently > - * estimate the number of processes sharing a folio. This is done by > - * looking at the precise mapcount of the first subpage in the > folio, and > - * assuming the other subpages are the same. This may not be true > for large > - * folios. If you want exact mapcounts for exact calculations, look > at > - * page_mapcount() or folio_total_mapcount(). > + * This function checks if the folio is currently mapped into more > than one > + * MM ("mapped shared"), or if the folio is only mapped into a > single MM > + * ("mapped exclusively"). > =C2=A0 * > - * Return: The estimated number of processes sharing a folio. > + * As precise information is not easily available for all folios, > this function > + * estimates the number of MMs ("sharers") that are currently > mapping a folio > + * using the number of times the first page of the folio is > currently mapped > + * into page tables. > + * > + * For small anonymous folios (except KSM folios) and anonymous > hugetlb folios, > + * the return value will be exactly correct, because they can only > be mapped > + * at most once into an MM, and they cannot be partially mapped. > + * > + * For other folios, the result can be fuzzy: > + * (a) For partially-mappable large folios (THP), the return value > can wrongly > + *=C2=A0=C2=A0=C2=A0=C2=A0 indicate "mapped exclusively" (false negative= ) when the folio > is > + *=C2=A0=C2=A0=C2=A0=C2=A0 only partially mapped into at least one MM. > + * (b) For pagecache folios (including hugetlb), the return value > can wrongly > + *=C2=A0=C2=A0=C2=A0=C2=A0 indicate "mapped shared" (false positive) whe= n two VMAs in > the same MM > + *=C2=A0=C2=A0=C2=A0=C2=A0 cover the same file range. > + * (c) For (small) KSM folios, the return value can wrongly indicate > "mapped > + *=C2=A0=C2=A0=C2=A0=C2=A0 shared" (false negative), when the folio is m= apped multiple > times into > + *=C2=A0=C2=A0=C2=A0=C2=A0 the same MM. > + * > + * Further, this function only considers current page table mappings > that > + * are tracked using the folio mapcount(s). It does not consider: > + * (1) If the folio might get mapped in the (near) future (e.g., > swapcache, > + *=C2=A0=C2=A0=C2=A0=C2=A0 pagecache, temporary unmapping for migration)= . > + * (2) If the folio is mapped differently (VM_PFNMAP). > + * (3) If hugetlb page table sharing applies. Callers might want to > check > + *=C2=A0=C2=A0=C2=A0=C2=A0 hugetlb_pmd_shared(). > + * > + * Return: Whether the folio is estimated to be mapped into more > than one MM. > =C2=A0 */ > -static inline int folio_estimated_sharers(struct folio *folio) > +static inline bool folio_likely_mapped_shared(struct folio *folio) > =C2=A0{ > - return page_mapcount(folio_page(folio, 0)); > + return page_mapcount(folio_page(folio, 0)) > 1; > =C2=A0} > =C2=A0 > =C2=A0#ifndef HAVE_ARCH_MAKE_PAGE_ACCESSIBLE > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index 50d146eb248ff..4d10904fef70c 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -1829,7 +1829,7 @@ bool madvise_free_huge_pmd(struct mmu_gather > *tlb, struct vm_area_struct *vma, > =C2=A0 * If other processes are mapping this folio, we couldn't > discard > =C2=A0 * the folio unless they all do MADV_FREE so let's skip the > folio. > =C2=A0 */ > - if (folio_estimated_sharers(folio) !=3D 1) > + if (folio_likely_mapped_shared(folio)) > =C2=A0 goto out; > =C2=A0 > =C2=A0 if (!folio_trylock(folio)) > diff --git a/mm/madvise.c b/mm/madvise.c > index 44a498c94158c..32a534d200219 100644 > --- a/mm/madvise.c > +++ b/mm/madvise.c > @@ -366,7 +366,7 @@ static int > madvise_cold_or_pageout_pte_range(pmd_t *pmd, > =C2=A0 folio =3D pfn_folio(pmd_pfn(orig_pmd)); > =C2=A0 > =C2=A0 /* Do not interfere with other mappings of this > folio */ > - if (folio_estimated_sharers(folio) !=3D 1) > + if (folio_likely_mapped_shared(folio)) > =C2=A0 goto huge_unlock; > =C2=A0 > =C2=A0 if (pageout_anon_only_filter && > !folio_test_anon(folio)) > @@ -453,7 +453,7 @@ static int > madvise_cold_or_pageout_pte_range(pmd_t *pmd, > =C2=A0 if (folio_test_large(folio)) { > =C2=A0 int err; > =C2=A0 > - if (folio_estimated_sharers(folio) > 1) > + if (folio_likely_mapped_shared(folio)) > =C2=A0 break; > =C2=A0 if (pageout_anon_only_filter && > !folio_test_anon(folio)) > =C2=A0 break; > @@ -677,7 +677,7 @@ static int madvise_free_pte_range(pmd_t *pmd, > unsigned long addr, > =C2=A0 if (folio_test_large(folio)) { > =C2=A0 int err; > =C2=A0 > - if (folio_estimated_sharers(folio) !=3D 1) > + if (folio_likely_mapped_shared(folio)) > =C2=A0 break; > =C2=A0 if (!folio_trylock(folio)) > =C2=A0 break; > diff --git a/mm/memory.c b/mm/memory.c > index 1c45b6a42a1b9..8394a9843ca06 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -5173,7 +5173,7 @@ static vm_fault_t do_numa_page(struct vm_fault > *vmf) > =C2=A0 * Flag if the folio is shared between multiple address > spaces. This > =C2=A0 * is later used when determining whether to group tasks > together > =C2=A0 */ > - if (folio_estimated_sharers(folio) > 1 && (vma->vm_flags & > VM_SHARED)) > + if (folio_likely_mapped_shared(folio) && (vma->vm_flags & > VM_SHARED)) > =C2=A0 flags |=3D TNF_SHARED; > =C2=A0 > =C2=A0 nid =3D folio_nid(folio); > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index f60b4c99f1302..0b92fde395182 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -642,12 +642,11 @@ static int queue_folios_hugetlb(pte_t *pte, > unsigned long hmask, > =C2=A0 * Unless MPOL_MF_MOVE_ALL, we try to avoid migrating a > shared folio. > =C2=A0 * Choosing not to migrate a shared folio is not counted as > a failure. > =C2=A0 * > - * To check if the folio is shared, ideally we want to make > sure > - * every page is mapped to the same process. Doing that is > very > - * expensive, so check the estimated sharers of the folio > instead. > + * See folio_likely_mapped_shared() on possible imprecision > when we > + * cannot easily detect if a folio is shared. > =C2=A0 */ > =C2=A0 if ((flags & MPOL_MF_MOVE_ALL) || > - =C2=A0=C2=A0=C2=A0 (folio_estimated_sharers(folio) =3D=3D 1 && > !hugetlb_pmd_shared(pte))) > + =C2=A0=C2=A0=C2=A0 (!folio_likely_mapped_shared(folio) && > !hugetlb_pmd_shared(pte))) > =C2=A0 if (!isolate_hugetlb(folio, qp->pagelist)) > =C2=A0 qp->nr_failed++; > =C2=A0unlock: > @@ -1032,11 +1031,10 @@ static bool migrate_folio_add(struct folio > *folio, struct list_head *foliolist, > =C2=A0 * Unless MPOL_MF_MOVE_ALL, we try to avoid migrating a > shared folio. > =C2=A0 * Choosing not to migrate a shared folio is not counted as > a failure. > =C2=A0 * > - * To check if the folio is shared, ideally we want to make > sure > - * every page is mapped to the same process. Doing that is > very > - * expensive, so check the estimated sharers of the folio > instead. > + * See folio_likely_mapped_shared() on possible imprecision > when we > + * cannot easily detect if a folio is shared. > =C2=A0 */ > - if ((flags & MPOL_MF_MOVE_ALL) || > folio_estimated_sharers(folio) =3D=3D 1) { > + if ((flags & MPOL_MF_MOVE_ALL) || > !folio_likely_mapped_shared(folio)) { > =C2=A0 if (folio_isolate_lru(folio)) { > =C2=A0 list_add_tail(&folio->lru, foliolist); > =C2=A0 node_stat_mod_folio(folio, > diff --git a/mm/migrate.c b/mm/migrate.c > index 73a052a382f13..35d376969f8b9 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -2568,11 +2568,11 @@ int migrate_misplaced_folio(struct folio > *folio, struct vm_area_struct *vma, > =C2=A0 /* > =C2=A0 * Don't migrate file folios that are mapped in multiple > processes > =C2=A0 * with execute permissions as they are probably shared > libraries. > - * To check if the folio is shared, ideally we want to make > sure > - * every page is mapped to the same process. Doing that is > very > - * expensive, so check the estimated mapcount of the folio > instead. > + * > + * See folio_likely_mapped_shared() on possible imprecision > when we > + * cannot easily detect if a folio is shared. > =C2=A0 */ > - if (folio_estimated_sharers(folio) !=3D 1 && > folio_is_file_lru(folio) && > + if (folio_likely_mapped_shared(folio) && > folio_is_file_lru(folio) && > =C2=A0 =C2=A0=C2=A0=C2=A0 (vma->vm_flags & VM_EXEC)) > =C2=A0 goto out; > =C2=A0