lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240604042454.2012091-5-alexs@kernel.org>
Date: Tue,  4 Jun 2024 12:24:46 +0800
From: alexs@...nel.org
To: 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,
	david@...hat.com
Cc: "Alex Shi (tencent)" <alexs@...nel.org>
Subject: [PATCH 04/10] mm/ksm: add identical_folio func

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;
+}
 static inline int pages_identical(struct page *page1, struct page *page2)
 {
 	return !memcmp_pages(page1, page2);
diff --git a/mm/ksm.c b/mm/ksm.c
index 21bfa9bfb210..2e4790842515 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1527,7 +1527,7 @@ static int try_to_merge_one_page(struct vm_area_struct *vma, struct folio *folio
 			if (!folio_test_dirty(folio))
 				folio_set_dirty(folio);
 			err = 0;
-		} else if (pages_identical(page, kpage))
+		} else if (identical_folio(folio, kfolio))
 			err = replace_page(vma, page, kpage, orig_pte);
 	}
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