Received: by 10.192.165.156 with SMTP id m28csp974806imm; Wed, 11 Apr 2018 10:09:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ddwMVQn6erKWJPIZ8SmX66rB/S3kjLnQPVHeWnKeLzmt2BDFceCo7P7i/ysKEr5yf9hKc X-Received: by 2002:a17:902:10c:: with SMTP id 12-v6mr5805684plb.405.1523466561133; Wed, 11 Apr 2018 10:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523466561; cv=none; d=google.com; s=arc-20160816; b=KgIZR3fDnIv4YDQ3tEUpCIUSAWQo7XCB+Gr50dp9jt1SLYwLFl2J/q3JATtO8PWWU2 1EBWitb1P2EP0UsjjLgUPipnmyC1k2tcChJjFcTy9tiFNXBm3Uc0fI+MJPRYPo0A7D95 rZMYdj/dyNwFed4SAE6w90fM0LATvjDGFHkF37b54FRe/VL5Xqbzf4kItVDYzRShi6ov NKuFlXn6aauaO3CkWQ8pg+cN23GhHa0EF2Ulx7i5bEE+bKmDQH0D7ASL1BLZy6CVvsfJ 9k6DlebR8Axm1cAR7b2WJIfvrjyPG/BE/NdT5pHaeOwy1034W92KbBjU//1B+Y/T1Fop GY7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=msoz1rnOVh2WMau59z7olsj6Ukbfg2Ncih6e1/abmCo=; b=i4d/d0byqk591pUqarTmMCe3dyow8m0Jq0jBQP4yS9WCUlRDckzNUAxaRnkul3BfPt 4HHxRFQE32lBFPGEE+lX/Qu7IZt+9PJTHitgxKsaKuBZUjU9+wEu0PcEMl/5yEHjrsVy JRc0pu5Vvw6zSBnYbOo1THzAYdJZ9pNSfiYOt/Q3A8Qgs8lHl9w1zjGFHmExr3VW8IoQ Za5LSlelhtR2Ulq1g2b02hjba0XdwmwPg5c101r0ULaXYHpqJQshp+GWM2/K3jMnV2fc 81MtiBgo+g+6nISMFnZLmXAWBFi46vVwVjmYjG0pdnXbuQ95cQWd3gub+ZJ+z2Fm5dg+ IZvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=R82pN/RC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si1006523pgf.499.2018.04.11.10.08.41; Wed, 11 Apr 2018 10:09:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=R82pN/RC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753764AbeDKRBB (ORCPT + 99 others); Wed, 11 Apr 2018 13:01:01 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:55338 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753599AbeDKRA7 (ORCPT ); Wed, 11 Apr 2018 13:00:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=msoz1rnOVh2WMau59z7olsj6Ukbfg2Ncih6e1/abmCo=; b=R82pN/RCW53MNVaOwZerTFkJz I7oP15aT6AtHR5daSfCN/+Z29rDGR+ix0pF4bKTMB6abGvMdg8VnPO7vo9moGkgmyhR6kM0wYzYqY bxj62gczLDbUGnz9HmWBHlhSg+L+rU10wajofl5s/JYW8uwv25YuU0Ny2EGmVmx5KAgBegwxNyf+o mbpl/YlQ4HfsoqsEDscsSaSIfy9k84ZfJsBRpU8BKiGNT1QQycqhbx0Xy5TnI/eP4+m8+/kblEGRO 6qr4FlA6KXD/NVpZyIhTUfVNMhFBjKrjz17rQgWmUYJXEggDLV5JQuROI0rtS1iZV+sixZ84DiLlL Zr2EaK+/g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f6J74-00055z-Ob; Wed, 11 Apr 2018 17:00:50 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 428A7202A29FD; Wed, 11 Apr 2018 19:00:49 +0200 (CEST) Date: Wed, 11 Apr 2018 19:00:49 +0200 From: Peter Zijlstra To: Andrew Morton Cc: Joe Perches , "Rafael J. Wysocki" , Andy Whitcroft , yuankuiz@codeaurora.org, Linux PM , "Rafael J. Wysocki" , Frederic Weisbecker , Thomas Gleixner , paulmck@linux.vnet.ibm.com, Ingo Molnar , Len Brown , Linux Kernel Mailing List Subject: Re: [PATCH] checkpatch: Add a --strict test for structs with bool member definitions Message-ID: <20180411170049.GR4082@hirez.programming.kicks-ass.net> References: <891d4f632fbff5052e11f2d0b6fac35d@codeaurora.org> <20180410123305.GF4082@hirez.programming.kicks-ass.net> <95477c93db187bab6da8a8ba7c57836868446179.camel@perches.com> <20180410143950.4b8526073b4e3e34689f68cb@linux-foundation.org> <20180410150011.df9e036f57b5bcac7ac19686@linux-foundation.org> <20180411081502.GJ4082@hirez.programming.kicks-ass.net> <20180411092959.e666ec443e4d3bb6f43901d7@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180411092959.e666ec443e4d3bb6f43901d7@linux-foundation.org> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 11, 2018 at 09:29:59AM -0700, Andrew Morton wrote: > > OK. I guess. But I'm not really seeing some snappy description which > helps people understand why checkpatch is warning about this. "Results in architecture dependent layout." is the best short sentence I can come up with. > We already have some 500 bools-in-structs and the owners of that code > will be wondering whether they should change them, and whether they > should apply those remove-bool-in-struct patches which someone sent > them. I still have room in my /dev/null mailbox for pure checkpatch patches. > (ooh, https://lkml.org/lkml/2017/11/21/384 is working this morning) Yes, we really should not use lkml.org for references. Sadly google displays it very prominently when you search for something. > hm, Linus suggests that instead of using > > bool mybool; > > we should use > > unsigned mybool:1; > > However that introduces the risk that alterations of mybool will use > nonatomic rmw operations. > > unsigned myboolA:1; > unsigned myboolB:1; > > so > > foo->myboolA = 1; > > could scribble on concurrent alterations of foo->myboolB. I think. So that is true of u8 on Alpha I guess that risk is also present if myboolA and myboolB were `bool', > too. The compiler could do any old thing with them including, perhaps, > using a single-bit bitfield(?). The smallest addressable type in C is a byte, so while _Bool may be larger than a byte, it cannot be smaller. Otherwise we could not write: _Bool var; _Boll *ptr = &var; Which is something that comes apart with bitfields.