From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D35F53ACEF0 for ; Tue, 7 Apr 2026 11:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775561413; cv=none; b=eeV2j/tY+uYRGtDubOFumrz/fkS7+7AP01UT1qP442Df4b2++Q6949r299hUfViO0l9650eD6zWA70PpUD8MWI9CCrRnNSe38yC11DqkvUfvM0pVGlo/HHYT/El+AW42Dc0yI/Cx82xEnwx2hdgrY4OdiOVKRTuC6DlZWCh4jnc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775561413; c=relaxed/simple; bh=gJmeGJ4YN8tSj2UwwdnqaAqNbb191sdvW00bw/KMDMo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=uHSm1r83vwZpxiP5gC0yeqvskv04NoR2ZpLTHJ+v4UF/MEn8Trl16gL09Xe8xX5GbSWGKShBgkRfpjr9J5k/O6kc6o86zlcKVXuJURModK3ogQuSLrD0pqM+mSvloclH+5uNTq6viih9NZpZcdBVP2W46N7sEiqWAu7VnO4ZqjM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=LlgejsTs; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="LlgejsTs" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-43cfb723793so3147466f8f.2 for ; Tue, 07 Apr 2026 04:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1775561410; x=1776166210; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=X0AK+dItOezHrfutn/S86jIfwBt1tYlgVzWPhG3Rkg4=; b=LlgejsTsH9VJsNm/3X0MBF7h9YHfSL4diYMLtPfjqUh+JpV3M/Y0wPgN7Y1ctIcwv2 im0KDa4nk/17sDatAoJzu6p6lyobo6xkj48+5xoDwElSUvwwMoKONYjukr2NLxduW5Wb +iltYLAfBzgwtTrOGZKBSMJHqcRVW6TDVpQShQTV27EfvapSBIluxWltwNuz9cqcpQ3i SsOi/aySKC0/5Xv+pPdLYyf0yh7JNmJdDTJVWMZ2EZoYF4pMyV5IbO02ahzOPrPKqezQ 2hS3oEhzVOs69yrWQvLr8Ah6apAMl7QV/heiiKU1KlTUYP1v5y6KfAlpDab3lqldAZxd ompA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775561410; x=1776166210; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=X0AK+dItOezHrfutn/S86jIfwBt1tYlgVzWPhG3Rkg4=; b=XJjjdKNsBzd2DQ5QXdX2tFNO0m4krpIhnkNInLFjlNd1l4AJFpgluGZzcCcFpbuUr8 +wMfKwyhjwmHCc553HR0C1w5kpELEpsRJUU7pzIPahKnzcJdUbEl/vut/vlGhedLVMyf xrukbHOo0VZ0JvXvkOa5lvk3f23A4uq32m2D6Lc0+j8DxxDJXvjO+g9sqG6qCzLvNlVG cm9OMRBeXwPYR2p+qqMnUtXf5uRYQ6G3Pgtw3PnQy9Q+Tc4IXQmeFWpJ2Blb3LxCZ6uz 9ysGiw5CkfhOq2SBQYi93ht6mDov/O6zuw+xXww8LMv3JHZIGa0FZNGvMtOKl+9QajG4 TDPQ== X-Forwarded-Encrypted: i=1; AJvYcCXnqJ8VyWrPl9aeZd9+2i6R7g+OcGiuy9v+y0bdfn+XSdzs6yuKGJjqLP8PoSEyuPIyu90Y1z3zWdLwt7s=@vger.kernel.org X-Gm-Message-State: AOJu0YxvrhiOW0bLC+ZItQD5AhoXkouCZ5jzX86hO7GI/54TrvE9xEWB K8KPFr6Wl8er3Qen1zxNkruzWoCA79NBAeT7Gpf4QrsShHBljPZARrqcvXkX/TffpQw= X-Gm-Gg: AeBDiev8W7w5OFsBpHn0tZfjT7wOLaYNS0Y3TwY4vt2z3B1WiZpV6oy53boCLKdiwLM hrs/RAnBayfwmVD1S1FmYaryGeWlZpoDqgAiKGGst2wOllXReDz6Mdxi9qPcTna2U/Cex8d9pRH NnjtaUKF7JzsK/UQgF2KtnYxxK+uqXMgWN8GhzpJ8FWJcv1XL7lrgVwrPu7GRWX05JFLhhPeY3E jnet5kEjkB7oxrHTUcpKpn/7VFCVXgzmjIMCqPNUDpM/7KaCA16X5uTHj47Xw2FJL3ni5dX85xc thkirXVYnPu7a25s5FQaS4yHlzT60ba3rwYZeCV8aQc8CiP1O6NacUkIJk2ECj9f3JK8l4G/XRa +wjFQ4ya8LGyAyjXEBvCH1Y/LgQ3jfyeK2I0eN3jszhgjgkisLhTGJX8OqSG5krEFl34DLrrA2G qEceyAJ+7YJToQn5ThkBsAc1SYI74foSBCGNHDmMZHiCQm X-Received: by 2002:a5d:5d0f:0:b0:43d:184:8a9b with SMTP id ffacd0b85a97d-43d2929d8fcmr23481469f8f.16.1775561409975; Tue, 07 Apr 2026 04:30:09 -0700 (PDT) Received: from [10.100.51.209] (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e2a720dsm49743604f8f.4.2026.04.07.04.30.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Apr 2026 04:30:09 -0700 (PDT) Message-ID: Date: Tue, 7 Apr 2026 13:30:08 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] kbuild/btf: Avoid relinking modules when only vmlinux changes To: Nathan Chancellor , Nicolas Schier , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Luis Chamberlain , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Ihor Solodrai , Masahiro Yamada , linux-kbuild@vger.kernel.org, bpf@vger.kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260402141911.1577711-1-petr.pavlu@suse.com> Content-Language: en-US From: Petr Pavlu In-Reply-To: <20260402141911.1577711-1-petr.pavlu@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/2/26 4:17 PM, Petr Pavlu wrote: > Commit 5f9ae91f7c0d ("kbuild: Build kernel module BTFs if BTF is enabled > and pahole supports it") in 2020 introduced CONFIG_DEBUG_INFO_BTF_MODULES > to enable generation of split BTF for kernel modules. This change required > the %.ko Makefile rule to additionally depend on vmlinux, which is used as > a base for deduplication. The regular ld_ko_o command executed by the rule > was then modified to be skipped if only vmlinux changes. This was done by > introducing a new if_changed_except command and updating the original call > to '+$(call if_changed_except,ld_ko_o,vmlinux)'. > > Later, commit 214c0eea43b2 ("kbuild: add $(objtree)/ prefix to some > in-kernel build artifacts") in 2024 updated the rule's reference to vmlinux > from 'vmlinux' to '$(objtree)/vmlinux'. This accidentally broke the > previous logic to skip relinking modules if only vmlinux changes. The issue > is that '$(objtree)' is typically '.' and GNU Make normalizes the resulting > prerequisite './vmlinux' to just 'vmlinux', while the exclusion logic > retains the raw './vmlinux'. As a result, if_changed_except doesn't > correctly filter out vmlinux. Consequently, with > CONFIG_DEBUG_INFO_BTF_MODULES=y, modules are relinked even if only vmlinux > changes. > > Additionally, commit 522397d05e7d ("resolve_btfids: Change in-place update > with raw binary output") in 2025 reworked the method for patching BTF data > into the resulting modules by using 'objcopy --add-section'. This command > fails if a section already exists. > > Fix the unnecessary relinking issue by also excluding the normalized form > 'vmlinux' when invoking ld_ko_o. Adjust embed_btf_data() to first use the > --remove-section option to remove the patched BTF section if it is already > present. I noticed that sorting id+flags in BTF_SET8 by resolve_btfids doesn't seem to be idempotent, so this requires additional work. -- Petr