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-next>] [day] [month] [year] [list]
Message-Id: <20231129104530.63787-1-v-songbaohua@oppo.com>
Date:   Wed, 29 Nov 2023 23:45:30 +1300
From:   Barry Song <21cnbao@...il.com>
To:     akpm@...ux-foundation.org, linux-mm@...ck.org
Cc:     david@...hat.com, shikemeng@...weicloud.com, willy@...radead.org,
        mgorman@...hsingularity.net, hannes@...xchg.org,
        baolin.wang@...ux.alibaba.com, linux-kernel@...r.kernel.org,
        Barry Song <v-songbaohua@...o.com>,
        Zhanyuan Hu <huzhanyuan@...o.com>
Subject: [RFC PATCH] mm: compaction: avoid fast_isolate_freepages blindly choose improper pageblock

Testing shows fast_isolate_freepages can blindly choose an unsuitable
pageblock from time to time particularly while the min mark is used
from XXX path:
 if (!page) {
         cc->fast_search_fail++;
         if (scan_start) {
                 /*
                  * Use the highest PFN found above min. If one was
                  * not found, be pessimistic for direct compaction
                  * and use the min mark.
                  */
                 if (highest >= min_pfn) {
                         page = pfn_to_page(highest);
                         cc->free_pfn = highest;
                 } else {
                         if (cc->direct_compaction && pfn_valid(min_pfn)) { /* XXX */
                                 page = pageblock_pfn_to_page(min_pfn,
                                         min(pageblock_end_pfn(min_pfn),
                                             zone_end_pfn(cc->zone)),
                                         cc->zone);
                                 cc->free_pfn = min_pfn;
                         }
                 }
         }
 }

In contrast, slow path is skipping unsuitable pageblocks in a decent way.

I don't know if it is an intended design or just an oversight. But
it seems more sensible to skip unsuitable pageblock.

Reported-by: Zhanyuan Hu <huzhanyuan@...o.com>
Signed-off-by: Barry Song <v-songbaohua@...o.com>
---
 mm/compaction.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/compaction.c b/mm/compaction.c
index 01ba298739dd..98c485a25614 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1625,6 +1625,12 @@ static void fast_isolate_freepages(struct compact_control *cc)
 	cc->total_free_scanned += nr_scanned;
 	if (!page)
 		return;
+	/*
+	 * Otherwise, we can blindly choose an improper pageblock especially
+	 * while using the min mark
+	 */
+	if (!suitable_migration_target(cc, page))
+		return;
 
 	low_pfn = page_to_pfn(page);
 	fast_isolate_around(cc, low_pfn);
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