Re: [PATCH 0/2] mm: thp: reduce unnecessary start_stop_khugepaged() calls

From: David Hildenbrand (Arm)

Date: Thu Mar 05 2026 - 08:18:18 EST


On 3/5/26 13:45, Lorenzo Stoakes (Oracle) wrote:
> On Thu, Mar 05, 2026 at 01:41:33PM +0100, David Hildenbrand (Arm) wrote:
>>
>>>
>>> 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.

I consider

if (x)
return true;
return false;

rather ... questionable :)

--
Cheers,

David