Subject: Re: rfc: bool structure members (was Re: [PATCH V3] net/mlx4: Get rid of page operation after dma_alloc_coherent)

From: Jason Gunthorpe <[email-masked]>
Date: Thu, 20 Dec 2018 20:31:59 -0700

On Thu, Dec 20, 2018 at 06:25:05PM -0800, Joe Perches wrote:

> I agree it's not a very good message nor is bool use
> of structure members a real problem except in very
> few cases.

I think the issue is that the link it shows lacks the context of the
discussion thread - and the actual guidance here is more
complicated.

A discussion in coding style would probably be better.

- Don't put multiple true/false fields in a single struct (be it bool,
  u8, int, etc) - use bit-fields instead.
- Don't use bool if cache line layout matters, its size and alignment
  varies
- Do use bool to clearly express that the variable, parameter or
  structure member can only take on a true/false value.

.. and I also seem to remember there is a small performance downside
to bool stores in some ABIs as the compiler has to cannonize stores to
0 or 1? But this also eliminates certain bug classes..

Jason