From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77391C2BCA1 for ; Fri, 7 Jun 2019 15:32:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5785320684 for ; Fri, 7 Jun 2019 15:32:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729955AbfFGPcs (ORCPT ); Fri, 7 Jun 2019 11:32:48 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:44212 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728797AbfFGPcr (ORCPT ); Fri, 7 Jun 2019 11:32:47 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1hZGr6-0000Wb-T4; Fri, 07 Jun 2019 23:32:36 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1hZGqw-0007N0-7k; Fri, 07 Jun 2019 23:32:26 +0800 Date: Fri, 7 Jun 2019 23:32:26 +0800 From: Herbert Xu To: Eric Dumazet Cc: Linus Torvalds , Alan Stern , "Paul E. McKenney" , Boqun Feng , Frederic Weisbecker , Fengguang Wu , LKP , LKML , Netdev , "David S. Miller" , Andrea Parri , Luc Maranget , Jade Alglave Subject: Re: inet: frags: Turn fqdir->dead into an int for old Alphas Message-ID: <20190607153226.gzt4yeq5c5i6bpqd@gondor.apana.org.au> References: <20190603200301.GM28207@linux.ibm.com> <20190607140949.tzwyprrhmqdx33iu@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 07, 2019 at 08:26:12AM -0700, Eric Dumazet wrote: > > There is common knowledge among us programmers that bit fields > (or bool) sharing a common 'word' need to be protected > with a common lock. > > Converting all bit fields to plain int/long would be quite a waste of memory. > > In this case, fqdir_exit() is called right before the whole > struct fqdir is dismantled, and the only cpu that could possibly > change the thing is ourself, and we are going to start an RCU grace period. > > Note that first cache line in 'struct fqdir' is read-only. > Only ->dead field is flipped to one at exit time. > > Your patch would send a strong signal to programmers to not even try using > bit fields. > > Do we really want that ? If this were a bitfield then I'd think it would be safer because anybody adding a new bitfield is unlikely to try modifying both fields without locking or atomic ops. However, because this is a boolean, I can certainly see someone else coming along and adding another bool right next to it and expecting writes them to still be atomic. As it stands, my patch has zero impact on memory usage because it's simply using existing padding. Should this become an issue in future, we can always revisit this and use a more appropriate method of addressing it. But the point is to alert future developers that this field is not an ordinary boolean. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5302626870346092059==" MIME-Version: 1.0 From: Herbert Xu To: lkp@lists.01.org Subject: Re: inet: frags: Turn fqdir->dead into an int for old Alphas Date: Fri, 07 Jun 2019 23:32:26 +0800 Message-ID: <20190607153226.gzt4yeq5c5i6bpqd@gondor.apana.org.au> In-Reply-To: List-Id: --===============5302626870346092059== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On Fri, Jun 07, 2019 at 08:26:12AM -0700, Eric Dumazet wrote: > > There is common knowledge among us programmers that bit fields > (or bool) sharing a common 'word' need to be protected > with a common lock. > = > Converting all bit fields to plain int/long would be quite a waste of mem= ory. > = > In this case, fqdir_exit() is called right before the whole > struct fqdir is dismantled, and the only cpu that could possibly > change the thing is ourself, and we are going to start an RCU grace perio= d. > = > Note that first cache line in 'struct fqdir' is read-only. > Only ->dead field is flipped to one at exit time. > = > Your patch would send a strong signal to programmers to not even try using > bit fields. > = > Do we really want that ? If this were a bitfield then I'd think it would be safer because anybody adding a new bitfield is unlikely to try modifying both fields without locking or atomic ops. However, because this is a boolean, I can certainly see someone else coming along and adding another bool right next to it and expecting writes them to still be atomic. As it stands, my patch has zero impact on memory usage because it's simply using existing padding. Should this become an issue in future, we can always revisit this and use a more appropriate method of addressing it. But the point is to alert future developers that this field is not an ordinary boolean. Cheers, -- = Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt --===============5302626870346092059==--