Re: [PATCH] mm: Do not use double negation for testing page flags

From: Vlastimil Babka
Date: Wed Mar 08 2017 - 04:04:12 EST


On 03/08/2017 06:25 AM, Minchan Kim wrote:
> Hi Anshuman,
>
> On Tue, Mar 07, 2017 at 09:31:18PM +0530, Anshuman Khandual wrote:
>> On 03/07/2017 12:06 PM, Minchan Kim wrote:
>>> With the discussion[1], I found it seems there are every PageFlags
>>> functions return bool at this moment so we don't need double
>>> negation any more.
>>> Although it's not a problem to keep it, it makes future users
>>> confused to use dobule negation for them, too.
>>>
>>> Remove such possibility.
>>
>> A quick search of '!!Page' in the source tree does not show any other
>> place having this double negation. So I guess this is all which need
>> to be fixed.
>
> Yeb. That's the why my patch includes only khugepagd part but my
> concern is PageFlags returns int type not boolean so user might
> be confused easily and tempted to use dobule negation.
>
> Other side is they who create new custom PageXXX(e.g., PageMovable)
> should keep it in mind that they should return 0 or 1 although
> fucntion prototype's return value is int type.

> It shouldn't be
> documented nowhere.

Was this double negation intentional? :P

> Although we can add a little description
> somewhere in page-flags.h, I believe changing to boolean is more
> clear/not-error-prone so Chen's work is enough worth, I think.

Agree, unless some arches benefit from the int by performance
for some reason (no idea if it's possible).

Anyway, to your original patch:

Acked-by: Vlastimil Babka <vbabka@xxxxxxx>