netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Joe Perches <joe@perches.com>
Cc: Bart Van Assche <bvanassche@acm.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Tariq Toukan <tariqt@mellanox.com>,
	xavier.huwei@huawei.com, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, Doug Ledford <dledford@redhat.com>,
	Stephen Warren <swarren@nvidia.com>,
	Christoph Hellwig <hch@lst.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: rfc: bool structure members (was Re: [PATCH V3] net/mlx4: Get rid of page operation after dma_alloc_coherent)
Date: Thu, 20 Dec 2018 20:31:59 -0700	[thread overview]
Message-ID: <20181221033159.GF23877@ziepe.ca> (raw)
In-Reply-To: <072c2d9d187daf0672bf54ab035e47a05fd1cd1d.camel@perches.com>

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

  parent reply	other threads:[~2018-12-21  3:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 18:20 [PATCH V3] net/mlx4: Get rid of page operation after dma_alloc_coherent Stephen Warren
2018-12-20 17:43 ` Jason Gunthorpe
2018-12-20 17:44   ` Christoph Hellwig
2018-12-20 17:49     ` Bart Van Assche
2018-12-21  2:25       ` rfc: bool structure members (was Re: [PATCH V3] net/mlx4: Get rid of page operation after dma_alloc_coherent) Joe Perches
2018-12-21  2:40         ` Andrew Morton
2018-12-21  3:31         ` Jason Gunthorpe [this message]
2018-12-21  5:12           ` Joe Perches
2018-12-21 23:52             ` Jason Gunthorpe
2018-12-23 16:42               ` Gal Pressman
2018-12-23 16:53                 ` Al Viro
2018-12-24 22:08                   ` Jason Gunthorpe
2018-12-24 23:12                 ` Jason Gunthorpe
2018-12-25  8:41                   ` Gal Pressman
2019-01-02 16:29   ` [PATCH V3] net/mlx4: Get rid of page operation after dma_alloc_coherent Stephen Warren
2019-01-03  7:48     ` Christoph Hellwig
2019-01-03 14:32     ` Tariq Toukan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181221033159.GF23877@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=akpm@linux-foundation.org \
    --cc=bvanassche@acm.org \
    --cc=dledford@redhat.com \
    --cc=hch@lst.de \
    --cc=joe@perches.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=swarren@nvidia.com \
    --cc=swarren@wwwdotorg.org \
    --cc=tariqt@mellanox.com \
    --cc=torvalds@linux-foundation.org \
    --cc=xavier.huwei@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).