Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1570630ybm; Thu, 23 May 2019 03:21:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYpCG+/29JtnAdWa/OKKoCvc95abFq73gJPQOJvc4ovXL0I6I+Aqqs0zwSqxRtjNaOnx5V X-Received: by 2002:a17:90a:b388:: with SMTP id e8mr421152pjr.97.1558606880583; Thu, 23 May 2019 03:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558606880; cv=none; d=google.com; s=arc-20160816; b=iLFwCv/snRkQ5/5pkWz5XQxDpypHfuUZ5qum/uAm+Lpo2o/JmHRSvAnKL/sp55Waz+ 50jSJu3eGBk7l3417HH/8gTWgS0iLiIXlFGaBqLsZXkEQo3XY7vOFxoWT1KchVdbJTnc u70UAqnjIi1hiIR+vTtH9cE3MZWm/DEVy2WEncvE1cPlyUELUcKnl+nEnoakp05g7KUJ YPQWRkmQcWj0Hwh0z4xDe5kKz6pElDjmouW1TS4j40yUOI9tu+4WLnBsz93iQ13Kw3Dk 5jcwlVQc/+NvylZhFwUCkpCN/qrj42ecp6Kh6xhyw4EzpGYsu3BnqgT4c/8VurliFfwE y2/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zbqsb1pflTvhHP17nXye/8SpKiAgT0gP/hf3mPfnBqE=; b=FFyBNdRM4JfJfddvw3K63laMO3hnppr3I7wX0lrrx4oaah/es9v/OSvLRD1BEI9n8R aw063LLZ4JvZepgYtvMcZugeqyb5OC2hlTxoT37n9pXhwu9zmMPtB+gXP2L46AQ2eCi5 s8/JlXYpF4JfTRndqjkdNLsvw/pQc3sJnjilT81gLR/8Wc2QDPYJTG4fuXqTVwU4ZVjv Q85PKFGIvYCSQD1LDABQ6Nw40Cz7ajDnxAWuvaUuJACVAgwbqzc4AXWBte5E9F7HCyfl 9YnGSWe0RhVVfr35YZVTw1/EbwBi4JpiWsfZ/op2NARf5TnLiyZBgrp6hSjU1V3WqgKe 0Uaw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h15si30179342pfn.96.2019.05.23.03.21.05; Thu, 23 May 2019 03:21:20 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730284AbfEWKTh (ORCPT + 99 others); Thu, 23 May 2019 06:19:37 -0400 Received: from foss.arm.com ([217.140.101.70]:42386 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726846AbfEWKTh (ORCPT ); Thu, 23 May 2019 06:19:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9DEBF341; Thu, 23 May 2019 03:19:36 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5C8823F718; Thu, 23 May 2019 03:19:32 -0700 (PDT) Date: Thu, 23 May 2019 11:19:26 +0100 From: Mark Rutland To: Andrea Parri Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, will.deacon@arm.com, aou@eecs.berkeley.edu, arnd@arndb.de, bp@alien8.de, catalin.marinas@arm.com, davem@davemloft.net, fenghua.yu@intel.com, heiko.carstens@de.ibm.com, herbert@gondor.apana.org.au, ink@jurassic.park.msu.ru, jhogan@kernel.org, linux@armlinux.org.uk, mattst88@gmail.com, mingo@kernel.org, mpe@ellerman.id.au, palmer@sifive.com, paul.burton@mips.com, paulus@samba.org, ralf@linux-mips.org, rth@twiddle.net, stable@vger.kernel.org, tglx@linutronix.de, tony.luck@intel.com, vgupta@synopsys.com Subject: Re: [PATCH 00/18] locking/atomic: atomic64 type cleanup Message-ID: <20190523101926.GA3370@lakrids.cambridge.arm.com> References: <20190522132250.26499-1-mark.rutland@arm.com> <20190523083013.GA4616@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190523083013.GA4616@andrea> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 23, 2019 at 10:30:13AM +0200, Andrea Parri wrote: > Hi Mark, Hi Andrea, > On Wed, May 22, 2019 at 02:22:32PM +0100, Mark Rutland wrote: > > Currently architectures return inconsistent types for atomic64 ops. Some return > > long (e..g. powerpc), some return long long (e.g. arc), and some return s64 > > (e.g. x86). > > (only partially related, but probably worth asking:) > > While reading the series, I realized that the following expression: > > atomic64_t v; > ... > typeof(v.counter) my_val = atomic64_set(&v, VAL); > > is a valid expression on some architectures (in part., on architectures > which #define atomic64_set() to WRITE_ONCE()) but is invalid on others. > (This is due to the fact that WRITE_ONCE() can be used as an rvalue in > the above assignment; TBH, I ignore the reasons for having such rvalue?) > > IIUC, similar considerations hold for atomic_set(). > > The question is whether this is a known/"expected" inconsistency in the > implementation of atomic64_set() or if this would also need to be fixed > /addressed (say in a different patchset)? In either case, I don't think the intent is that they should be used that way, and from a quick scan, I can only fine a single relevant instance today: [mark@lakrids:~/src/linux]% git grep '\(return\|=\)\s\+atomic\(64\)\?_set' include/linux/vmw_vmci_defs.h: return atomic_set((atomic_t *)var, (u32)new_val); include/linux/vmw_vmci_defs.h: return atomic64_set(var, new_val); [mark@lakrids:~/src/linux]% git grep '=\s+atomic_set' | wc -l 0 [mark@lakrids:~/src/linux]% git grep '=\s+atomic64_set' | wc -l 0 Any architectures implementing arch_atomic_* will have both of these functions returning void. Currently that's x86 and arm64, but (time permitting) I intend to migrate other architectures, so I guess we'll have to fix the above up as required. I think it's best to avoid the construct above. Thanks, Mark.