mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/2] kbuild: propagate CONFIG_WERROR to resolve_btfids
@ 2024-12-04 19:37 Thomas Weißschuh
  2024-12-04 19:37 ` [PATCH bpf-next v3 1/2] tools/resolve_btfids: Add --fatal_warnings option Thomas Weißschuh
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2024-12-04 19:37 UTC (permalink / raw)
  To: Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
  Cc: linux-kbuild, linux-kernel, bpf, Thomas Weißschuh

Use CONFIG_WERROR to also fail on warnings emitted by resolve_btfids.
Allow the CI bots to prevent the introduction of new warnings.

This series currently depends on
"[PATCH] bpf, lsm: Fix getlsmprop hooks BTF IDs" [0]

[0] https://lore.kernel.org/lkml/20241123-bpf_lsm_task_getsecid_obj-v1-1-0d0f94649e05@weissschuh.net/

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v3:
- Retarget to bpf-next tree
- Rename --fatal-warnings to --fatal_warnings for consistency
- Link to v2: https://lore.kernel.org/r/20241126-resolve_btfids-v2-0-288c37cb89ee@weissschuh.net

Changes in v2:
- Avoid uninitialized read of fatal_warnings
- Use OPT_BOOLEAN over OPT_INCR
- Drop dependency patch, which went in via the kbuild tree
- Link to v1: https://lore.kernel.org/r/20241123-resolve_btfids-v1-0-927700b641d1@weissschuh.net

---
Thomas Weißschuh (2):
      tools/resolve_btfids: Add --fatal_warnings option
      kbuild: propagate CONFIG_WERROR to resolve_btfids

 scripts/link-vmlinux.sh         |  6 +++++-
 tools/bpf/resolve_btfids/main.c | 12 ++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
---
base-commit: e2cf913314b9543f4479788443c7e9009c6c56d8
change-id: 20241123-resolve_btfids-eb95c9b42d00

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH bpf-next v3 1/2] tools/resolve_btfids: Add --fatal_warnings option
  2024-12-04 19:37 [PATCH bpf-next v3 0/2] kbuild: propagate CONFIG_WERROR to resolve_btfids Thomas Weißschuh
@ 2024-12-04 19:37 ` Thomas Weißschuh
  2024-12-10 17:09   ` Daniel Borkmann
  2024-12-04 19:37 ` [PATCH bpf-next v3 2/2] kbuild: propagate CONFIG_WERROR to resolve_btfids Thomas Weißschuh
  2024-12-05 23:30 ` [PATCH bpf-next v3 0/2] " patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Thomas Weißschuh @ 2024-12-04 19:37 UTC (permalink / raw)
  To: Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
  Cc: linux-kbuild, linux-kernel, bpf, Thomas Weißschuh

Currently warnings emitted by resolve_btfids are buried in the build log
and are slipping into mainline frequently.
Add an option to elevate warnings to hard errors so the CI bots can
catch any new warnings.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/bpf/resolve_btfids/main.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c
index bd9f960bce3d5b74dc34159b35af1e0b33524d2d..d47191c6e55e10215269774f4bdfc6e5b4bf72f8 100644
--- a/tools/bpf/resolve_btfids/main.c
+++ b/tools/bpf/resolve_btfids/main.c
@@ -141,6 +141,7 @@ struct object {
 };
 
 static int verbose;
+static int warnings;
 
 static int eprintf(int level, int var, const char *fmt, ...)
 {
@@ -604,6 +605,7 @@ static int symbols_resolve(struct object *obj)
 			if (id->id) {
 				pr_info("WARN: multiple IDs found for '%s': %d, %d - using %d\n",
 					str, id->id, type_id, id->id);
+				warnings++;
 			} else {
 				id->id = type_id;
 				(*nr)--;
@@ -625,8 +627,10 @@ static int id_patch(struct object *obj, struct btf_id *id)
 	int i;
 
 	/* For set, set8, id->id may be 0 */
-	if (!id->id && !id->is_set && !id->is_set8)
+	if (!id->id && !id->is_set && !id->is_set8) {
 		pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name);
+		warnings++;
+	}
 
 	for (i = 0; i < id->addr_cnt; i++) {
 		unsigned long addr = id->addr[i];
@@ -782,6 +786,7 @@ int main(int argc, const char **argv)
 		.funcs    = RB_ROOT,
 		.sets     = RB_ROOT,
 	};
+	bool fatal_warnings = false;
 	struct option btfid_options[] = {
 		OPT_INCR('v', "verbose", &verbose,
 			 "be more verbose (show errors, etc)"),
@@ -789,6 +794,8 @@ int main(int argc, const char **argv)
 			   "BTF data"),
 		OPT_STRING('b', "btf_base", &obj.base_btf_path, "file",
 			   "path of file providing base BTF"),
+		OPT_BOOLEAN(0, "fatal_warnings", &fatal_warnings,
+			    "turn warnings into errors"),
 		OPT_END()
 	};
 	int err = -1;
@@ -823,7 +830,8 @@ int main(int argc, const char **argv)
 	if (symbols_patch(&obj))
 		goto out;
 
-	err = 0;
+	if (!(fatal_warnings && warnings))
+		err = 0;
 out:
 	if (obj.efile.elf) {
 		elf_end(obj.efile.elf);

-- 
2.47.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH bpf-next v3 2/2] kbuild: propagate CONFIG_WERROR to resolve_btfids
  2024-12-04 19:37 [PATCH bpf-next v3 0/2] kbuild: propagate CONFIG_WERROR to resolve_btfids Thomas Weißschuh
  2024-12-04 19:37 ` [PATCH bpf-next v3 1/2] tools/resolve_btfids: Add --fatal_warnings option Thomas Weißschuh
