Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1828541ybm; Thu, 23 May 2019 07:21:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwX8hQYH/XgE6vEl4og9yQgG4GlrapJ6aLSBZ2nauxW1QStnQgMp9wHbso7CASteL2ACCzF X-Received: by 2002:a17:902:c85:: with SMTP id 5mr24563947plt.172.1558621288512; Thu, 23 May 2019 07:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558621288; cv=none; d=google.com; s=arc-20160816; b=XlLh0gIv17x9vhHKJLTkSagS6649rwJ1k+A3bz3OlH1qynBCqffvlK/iRumrTJtdzL mocPFFAb4FgQWRtTAiZ+J+9Kk4S9gFijTbeXpwmOvvpBWO+RD+vuCqbRut9GPqCOYyW3 EgtZZrUNC08Nf4yqJv4+UzGa8/6Riqh54uLcTEwVnY1PnQ6n0g2grk5jnMrDgM0NUM24 2Y2C9n1OmB1oG/WqKJufJmMUvyTcSm6G4/y5ARrt8kNn+p4AmixkZEPFKSH9XVyaIeTI UaPmCB9yCBmhXCCnuef2el/GfS2LBfCv1kPx+GZtiW2HGVKgYHypbvA07bY0sHqKhTxl F3fQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=HNTxK47POUUbug+H/NXhDBp7ZT5I+slxRxIM1qGdX/4=; b=U83FGWf9aaCXBOLLjCIxwEAZcuHRAhv+VYV5ivJuNZ+5xXFgiKOjR5K7R6FcM5+i+p FGmmqu5cCr/mvKwVZ5jsK4EfHVVmD1q2+zGESCH5bPrcU66/bZx4AHNIWaC2O8OMOaIg nsIni8pq86vlXDIreTv32zchlRHS+Xjl01ggoamztFzXyvoAh09h3deOZGJoLyP4bhLp pNDstALl8ZT/XemMVF9ajcP8yPMqBhfuBOx+U7/9kERTA2tCZr6F5zso3uPNa14D+cvB TphH/pJ4ajZi4SsS1rIRVn3sVoz/92IEJOzyFHwl3hgRwGicjMXUl6TB2RMRBTHNCf9/ beWg== 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 17si31032143pgt.554.2019.05.23.07.21.11; Thu, 23 May 2019 07:21:28 -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 S1730782AbfEWOT0 (ORCPT + 99 others); Thu, 23 May 2019 10:19:26 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47372 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730495AbfEWOT0 (ORCPT ); Thu, 23 May 2019 10:19:26 -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 90E3680D; Thu, 23 May 2019 07:19:25 -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 9FBFA3F690; Thu, 23 May 2019 07:19:23 -0700 (PDT) Date: Thu, 23 May 2019 15:19:19 +0100 From: Mark Rutland To: "Paul E. McKenney" Cc: Andrea Parri , linux-kernel@vger.kernel.org, Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , rcu@vger.kernel.org, Peter Zijlstra , Will Deacon Subject: Re: [RFC PATCH] rcu: Make 'rcu_assign_pointer(p, v)' of type 'typeof(p)' Message-ID: <20190523141851.GA7523@lakrids.cambridge.arm.com> References: <1558618340-17254-1-git-send-email-andrea.parri@amarulasolutions.com> <20190523135013.GL28207@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190523135013.GL28207@linux.ibm.com> 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 06:50:13AM -0700, Paul E. McKenney wrote: > On Thu, May 23, 2019 at 03:32:20PM +0200, Andrea Parri wrote: > > The expression > > > > rcu_assign_pointer(p, typeof(p) v) > > > > is reported to be of type 'typeof(p)' in the documentation (c.f., e.g., > > Documentation/RCU/whatisRCU.txt) but this is not the case: for example, > > the following snippet > > > > int **y; > > int *x; > > int *r0; > > > > ... > > > > r0 = rcu_assign_pointer(*y, x); > > > > can currently result in the compiler warning > > > > warning: assignment to ‘int *’ from ‘uintptr_t’ {aka ‘long unsigned int’} makes pointer from integer without a cast [-Wint-conversion] > > > > Cast the uintptr_t value to a typeof(p) value. > > > > Signed-off-by: Andrea Parri > > Cc: "Paul E. McKenney" > > Cc: Josh Triplett > > Cc: Steven Rostedt > > Cc: Mathieu Desnoyers > > Cc: Lai Jiangshan > > Cc: Joel Fernandes > > Cc: rcu@vger.kernel.org > > Cc: Peter Zijlstra > > Cc: Will Deacon > > Cc: Mark Rutland > > --- > > NOTE: > > > > TBH, I'm not sure this is 'the right patch' (hence the RFC...): in > > fact, I'm currently missing the motivations for allowing assignments > > such as the "r0 = ..." assignment above in generic code. (BTW, it's > > not currently possible to use such assignments in litmus tests...) > > Given that a quick (and perhaps error-prone) search of the uses of > rcu_assign_pointer() in v5.1 didn't find a single use of the return > value, let's please instead change the documentation and implementation > to eliminate the return value. FWIW, I completely agree, and for similar reasons I'd say we should do the same to WRITE_ONCE(), where this 'cool feature' has been inherited from. For WRITE_ONCE() there's at least one user that needs to be cleaned up first (relying on non-portable implementation detaisl of atomic*_set()), but I suspect rcu_assign_pointer() isn't used as much as a building block for low-level macros. Thanks, Mark.