Re: [PATCH] slab.h: Avoid using & for logical and of booleans

From: William Kucharski
Date: Tue Nov 06 2018 - 04:45:54 EST




> On Nov 5, 2018, at 14:13, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>> On Mon, 5 Nov 2018 12:40:00 -0800 Bart Van Assche <bvanassche@xxxxxxx> wrote:
>> - return type_dma + (is_reclaimable & !is_dma) * KMALLOC_RECLAIM;
>> + return type_dma + is_reclaimable * !is_dma * KMALLOC_RECLAIM;
>> }
>>
>> /*
>
> I suppose so.
>
> That function seems too clever for its own good :(. I wonder if these
> branch-avoiding tricks are really worthwhile.

At the very least I'd like to see some comments added as to why that approach was taken for the sake of future maintainers.

William Kucharski