From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F950606A32F for ; Fri, 4 Dec 2026 00:00:35 +0000 (UTC) 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 Received: by kanga.kvack.org (Postfix) id 965956B00EF; Thu, 3 Dec 2026 19:00:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 916666B05B1; Thu, 3 Dec 2026 19:00:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 805956B05B2; Thu, 3 Dec 2026 19:00:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1432A6B00EF for ; Thu, 3 Dec 2026 19:00:34 -0500 (EST) Received: from smtpin26.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C1C34140211 for ; Fri, 4 Dec 2026 00:00:29 +0000 (UTC) X-FDA: 85504343778.26.BF3ED1C Received: from mta1.migadu.com (out-98.mta1.migadu.com [95.215.58.98]) by imf01.hostedemail.com (Postfix) with ESMTP id 6842C4000A for ; Fri, 4 Dec 2026 00:00:27 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=RzqZstSM; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of vineet.gupta@linux.dev designates 95.215.58.98 as permitted sender) smtp.mailfrom=vineet.gupta@linux.dev ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796342428; b=zD/KOLxrXlNk5iVWKQeT+EltqTAPjwaMcEge4RKxRoRRstdki6K8h7qwkYum9gLcLgpbeU 36+RN6XVmCQ8DtRCVU3MfJqnCKR4/zyMjHlrI5SjShicct4JygQ0BhWwCshxvuVbbEtGnJ 0K/yx7ZUosoteuK0XLqr3ibt9ekthEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796342428; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SnyPI8s3LaSNPkDyB0P1kuElGDCWTOCTb23k5NKDVOI=; b=fhfQqzq0SvFAU/0pQ2lTe49H6T/6uL0yxPG/XRaK/qlabvf5TJCYo5lRSZv2hAfMUcxV49 F2ZQtdRKyP0migp+PqHOqb2TUklC66uwcC5C80EyvX0vM98z3LBH2DwQNhHyQWjtd9IjmQ KlacNUzv2nXw4FYxTerv1h8MXnDGTf0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=RzqZstSM; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of vineet.gupta@linux.dev designates 95.215.58.98 as permitted sender) smtp.mailfrom=vineet.gupta@linux.dev X-Envelope-To: linux-mm@kvack.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-mm@kvack.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-Archived-By: 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 X-Stat-Signature: arwyy4brqfc67azjtzkrztpfi63qtkyo X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=4.0.1 X-Rspam-User: X-Rspamd-Queue-Id: 6842C4000A X-Rspamd-Server: rspam07 X-HE-Tag: 1796342427-737149 X-HE-Meta: U2FsdGVkX1/Wmh8q05e3YA9YEYdLHjwJ7Ef8hTZe7X19zodw4osnxHlzeVnCyDvjNDvs4PNlmotrQiFj8w1MbacnEek+fMFT+XHl38NUnGdRkrA/YqPvbLYzM8XSws7/Rq2n2fn8EWVpyHtjpj+6UEvU69GYzmOp8YGxstJDRbQ/7wCjeCbPolJHOOY1Z1jFoHASx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Yv/6LnkMgCxEUFYCkrsuC6ioj5HsYtaEuhpkxx2+xJdY/kIakD8aegnnbmjeAC+DUlMxdAZzwYpTIWNdsFwO3k1HhwRAprZYx4I07IqsP7Trp5Hya2rBMuHmhCS6p14xyf6Mki5I5pFb2KPtMASewmDyPALp5ol2HzX+doyLutyJbfsuxIyF57ulKzFIet587wG84MPuQmkzNBTeR92GESWB7BCgV4vhtlFKLM0BcS5D8ctieF14PKcQUZhQxRvoQmu0s0vg0MLIBhHRoI1YjW8bEawKkfcX1S0n+df3BgZ6jtHfjbWnKKZ5xDtLOrv9ufW6SP7PY4VHwuMyLvOKLu0MOTirb6RNi/5J5/D/ Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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