@ 2024-12-04 19:37 ` Thomas Weißschuh
  2024-12-05 23:30 ` [PATCH bpf-next v3 0/2] " patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2024-12-04 19:37 UTC (permalink / raw)
  To: Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
	Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
  Cc: linux-kbuild, linux-kernel, bpf, Thomas Weißschuh

Use CONFIG_WERROR to also fail on warnings emitted by resolve_btfids.
Allow the CI bots to prevent the introduction of new warnings.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
---
 scripts/link-vmlinux.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index a3c634b2f348f9c976cff9693caf290db7f31666..991d08c0042c68fc452210a8423d67162891c585 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -279,7 +279,11 @@ vmlinux_link vmlinux
 # fill in BTF IDs
 if is_enabled CONFIG_DEBUG_INFO_BTF; then
 	info BTFIDS vmlinux
-	${RESOLVE_BTFIDS} vmlinux
+	RESOLVE_BTFIDS_ARGS=""
+	if is_enabled CONFIG_WERROR; then
+		RESOLVE_BTFIDS_ARGS=" --fatal_warnings "
+	fi
+	${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} vmlinux
 fi
 
 mksysmap vmlinux System.map

-- 
2.47.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v3 0/2] kbuild: propagate CONFIG_WERROR to resolve_btfids
  2024-12-04 19:37 [PATCH bpf-next v3 0/2] kbuild: propagate CONFIG_WERROR to resolve_btfids Thomas Weißschuh
  2024-12-04 19:37 ` [PATCH bpf-next v3 1/2] tools/resolve_btfids: Add --fatal_warnings option Thomas Weißschuh
  2024-12-04 19:37 ` [PATCH bpf-next v3 2/2] kbuild: propagate CONFIG_WERROR to resolve_btfids Thomas Weißschuh
@ 2024-12-05 23:30 ` patchwork-bot+netdevbpf
  2024-12-05 23:36   ` Andrii Nakryiko
  2 siblings, 1 reply; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-12-05 23:30 UTC (permalink / raw)
  To: =?utf-8?q?Thomas_Wei=C3=9Fschuh_=3Clinux=40weissschuh=2Enet=3E?=
  Cc: masahiroy, nathan, nicolas, ast, daniel, andrii, martin.lau,
	eddyz87, song, yonghong.song, john.fastabend, kpsingh, sdf,
	haoluo, jolsa, linux-kbuild, linux-kernel, bpf

Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Wed, 04 Dec 2024 20:37:43 +0100 you wrote:
> Use CONFIG_WERROR to also fail on warnings emitted by resolve_btfids.
> Allow the CI bots to prevent the introduction of new warnings.
> 
> This series currently depends on
> "[PATCH] bpf, lsm: Fix getlsmprop hooks BTF IDs" [0]
> 
> [0] https://lore.kernel.org/lkml/20241123-bpf_lsm_task_getsecid_obj-v1-1-0d0f94649e05@weissschuh.net/
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3,1/2] tools/resolve_btfids: Add --fatal_warnings option
    https://git.kernel.org/bpf/bpf-next/c/2fd821354772
  - [bpf-next,v3,2/2] kbuild: propagate CONFIG_WERROR to resolve_btfids
    https://git.kernel.org/bpf/bpf-next/c/0a7a188468c0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v3 0/2] kbuild: propagate CONFIG_WERROR to resolve_btfids
  2024-12-05 23:30 ` [PATCH bpf-next v3 0/2] " patchwork-bot+netdevbpf
@ 2024-12-05 23:36   ` Andrii Nakryiko
  0 siblings, 0 replies; 6+ messages in thread
