[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fd64e502-d40d-4380-830b-2f630de4dac9@redhat.com>
Date: Tue, 4 Jun 2024 10:25:52 +0200
From: David Hildenbrand <david@...hat.com>
To: alexs@...nel.org, Andrew Morton <akpm@...ux-foundation.org>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
izik.eidus@...ellosystems.com, willy@...radead.org, aarcange@...hat.com,
chrisw@...s-sol.org, hughd@...gle.com
Subject: Re: [PATCH 04/10] mm/ksm: add identical_folio func
On 04.06.24 06:24, alexs@...nel.org wrote:
> From: "Alex Shi (tencent)" <alexs@...nel.org>
>
> To replace pages_identical() func and further reduce the 'page' using in
> try_to_merge_one_page function.
>
> Signed-off-by: Alex Shi (tencent) <alexs@...nel.org>
> ---
> include/linux/mm.h | 17 +++++++++++++++++
> mm/ksm.c | 2 +-
> 2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 9849dfda44d4..2d1f16ffc6ac 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -4164,6 +4164,23 @@ static inline void setup_nr_node_ids(void) {}
>
> extern int memcmp_pages(struct page *page1, struct page *page2);
>
> +static inline int identical_folio(struct folio *folio1, struct folio *folio2)
> +{
> + int i, nr1, nr2, ret = 0;
> +
> + nr1 = folio_nr_pages(folio1);
> + nr2 = folio_nr_pages(folio2);
> + if (nr1 != nr2)
> + return 0;
> +
> + for (i = 0; i < nr1; i++) {
> + ret = memcmp_pages(folio_page(folio1, i), folio_page(folio2, i));
> + if (ret)
> + break;
> + }
> +
> + return !ret;
> +}
We never get there with large folios. So handling large folios is
completely unnecessary.
Keep it simple: either VM_WARN_ON_ONCE when a large folio is passed, or
simply return "false". Then, check only a single page.
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists