Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4912140pxb; Tue, 5 Oct 2021 13:09:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/HEGf9x6KSGqIUOIdaqyVZ5kf3tAAVt2JxWKu0BaLhtMRSOYz6/dwKUenjbpEhtTTNDmq X-Received: by 2002:aa7:c619:: with SMTP id h25mr8121583edq.260.1633464552447; Tue, 05 Oct 2021 13:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633464552; cv=none; d=google.com; s=arc-20160816; b=q3Rs3+P00wEc8mPFac0zVaEZlnUaI4gl/Y31u/3VT7uQv+9lodqqYbrI/dk9bI0Wkr eEZKNtT2Q/sA5b2u9L4GfMywH6MKu8HuaMNGfnXBbi+TZZdplNURsZusTt7oV4WdoecW uEoxtoJzxusHOlA9zBE12zyv1Dlpq7Iq5WVSdOTvOyuXnc47pYgjtqmvajsvQAnusv1j bslDKzVF7DjDzrKn/U392USaRrs5wDrtKHmdm2iFmZqyI8xMjKNyeBFs6KobvO9Sud/3 kjONGnd/NoDFxx9PKnb0+eOM5fMjsGiW1Bit9I0ejvkuJpaRZoC/YnVzp7Qlf0QCP/+i 5i8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=3+fWCmAwERSGZjdWS5vJfRbpoyjjdlKrkRfMHKxEUvY=; b=uLqwmN03RjG8M9hL8o+yiumQ6iJTeoMNaeBbOd5rZQ7DQjaCh5OTM2e1mWYxqg15Le QbTE8LZORrOXYleB+jtp2oRjMqrngpoPttNGxkKdEKKrf3MelZgeS+JNLKQEpIM/UNX+ x8kd1kpNIjF2SQJaLupsl6rPLaSZk0wV3H+q1K8RdFRTxuOu+z5iZ7MwJZzzROknf1yy Xm+fRkcpjtI3uYtQRA8K8LmJJMkvKf2cB5n+tuKW5AUe2ZYu66C5aDynYMcv0cK1TAaN aGeTWSFOJaXPmDGYhh+MFxssmDi8+5hrcLnT3K3lvHhnzGReiCxB3KJU7Z1dJCMEgvpY ae6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si25823097ejz.195.2021.10.05.13.08.43; Tue, 05 Oct 2021 13:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235163AbhJEUIv convert rfc822-to-8bit (ORCPT + 99 others); Tue, 5 Oct 2021 16:08:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:46506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbhJEUIu (ORCPT ); Tue, 5 Oct 2021 16:08:50 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30FDB610CE; Tue, 5 Oct 2021 20:06:58 +0000 (UTC) Date: Tue, 5 Oct 2021 16:06:56 -0400 From: Steven Rostedt To: Mathieu Desnoyers Cc: Jan Engelhardt , Rasmus Villemoes , linux-kernel , Linus Torvalds , Paul , Josh Triplett , Lai Jiangshan , "Joel Fernandes, Google" , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , rcu , netfilter-devel , coreteam , netdev Subject: Re: [RFC][PATCH] rcu: Use typeof(p) instead of typeof(*p) * Message-ID: <20211005160656.29e8bf38@gandalf.local.home> In-Reply-To: <1403497170.3059.1633463398562.JavaMail.zimbra@efficios.com> References: <20211005094728.203ecef2@gandalf.local.home> <639278914.2878.1633457192964.JavaMail.zimbra@efficios.com> <826o327o-3r46-3oop-r430-8qr0ssp537o3@vanv.qr> <20211005144002.34008ea0@gandalf.local.home> <20211005154029.46f9c596@gandalf.local.home> <1403497170.3059.1633463398562.JavaMail.zimbra@efficios.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 5 Oct 2021 15:49:58 -0400 (EDT) Mathieu Desnoyers wrote: > ----- On Oct 5, 2021, at 3:40 PM, rostedt rostedt@goodmis.org wrote: > > > On Tue, 5 Oct 2021 21:06:36 +0200 (CEST) > > Jan Engelhardt wrote: > > > >> On Tuesday 2021-10-05 20:40, Steven Rostedt wrote: > >> >> > >> >> >>>> typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); > >> >> > >> >> #define static_cast(type, expr) ((struct { type x; }){(expr)}.x) > >> >> typeof(p) p1 = (typeof(p) __force)static_cast(void *, READ_ONCE(p)); > >> >> > >> >> Let the name not fool you; it's absolutely _not_ the same as C++'s > >> >> static_cast, but still: it does emit a warning when you do pass an > >> >> integer, which is better than no warning at all in that case. > >> >> > >> >> *flies away* > >> > > >> >Are you suggesting I should continue this exercise ;-) > >> > >> “After all, why not?” > >> > >> typeof(p) p1 = (typeof(p) __force)READ_ONCE(p) + > >> BUILD_BUG_ON_EXPR(__builtin_classify_type(p) != 5); > > > > I may try it, because exposing the structure I want to hide, is pulling out > > a lot of other crap with it :-p > > I like the static_cast() approach above. It is neat way to validate that the > argument is a pointer without need to dereference the pointer. > > I would also be open to consider this trick for liburcu's userspace API. > > About the other proposed solution based on __builtin_classify_type, I am > reluctant to use something designed specifically for varargs in a context > where they are not used. > Unfortunately, it doesn't solve the Debian gcc 10 compiler failing when passing the function name instead of a pointer to the function in RCU_INIT_POINTER() That alone makes me feel like I shouldn't touch that macro :-( And who knows what other version of gcc will fail on passing the address :-p -- Steve