Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4893290pxb; Tue, 5 Oct 2021 12:41:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJya9xORrraRq4GXqTNm7yrU9Hu6jnLe2187t0zp4i3ee19xgRHnht5FV0LARVDMliH+YMXi X-Received: by 2002:a17:90a:9903:: with SMTP id b3mr5899178pjp.52.1633462896285; Tue, 05 Oct 2021 12:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633462896; cv=none; d=google.com; s=arc-20160816; b=xJyEiEKSIbrBHjNgrXCqeCM4dURYbrkmzAXMOOe3FmgFr4ZSsm/FEkHPJibJPmhtoy SOMHU5ySqRrhPS3o2DwDHN8Bsl5hQzqJBT+bg43z7wriVurh0syb/rrkesRPBt9CD+ux Lz1Q0tEFTBffCcadl0tQ51vzEmgsSgv/BnPcQPBgnu1y1kqXU/YzG4w2BsDDCq5fpDYk uyZiawxPbnkYEAQgWOs9Ym8NDXiVWYJPmkg9mxx8DKq+Z98WCvM3HjvpYY5yxMh7cSZa Tc7SB0z7gXyRsRJIde4TqRjNgAICFjChTLAwqZpAUYMoG5wyoMaNWwvRQTps0mf1G2wj T7hw== 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=K6RLpLProOzM1JPc0fSwyN7TcJG5AVU4US2pK5f5KTA=; b=0C5um0Lh0rMTIs0ePpnfq7wTnFbSU+Y1b3rCJf421m6bGuNcXpLWGalFneyMelO8Yh NtLmEroN6WpbIfV5rqf/Vd8p9nRYwIdRkOqkkj10Ueopt2RVMshDaTpejeFGhRJ0tKVg bw6PipEsWwjbU5XHs1UH+WExZcHDpnGzDT6P5dUdvDNkzMddcbfF5nTmv4bQaxZ3RKhb uVvSfqKFWT62VdHoOmbWqay3hfcBp3R9VPI2ZqOc8aWAUrkXotbkJ2vnwg6FQIbkadMk KcAi5uC7gIsfuYqkRjFPdSAsR652AIFG2HCdDSvFslYoJOmTpmnAmCbKJKkh1lYvUWIf /NHQ== 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 m9si4994553pfe.126.2021.10.05.12.41.20; Tue, 05 Oct 2021 12:41:36 -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 S235277AbhJETmY convert rfc822-to-8bit (ORCPT + 99 others); Tue, 5 Oct 2021 15:42:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:41750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbhJETmX (ORCPT ); Tue, 5 Oct 2021 15:42:23 -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 9FA61611C5; Tue, 5 Oct 2021 19:40:30 +0000 (UTC) Date: Tue, 5 Oct 2021 15:40:29 -0400 From: Steven Rostedt To: Jan Engelhardt Cc: Mathieu Desnoyers , 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: <20211005154029.46f9c596@gandalf.local.home> In-Reply-To: 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> 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 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 struct trace_pid_list { raw_spinlock_t lock; struct irq_work refill_irqwork; union upper_chunk *upper[UPPER1_SIZE]; // 1 or 2K in size union upper_chunk *upper_list; union lower_chunk *lower_list; int free_upper_chunks; int free_lower_chunks; }; I can still abstract out the unions, but this means I need to also pull out the define of "UPPER1_SIZE". Not to mention, I need to make sure irq_work and spin locks are defined. Another approach is to have it return: struct trace_pid_list { unsigned long ignore; }; Rename the above struct trace_pid_list to struct trace_pid_internal. And internally have: union trace_pid_data { struct trace_pid_list external; struct trace_pid_internal internal; }; Then use the internal version within the C file that modifies it, and just return a pointer to the external part. That should follow the "C standard". -- Steve