On Wed, 20 Jul 2022, Zach O'Keefe wrote: > cc->is_khugepaged is used to predicate the khugepaged-only behavior > of enforcing khugepaged heuristics limited by the sysfs knobs > khugepaged_max_ptes_[none|swap|shared]. > > In branches where khugepaged_max_ptes_* is checked, consistently check > cc->is_khugepaged first. Also, local counters (for comparison vs > khugepaged_max_ptes_* limits) were previously incremented in the > comparison expression. Some of these counters (unmapped) are > additionally used outside of khugepaged_max_ptes_* enforcement, and > all counters are communicated in tracepoints. Move the correct > accounting of these counters before branching statements to avoid future > errors due to C's short-circuiting evaluation. > > Fixes: 9fab4752a181 ("mm/khugepaged: add flag to predicate khugepaged-only behavior") > Link: https://lore.kernel.org/linux-mm/Ys2qJm6FaOQcxkha@xxxxxxxxxx/ > Signed-off-by: Zach O'Keefe <zokeefe@xxxxxxxxxx> Acked-by: David Rientjes <rientjes@xxxxxxxxxx>