Re: [PATCH 0/2] mm: thp: reduce unnecessary start_stop_khugepaged() calls
From: Lorenzo Stoakes (Oracle)
Date: Thu Mar 05 2026 - 07:46:54 EST
On Thu, Mar 05, 2026 at 01:41:33PM +0100, David Hildenbrand (Arm) wrote:
>
> >> +
> >> + /* Check if anything has to be done */
> >> + if (hugepage_pmd_enabled() == !!khugepaged_thread)
> >
> > This is horrible, better to break out the latter expression as a small static
> > function like:
> >
> > static bool is_khugepaged_thread_running(void)
> > {
> > if (khugepaged_thread)
> > return true;
> > return false;
>
> return khugepaged_thread;
>
> should do the trick, given taht the return type of the function is a bool :)
Yeah I know :)
I mean it's subjective, but this form makes it clear that what you're returning
is _not_ a boolean.
I was a bit 'meh' when I first saw this pattern, but it's grown on me, sort of a
'make it so simple you can't get confused' kinda thing.
>
> > }
>
> --
> Cheers,
>
> David
Cheers, Lorenzo