Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp363302ybi; Fri, 7 Jun 2019 09:15:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwbfJjR8yabeKsifbmAwn75LChIZU7lD6ZPse+0PsTB1eABysH7eyx2MOPQzZ2PvbtfxQc X-Received: by 2002:a17:90a:cd03:: with SMTP id d3mr6103542pju.127.1559924142904; Fri, 07 Jun 2019 09:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559924142; cv=none; d=google.com; s=arc-20160816; b=c7k+nIw24Qe6QfHt2OCfnYUKQ4fekj6ns1ehvUx0ct0tF0+1zs0dr9muvm0q8XR53H E2DwUdNkXJLnWXMnmmAGF4Q8PqJ7s2yKmY2uiNWsO65c4svoF3lQJBOWdHutZUcp2NMV KPcTeWF1zvqeDwDA8MYv+diFd37+v0pwxoluZQ/aDL1SQRNhRZ5r+EIlIoIF01jZCZqM 0vaCNyEx8AcE3rJ3ux0Pzt40zhRSjy+g+SL5PMuRh++cIFEVhrkq9y/DrI0OdYYfv/N7 LcVHA9ICnH2xi9pgpdpMkYK4WwKoCAmhRkRSUsctXQMMQaCqdJQwn/gDZcnGI4POoPGz 7BGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=+v/nyTrfUwKDiO60H6P7yrcb/AvGQ5TkB/DzgjrK9rk=; b=wOxLmWz3krKxQPIZ2jDpkd4A8MSy3oGgXAtRz7d1gp6e/gbWrbyxAb2hZiLUp4teBm kh+Wk33/OohNx3+IQhYnlVUL9v2+o3R0z6U4oHhcdvwwZDFIuI+fr+gWKjt9DZRogkCF MI1MpPSTZhTlQ9SBu0VL5yfEvJy0VQ2D0TjITK+OLLJ5LRDc1sL4/eJwMTgwg/wS4/5V cp9zg74RI9hyHX7EqSecmIFnMPXrflLPMJPtb6TBQttQIGTnzwZP+j+48DakAaYcG9Dq t5F61sqMmQZPWy1j6Eylg2sOnLiUPMuo7/aQcyzRZtgzDNLDfmGBtNINiIZQG2BzCPr6 ogVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ikYMHwpe; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21si310750pgk.414.2019.06.07.09.15.24; Fri, 07 Jun 2019 09:15:42 -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=pass header.i=@gmail.com header.s=20161025 header.b=ikYMHwpe; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730250AbfFGQNM (ORCPT + 99 others); Fri, 7 Jun 2019 12:13:12 -0400 Received: from mail-pg1-f169.google.com ([209.85.215.169]:37757 "EHLO mail-pg1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729127AbfFGQNM (ORCPT ); Fri, 7 Jun 2019 12:13:12 -0400 Received: by mail-pg1-f169.google.com with SMTP id 20so1415563pgr.4; Fri, 07 Jun 2019 09:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=+v/nyTrfUwKDiO60H6P7yrcb/AvGQ5TkB/DzgjrK9rk=; b=ikYMHwpeMcyQt1k0NxYmY6v+CxikGuE+R1vUmmNbxcRy3tpwp60Z+t9SRyrc1oVY2u rxSp/s9anWeYnx/yIErCPueV3dJWuJobVtQfce9FguRrJpvFCT4Eah90Yh2W4oGQVRgR +07qXwLfYSuod0nvYdcEKD/rKD6VgcDXdKkypIarOLjimDkycc2HrP3JXOCnAZKt9zi4 8k8siRg0CQ2d8IQJ2supqLtUyhqXMSWDxF7OdIbEptL2xlsjrVXgLcR4/kEUQ/knTRGn WnF3AM0NdMDkRtcM8m/r6bXXN7vPTCsZZZh7h97Hq9xmjqfTbR7fLDFKYAEzz2I6Q/8j loUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=+v/nyTrfUwKDiO60H6P7yrcb/AvGQ5TkB/DzgjrK9rk=; b=QCMJAUU+6fgL3hMMKPkYTCVMK1hi5VYsNXu6xm/HtmlYCXO0DHvGu5GEcGXrqlx0+U aYjtHoztqYHCFR36R/s8TQJIRS8xnwXfHtb+8+uq99EbbmcDeSIGIiICcx8TVrjxroRD kdBm8vwBugNCLvK/rwM/Q6SZXbyPfwMVtOSO+fFBfdvKdhhk9Dl+p3J6NP0bJz3QNmeb Ar8e5tek99WSNXrFTrl8kkYW6WM1Dl11MIFVWu0zXarMf4nx60CRvxN2fu++eNV0MphL TbrHh+JC+RPeLaICX1nXAexMnQyLjCU+FhnxTESm4TUPXWAzz47qmYsRD7dAgGHepKab c9Kw== X-Gm-Message-State: APjAAAWU/TIj7eCW41xhm2xbExslwKyi2+7D9WvaBbD+e3wp5dW1JojH l4Z5JnTCtiXHdJasPYXymS8= X-Received: by 2002:a63:e603:: with SMTP id g3mr3628545pgh.167.1559923991556; Fri, 07 Jun 2019 09:13:11 -0700 (PDT) Received: from ?IPv6:2620:15c:2c1:200:55c7:81e6:c7d8:94b? ([2620:15c:2c1:200:55c7:81e6:c7d8:94b]) by smtp.gmail.com with ESMTPSA id e5sm7214119pjj.2.2019.06.07.09.13.10 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jun 2019 09:13:10 -0700 (PDT) Subject: Re: inet: frags: Turn fqdir->dead into an int for old Alphas To: Herbert Xu , 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 References: <20190603200301.GM28207@linux.ibm.com> <20190607140949.tzwyprrhmqdx33iu@gondor.apana.org.au> <20190607153226.gzt4yeq5c5i6bpqd@gondor.apana.org.au> From: Eric Dumazet Message-ID: Date: Fri, 7 Jun 2019 09:13:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190607153226.gzt4yeq5c5i6bpqd@gondor.apana.org.au> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/7/19 8:32 AM, Herbert Xu wrote: > 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. Okay, but you added a quite redundant comment. /* We can't use boolean because this needs atomic writes. */ Should we add a similar comment in front of all bit-fields, or could we factorize this in a proper Documentation perhaps ? Can we just add a proper bit-field and not the comment ? unsigned int dead:1; This way, next programmer can just apply normal rules to add a new bit. Thanks !