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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 72D91C2BCA1 for ; Fri, 7 Jun 2019 16:13:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44E8B2146F for ; Fri, 7 Jun 2019 16:13:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ikYMHwpe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730259AbfFGQNM (ORCPT ); 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-Google-Smtp-Source: APXvYqzQJ4jN+znFbh4NisIXmXtjlcm9RNiNM2+fTJLWxplzZ9amcx9SPe20QkrjChZPygPGF60fdw== 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 !