On Wed, Jun 3, 2026 at 4:01 AM David Hildenbrand (Arm) <[email protected]> wrote: > > > > next_order: > > - if ((BIT(order) - 1) & enabled_orders) { > > - const u8 next_order = order - 1; > > - const u16 mid_offset = offset + (nr_ptes / 2); > > - > > - collapse_mthp_stack_push(cc, &stack_size, mid_offset, > > - next_order); > > - collapse_mthp_stack_push(cc, &stack_size, offset, > > - next_order); > > + if (order > KHUGEPAGED_MIN_MTHP_ORDER && > > + (BIT(order) - 1) & enabled_orders) { > > Why not a test_bit() ?
The test bit is at the top of the loop. This adds a exit if the lower orders are all disabled or we hit the last order. > > > But, wouldn't you want to skip orders that are not enabled and try with the > next > smaller one in any case before you advance the offset? We are currently iterating through each order (not skipping them). There may be optimizations to avoid iterating through every order (like your changes suggest), but currently, every collapse, whether it succeeds or fails at the bottom order, must also iterate the offset. lmk if that makes sense! -- Nico > > -- > Cheers, > > David >
