mm/sparse: simplify the vmemmap alignment check
Subsystems (2)
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
@@ -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
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, soVM_WARN_ON_ONCE()provides no benefit overVM_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 foldcompound_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
David Hildenbrand (Arm)
maintainerQuoted 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, soVM_WARN_ON_ONCE()provides no benefit overVM_WARN_ON()here.
Quoted 7 lines
Okay, that's true. But who cares.
__initsection will be freed anyway. I don't see downside in current code.Quoted 2 lines
Use
VM_WARN_ON()and foldcompound_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