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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable 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 1FC52C32789 for ; Fri, 2 Nov 2018 13:41:40 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7FD60204FD for ; Fri, 2 Nov 2018 13:41:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FD60204FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42mjsY6N7vzF37k for ; Sat, 3 Nov 2018 00:41:37 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=paulmck@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42mjpK1cwTzF37v for ; Sat, 3 Nov 2018 00:38:49 +1100 (AEDT) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wA2DXoW1041925 for ; Fri, 2 Nov 2018 09:38:47 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ngqg48epx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Nov 2018 09:38:46 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Nov 2018 13:38:45 -0000 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 2 Nov 2018 13:38:39 -0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wA2DccdS29818906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 13:38:38 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 124E8B2065; Fri, 2 Nov 2018 13:38:38 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C510CB2064; Fri, 2 Nov 2018 13:38:37 +0000 (GMT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.148.108]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 2 Nov 2018 13:38:37 +0000 (GMT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id EFEA516C36E4; Fri, 2 Nov 2018 06:38:37 -0700 (PDT) Date: Fri, 2 Nov 2018 06:38:37 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Subject: Re: [RFC PATCH] lib: Introduce generic __cmpxchg_u64() and use it where needed References: <20181031220253.GA15505@roeck-us.net> <20181031233235.qbedw3pinxcuk7me@pburton-laptop> <4e2438a23d2edf03368950a72ec058d1d299c32e.camel@hammerspace.com> <20181101131846.biyilr2msonljmij@lakrids.cambridge.arm.com> <20181101145926.GE3178@hirez.programming.kicks-ass.net> <20181101163212.GF3159@hirez.programming.kicks-ass.net> <20181101170146.GQ4170@linux.ibm.com> <7d1ecd21c4c249138dfdd42b9aaa1cea@AcuMS.aculab.com> <20181102122328.GM3178@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181102122328.GM3178@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18110213-0040-0000-0000-0000048B794D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009971; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000268; SDB=6.01111590; UDB=6.00576070; IPR=6.00891681; MB=3.00024005; MTD=3.00000008; XFM=3.00000015; UTC=2018-11-02 13:38:45 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18110213-0041-0000-0000-000008947A89 Message-Id: <20181102133837.GS4170@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-02_09:, , 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=407 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811020124 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: paulmck@linux.ibm.com Cc: "mark.rutland@arm.com" , "linux-mips@linux-mips.org" , "jhogan@kernel.org" , "will.deacon@arm.com" , "bfields@fieldses.org" , "paulus@samba.org" , Trond Myklebust , "aryabinin@virtuozzo.com" , "linux@roeck-us.net" , "arnd@arndb.de" , "boqun.feng@gmail.com" , "dvyukov@google.com" , "linux-nfs@vger.kernel.org" , "netdev@vger.kernel.org" , "jlayton@kernel.org" , "linux-kernel@vger.kernel.org" , "ralf@linux-mips.org" , "anna.schumaker@netapp.com" , "paul.burton@mips.com" , David Laight , "akpm@linux-foundation.org" , "linuxppc-dev@lists.ozlabs.org" , "davem@davemloft.net" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Nov 02, 2018 at 01:23:28PM +0100, Peter Zijlstra wrote: > On Fri, Nov 02, 2018 at 10:56:31AM +0000, David Laight wrote: > > From: Paul E. McKenney > > > Sent: 01 November 2018 17:02 > > ... > > > And there is a push to define C++ signed arithmetic as 2s complement, > > > but there are still 1s complement systems with C compilers. Just not > > > C++ compilers. Legacy... > > > > Hmmm... I've used C compilers for DSPs where signed integer arithmetic > > used the 'data registers' and would saturate, unsigned used the 'address > > registers' and wrapped. > > That was deliberate because it is much better to clip analogue values. > > Seems a dodgy heuristic if you ask me. > > > Then there was the annoying cobol run time that didn't update the > > result variable if the result wouldn't fit. > > Took a while to notice that the sum of a list of values was even wrong! > > That would be perfectly valid for C - if unexpected. > > That's just insane ;-) > > > > > But for us using -fno-strict-overflow which actually defines signed > > > > overflow > > > > I wonder how much real code 'strict-overflow' gets rid of? > > IIRC gcc silently turns loops like: > > int i; for (i = 1; i != 0; i *= 2) ... > > into infinite ones. > > Which is never what is required. > > Nobody said C was a 'safe' language. But less UB makes a better language > IMO. Ideally we'd get all UBs filled in -- but I realise C has a few > very 'interesting' ones that might be hard to get rid of. There has been an effort to reduce UB, but not sure how far they got. Thanx, Paul