From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe 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 Message-ID: <20181221033159.GF23877@ziepe.ca> References: <20181219182031.8675-1-swarren@wwwdotorg.org> <20181220174318.GA21404@ziepe.ca> <20181220174448.GA21149@lst.de> <1545328145.185366.500.camel@acm.org> <072c2d9d187daf0672bf54ab035e47a05fd1cd1d.camel@perches.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Bart Van Assche , Stephen Warren , Tariq Toukan , xavier.huwei@huawei.com, netdev@vger.kernel.org, linux-rdma@vger.kernel.org, Doug Ledford , Stephen Warren , Christoph Hellwig , Andrew Morton , Linus Torvalds To: Joe Perches Return-path: Received: from mail-pg1-f193.google.com ([209.85.215.193]:44767 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732228AbeLUDcB (ORCPT ); Thu, 20 Dec 2018 22:32:01 -0500 Received: by mail-pg1-f193.google.com with SMTP id t13so1825979pgr.11 for ; Thu, 20 Dec 2018 19:32:01 -0800 (PST) Content-Disposition: inline In-Reply-To: <072c2d9d187daf0672bf54ab035e47a05fd1cd1d.camel@perches.com> Sender: netdev-owner@vger.kernel.org List-ID: 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