Skip to contentSkip to conversation

mm/sparse: simplify the vmemmap alignment check

PATCH In review Kaitao Cheng 3 participants 3 messages Oct 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm/sparse: simplify the vmemmap alignment check

From: Kaitao Cheng <[email protected]>

sparse_init() is called only once during boot, and the vmemmap alignment check is outside any loop, so VM_WARN_ON_ONCE() provides no benefit over VM_WARN_ON() here.

Use VM_WARN_ON() and fold compound_info_has_mask() into its condition, preserving short-circuit evaluation.

---
 mm/sparse.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
mm/sparse.c +2 -4
index 6acb628c8a73..759b85172adb 100644
@@ -277,10 +277,8 @@ static void __init sparse_metadata_init(void)
  */
 void __init sparse_init(void)
 {
-	if (compound_info_has_mask()) {
-		VM_WARN_ON_ONCE(!IS_ALIGNED((unsigned long) pfn_to_page(0),
-				    MAX_FOLIO_VMEMMAP_ALIGN));
-	}
+	VM_WARN_ON(compound_info_has_mask() &&
+		   !IS_ALIGNED((unsigned long)pfn_to_page(0), MAX_FOLIO_VMEMMAP_ALIGN));
 
 	sparse_metadata_init();
 	sparse_init_subsection_map();
Signature · 1 line
2.53.0
#1 lore raw
Quoted 5 lines · Kaitao Cheng

From: Kaitao Cheng <[email protected]>

sparse_init() is called only once during boot, and the vmemmap alignment check is outside any loop, so VM_WARN_ON_ONCE() provides no benefit over VM_WARN_ON() here.

Okay, that's true. But who cares. __init section will be freed anyway. I don't see downside in current code.

Quoted 2 lines

Use VM_WARN_ON() and fold compound_info_has_mask() into its condition, preserving short-circuit evaluation.

Why? It only got harder to read, no?

Signature · 1 line
  Kiryl Shutsemau / Kirill A. Shutemov
#2 lore raw
Quoted 7 lines · Kiryl Shutsemau
Quoted 5 lines · Kaitao Cheng

From: Kaitao Cheng <[email protected]>

sparse_init() is called only once during boot, and the vmemmap alignment check is outside any loop, so VM_WARN_ON_ONCE() provides no benefit over VM_WARN_ON() here.

Quoted 7 lines

Okay, that's true. But who cares. __init section will be freed anyway. I don't see downside in current code.

Quoted 2 lines

Use VM_WARN_ON() and fold compound_info_has_mask() into its condition, preserving short-circuit evaluation.

Why? It only got harder to read, no?

This would be fine as part of some bigger rework, but standalone this cleanup is not very attractive :)

Signature · 3 lines
Cheers,

David