From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796342429; b=Hkw9agGFp3BrV/XXWGABAyIPOGu/zJ3gpgSuxluTC/girTvWA/4PMCHkzumgdPNHl2gR 3/oYs6dSpg4Il5ML+h+GGahCfmWQP7WBUD+9nNSFXb90r7HVZ6G35fg6kaTDqVjQ2m61i 2IxSYeSQSl47IE/y4KLIeADlEEnXoK2ZrZU121WD52OvGrFGa+hINH8LDa/DzRBDpV5kH lP4q09sKvSqywjdayugUSYmVDvwZrS8Xk3W9TUJeoCIy699kELhSs0jUUbWocnJ0qIuxX YfTwyQGzxgVmHVfSRqK4+95+waT/RiGXfCeJ+Ab19h53haKp2z0FdI42eKYhQ1IR1Vg== 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=nZyiI/fSmrQlpjsrJBt1afuf05tisnL0ChsBRNkRsKzAseqTw1OMafGJxuBqdB0uz+hS QjaRBrqc+kxNkZhaN5sPW0HXKHTnPtct7nQMZSuTI/1bZ4dedO8Wb+gjb2pdpS7nYsEHh HzAWy8sOKfcA/fpDhdFSXeNJvNoBuuYS/HjATyO+9dn5xlKHZsAD5fKsLWYgq6rwxlLZO ffO1gFrbUhvN5J08Flfiww+s6MWEcetBAWnoXQp/UcuCuzKsWl2D7tMUJtu/8ez2hrzGG 9cjLSGOugMudvbk/04LRIjQUg+52iuynOcCacxNExT5cEPXl3/DTFu1k/fjdCUsj6Zg== 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=91.218.175.41 Received: from mta0.migadu.com (out-41.mta0.migadu.com [91.218.175.41]) (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 D512B606A337 for ; Fri, 4 Dec 2026 00:00:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D512B606A337 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: bpf@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: bpf@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: bpf@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