Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1505927ybi; Sat, 8 Jun 2019 11:16:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqymfCSTLsbBO+8W/QQ6F1gfITnmIN8lPR1ld1j5Qx53tgK6zWxT/7MeRShiR8qiLdoYmIyu X-Received: by 2002:aa7:8e19:: with SMTP id c25mr30461283pfr.238.1560017764208; Sat, 08 Jun 2019 11:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560017764; cv=none; d=google.com; s=arc-20160816; b=SSejEiiNSCb3IqAt2hde3PIr9ixCFeLf7nHh+7zllmiPWPaXr9ziZ2PMtk9zOjvt14 t/RXpOst10NRqsgN6P44ydHOQCNoL+uSkY2tuHXh2PdPxpxbpVwxyTodAcz5uOh4/aHN LrxzAEFu4adzjdyE1Tqob4RweDmMDHprbpQmnrgjKvJePek0hoCA4n+ScJlK8Ef3lQtN sPW7p2XNcI/vHQG1ggIUGMMizWt5WsLJtAw0xvqy66gK0ZR27L2+OJqPnEpRa8eHviY8 LpthwNEp1leaxDXMAefTQ0u+X4RXpBxv7aiuCB6LxB/cvMpa/TLZb3GN/11oomHMyc/L HY4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date; bh=d8/mLjo98p8BUHBwwKXG3F0o4BMMG3iQHc08DIwPTU4=; b=ygt0VfY4WS0J7mRS9WEEVnNPxHuGrgOjfLTjWMeVs+ya8+IGBTJGxiIkkznuClbZwr nhPZUS4eI0yQ3mTSqpvKKp0xs5HI1x5IPXfwCY41jN+tKYJkg5M5LuBAezyzg6eYBs4Y JSCb3wLDxUOdlWxQP09Xmdf91RJwASP4oiHcfJoH8+Ed2nyZpbovdf4Qz9s4zulEp0r4 ukadxAV0dGCLTHb431y+SEeld4drOONNUNfgR7XLGIj0ZUkeNd94F9gKkHkRbWZUroCr WSW9qWzKeT1IgJTh07vhlRcRqa5FOMZwupL5vMMlUDxBlvPRBsGmt5Ug6HzNWuxxJbED gQfw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si4974003pjo.7.2019.06.08.11.15.47; Sat, 08 Jun 2019 11:16:04 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727364AbfFHSOg (ORCPT + 99 others); Sat, 8 Jun 2019 14:14:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34762 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727220AbfFHSOg (ORCPT ); Sat, 8 Jun 2019 14:14:36 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x58I6jhZ039875 for ; Sat, 8 Jun 2019 14:14:35 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2t09j5dj45-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 08 Jun 2019 14:14:35 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 8 Jun 2019 19:14:34 +0100 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sat, 8 Jun 2019 19:14:30 +0100 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x58IETRY32768474 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 8 Jun 2019 18:14:29 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D0D8B2064; Sat, 8 Jun 2019 18:14:29 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B056B205F; Sat, 8 Jun 2019 18:14:29 +0000 (GMT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.156.65]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Sat, 8 Jun 2019 18:14:28 +0000 (GMT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 5544016C5D9A; Sat, 8 Jun 2019 11:14:31 -0700 (PDT) Date: Sat, 8 Jun 2019 11:14:31 -0700 From: "Paul E. McKenney" To: Linus Torvalds Cc: Eric Dumazet , Herbert Xu , Alan Stern , 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 Reply-To: paulmck@linux.ibm.com References: <20190603200301.GM28207@linux.ibm.com> <20190607140949.tzwyprrhmqdx33iu@gondor.apana.org.au> <20190608152707.GF28207@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 19060818-2213-0000-0000-0000039BFD59 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011234; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01215108; UDB=6.00638786; IPR=6.00996199; MB=3.00027236; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-08 18:14:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19060818-2214-0000-0000-00005EC64B6B Message-Id: <20190608181431.GL28207@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-08_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906080138 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 08, 2019 at 10:42:41AM -0700, Linus Torvalds wrote: > On Sat, Jun 8, 2019 at 8:32 AM Paul E. McKenney wrote: > > > > On Fri, Jun 07, 2019 at 09:19:42AM -0700, Linus Torvalds wrote: > > > > > > - bitfields obviously do need locks. 'char' does not. > > > > > > If there's somebody who really notices the alpha issue in PRACTICE, we > > > can then bother to fix it. But there is approximately one user, and > > > it's not a heavy-duty one. > > > > C11 and later compilers are supposed to use read-modify-write atomic > > operations in this sort of situation anyway because they are not supposed > > to introduce data races. Apologies, I should have explicitly stated that I was talking about char stores, not bitfield stores. And last I checked, the C11 standard's prohibition against data races did not extend to individual fields within a bitfield. So, yes, for bitfields, the programmer must use a lock or similar if it is necessary for updates to fields within a bitfield to be atomic. > I don't think that's possible on any common architecture. The > bitfields themselves will need locking, to serialize writes of > different fields against each other. Yes, and again the C standard doesn't make any atomicity guarantees regarding storing to different fields within a bitfield. The compiler is free to assume that nothing else is happening anywhere in the bitfield when storing to a field within that bitfield. Which gets back to your "bitfields obviously do need locks", and it is of course the developer (not the compiler) who must supply those locks. Plus a given lock must cover the entire bitfield -- having one lock for half the fields within a given bitfield and another lock for the other half will break. Switching from bitfields to char, the C standard -does- require that storing to one char must avoid even momentary corruption of adjacent char, so given an old Alpha the compiler would need to use something like an LL/SC loop. If it fails to do so, that compiler is failing to comply with the standard. > There are no atomic rmw sequences that have reasonable performance for > the bitfield updates themselves. Agreed, in the general case. In a few specific special cases, we do sometimes hand-craft bitfields using shifts and masks, and sometimes we use atomic RMW operations to update them. I suppose we could use unions as an alternative, but it is not clear to me that this would help anything. > The fields *around* the bitfields had better be safe, but that's > something we already depend on, and which falls under the heading of > "we don't accept garbage compilers". And the C standard does require the compiler to make that guarantee, so for once the standard is even on our side. ;-) Thanx, Paul