From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.97 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796342429; b=DC/G0xEN07+Ps4Jcm7tj6bLmSMW/YtgjKATPnSUlmUDpbdVp1MrVOZ2uxWj8CNgsGv4g x+LlGwld9+kSxmGBj0WcY0WQ5PISX+ZvT5Ao7IbOWTJi5Beb41nxMW6HBLHP8YEbfz4P9 HloQo7hxJkCHQ01LQzd4uJyPKtMhA3vlS+WNYnpGEBVB+0ekD8AFSpro2Ay+423Z7s0X6 +7dWmzgyoSLagiqW5eg6EecEjuCBDdYnk/SSifbowtZy/XqEDIAIbECHeVpXEOdGBpMKJ 90dUx0SctkNw+q7ldaR3alp8uTLmoKEKdIMPCgSRbH37/sqW7Ek1k5l0C/4m4MeHBeQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796342429; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=SnyPI8s3LaSNPkDyB0P1kuElGDCWTOCTb23k5NKDVOI=; b=0seYvjHP9PvFIQVUkDxvklIUpdCFqK0D8dBF7MBb9vyGNFKWr6xhFYPFOSt6utpmuPiG FTnj9zTP6vAvXj0ZfvevipSrtStazpOVbo5crfHhark7k+0wejDqi69q82xu8F48r1fQ1 G9QeAH/NvHZno6ucagP2VqgFg2x3aaIRwjBa2uklOyEU7Bt4Fu3kPt5cc/RrIiTTu02Fu KTvovD1jIUuVsZcaiol5T+b6zzJhu3KVrCUcxPv0P2ct2030trOiAz6NxFyQrXAnKKLjE aeBGfeSyFp97igFfYNg2H2ixRtkA6qKFX4kF0ikkwsgeHnI9tDelmmbozEJz1PIgP3Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=RzqZstSM; arc=none smtp.remote-ip=95.215.58.97 Received: from mta1.migadu.com (out-97.mta1.migadu.com [95.215.58.97]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA8B8606A338 for ; Fri, 4 Dec 2026 00:00:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EA8B8606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=RzqZstSM X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=9NGnF5mMRmmI0InvEsdJDOmTwv8WRfqqUyZn0zh3FpA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796342425; v=1; x=1796947225; b=RzqZstSMEy2ptpJUPys+aoqyU63Bc4Z2/d+EM6KI6uNRI94Pd/Jykf596e1PwBa2DFGv2iDj 2qNgv8b+LS6h7Ie1XDiDQujsaHkEsGc4gYbgBWlP25jmHSbYD810dHNj83pv5a4Mk62NE6x+VBa AKCjdPegDMwIXq+TIOZNJhlU= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 15894db2aa4be1e2; Fri, 04 Dec 2026 00:00:22 +0000 X-Mizu-Trace-ID: 15894db2aa4be1e2 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Thu, 3 Dec 2026 17:00:17 -0700 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] percpu: do not put btf_type_tag on per-cpu variable declarations To: Alexei Starovoitov , Andrew Morton Cc: dennis@kernel.org, tj@kernel.org, cl@gentwo.org, chris@chrisdown.name, linux-mm@kvack.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, andrii@kernel.org, daniel@iogearbox.net, acme@kernel.org, yonghong.song@linux.dev, eddyz87@gmail.com, martin.lau@linux.dev, nathan@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com, llvm@lists.linux.dev References: <20261117220824.609017-1-vineet.gupta@linux.dev> <20261202110336.89af512bf2a336c18e11556c@linux-foundation.org> <71419c88-4411-4962-946e-d01968e44cfe@linux.dev> Content-Language: en-US From: Vineet Gupta In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/2/26 6:35 PM, Alexei Starovoitov wrote: > On Wed, Dec 02, 2026 at 12:04 PM Vineet Gupta wrote: >>> It's really GCC behavior. clang does fine as-is. >> Because clang ignores the construct GCC warns about. > For the variable, yes. > But clang keeps the tag in the type of &var. > this_cpu_ptr(&var) gives PTR -> TYPE_TAG 'percpu' -> T. > So this commit will remove 140 such valid tags? > Doesn't seem fair to clang. > I'm probably missing something. TL;DR: those tags are worthless: nothing can reach them. No variable, struct member or function parameter has that type, so no BTF record points at them. The verifier would not use them anyway. It finds a per-cpu variable through the .data..percpu DATASEC, not through a tag, and it reads the percpu tag only on attach function arguments and struct members. They come from typecasts: the accessor macros cast to the type of &var in __verify_pcpu_ptr():     const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; clang records the type of each explicit cast in DWARF (GCC does not), and pahole turns it into BTF with nothing pointing at it. A simplified example:     #define __tag __attribute__((btf_type_tag("percpu")))     struct S { int a; };     extern __tag __typeof__(struct S) v;    /* before: tag on the declaration */     extern __typeof__(struct S) w;        /* after: no tag */     int f(void)     {         return (__typeof__((&v) + 0))0 != 0;    /* cast only */     }     int g(void)     {         return (__typeof__((&w) + 0))0 != 0;     }     $ clang -g -O2 -c t.c -o t.o && pahole -J t.o && bpftool btf dump file t.o format raw     [1] TYPE_TAG 'percpu' type_id=3     [2] PTR '(anon)' type_id=1     [3] STRUCT 'S' size=4 vlen=1         'a' type_id=4 bits_offset=0     [4] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED     [5] PTR '(anon)' type_id=3     [6] FUNC_PROTO '(anon)' ret_type_id=4 vlen=0     [7] FUNC 'f' type_id=6 linkage=static     [8] FUNC 'g' type_id=6 linkage=static [2] -> [1] is the cast in f(), and nothing refers to [2]. With this patch the kernel looks like g(): its cast is the plain [5], which the kernel needs anyway. > if not should we push/pop -Wno-attributes around that one construct? This might be moot given above. Still it would be hard since there is no one place to put it. The pragmas cannot go inside DECLARE_PER_CPU()/DEFINE_PER_CPU(), because the caller writes "static" before them and "= init;" after them, so the pop lands in the middle of the declaration, and GCC rejects that:     error: expected '=', ',', ';', 'asm' or '__attribute__' before '#pragma' So it would have to wrap each per-cpu declaration of a struct or union type, about 650 of them, at which point we might as well do -Wno-attributes for the whole kernel. Thx, -Vineet