From: Andrii Nakryiko @ 2024-12-05 23:36 UTC (permalink / raw)
  To: patchwork-bot+netdevbpf
  Cc: masahiroy, nathan, nicolas, ast, daniel, andrii, martin.lau,
	eddyz87, song, yonghong.song, john.fastabend, kpsingh, sdf,
	haoluo, jolsa, linux-kbuild, linux-kernel, bpf

On Thu, Dec 5, 2024 at 3:30 PM <patchwork-bot+netdevbpf@kernel.org> wrote:
>
> Hello:
>
> This series was applied to bpf/bpf-next.git (master)

I unlanded this for now. We are waiting for a fix in the bpf tree to
make it into bpf-next before we can land this, sorry for the noise.

> by Andrii Nakryiko <andrii@kernel.org>:
>
> On Wed, 04 Dec 2024 20:37:43 +0100 you wrote:
> > Use CONFIG_WERROR to also fail on warnings emitted by resolve_btfids.
> > Allow the CI bots to prevent the introduction of new warnings.
> >
> > This series currently depends on
> > "[PATCH] bpf, lsm: Fix getlsmprop hooks BTF IDs" [0]
> >
> > [0] https://lore.kernel.org/lkml/20241123-bpf_lsm_task_getsecid_obj-v1-1-0d0f94649e05@weissschuh.net/
> >
> > [...]
>
> Here is the summary with links:
>   - [bpf-next,v3,1/2] tools/resolve_btfids: Add --fatal_warnings option
>     https://git.kernel.org/bpf/bpf-next/c/2fd821354772
>   - [bpf-next,v3,2/2] kbuild: propagate CONFIG_WERROR to resolve_btfids
>     https://git.kernel.org/bpf/bpf-next/c/0a7a188468c0
>
> You are awesome, thank you!
> --
> Deet-doot-dot, I am a bot.
> https://korg.docs.kernel.org/patchwork/pwbot.html
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH bpf-next v3 1/2] tools/resolve_btfids: Add --fatal_warnings option
  2024-12-04 19:37 ` [PATCH bpf-next v3 1/2] tools/resolve_btfids: Add --fatal_warnings option Thomas Weißschuh
@ 2024-12-10 17:09   ` Daniel Borkmann
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2024-12-10 17:09 UTC (permalink / raw)
  To: Thomas Weißschuh, Masahiro Yamada, Nathan Chancellor,
	Nicolas Schier, Alexei Starovoitov, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
  Cc: linux-kbuild, linux-kernel, bpf

On 12/4/24 8:37 PM, Thomas Weißschuh wrote:
> Currently warnings emitted by resolve_btfids are buried in the build log
> and are slipping into mainline frequently.
> Add an option to elevate warnings to hard errors so the CI bots can
> catch any new warnings.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Given the dependencies by now propagated to bpf-next, I took these two
in, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-10 17:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-04 19:37 [PATCH bpf-next v3 0/2] kbuild: propagate CONFIG_WERROR to resolve_btfids Thomas Weißschuh
2024-12-04 19:37 ` [PATCH bpf-next v3 1/2] tools/resolve_btfids: Add --fatal_warnings option Thomas Weißschuh
2024-12-10 17:09   ` Daniel Borkmann
2024-12-04 19:37 ` [PATCH bpf-next v3 2/2] kbuild: propagate CONFIG_WERROR to resolve_btfids Thomas Weißschuh
2024-12-05 23:30 ` [PATCH bpf-next v3 0/2] " patchwork-bot+netdevbpf
2024-12-05 23:36   ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®