On 04.06.24 06:24, alexs@xxxxxxxxxx wrote:
From: "Alex Shi (tencent)" <alexs@xxxxxxxxxx>
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@xxxxxxxxxx>
---
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