[PATCH for-6.12-fixes] sched_ext: fix fmt__str variables in kfuncs

Andrea Righi posted 1 patch 1 month ago
kernel/sched/ext.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH for-6.12-fixes] sched_ext: fix fmt__str variables in kfuncs
Posted by Andrea Righi 1 month ago
Commit 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in
kfuncs") renamed some parameters without updating the body of the
functions, triggering build errors like this:

kernel/sched/ext.c:6881:45: error: ‘fmt’ undeclared (first use in this function)
6881 |       if (bstr_format(&scx_exit_bstr_buf, fmt, data, data__sz) >= 0)
     |                                             ^~~

Fix by renaming also the varibles in the affected kfuncs.

Fixes: 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in kfuncs")
Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
---
 kernel/sched/ext.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index ff24d652c386..280beea63fa9 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -6738,7 +6738,7 @@ __bpf_kfunc void scx_bpf_exit_bstr(s64 exit_code, char *fmt__str,
 	unsigned long flags;
 
 	raw_spin_lock_irqsave(&scx_exit_bstr_buf_lock, flags);
-	if (bstr_format(&scx_exit_bstr_buf, fmt, data, data__sz) >= 0)
+	if (bstr_format(&scx_exit_bstr_buf, fmt__str, data, data__sz) >= 0)
 		scx_ops_exit_kind(SCX_EXIT_UNREG_BPF, exit_code, "%s",
 				  scx_exit_bstr_buf.line);
 	raw_spin_unlock_irqrestore(&scx_exit_bstr_buf_lock, flags);
@@ -6759,7 +6759,7 @@ __bpf_kfunc void scx_bpf_error_bstr(char *fmt__str, unsigned long long *data,
 	unsigned long flags;
 
 	raw_spin_lock_irqsave(&scx_exit_bstr_buf_lock, flags);
-	if (bstr_format(&scx_exit_bstr_buf, fmt, data, data__sz) >= 0)
+	if (bstr_format(&scx_exit_bstr_buf, fmt__str, data, data__sz) >= 0)
 		scx_ops_exit_kind(SCX_EXIT_ERROR_BPF, 0, "%s",
 				  scx_exit_bstr_buf.line);
 	raw_spin_unlock_irqrestore(&scx_exit_bstr_buf_lock, flags);
@@ -6791,10 +6791,10 @@ __bpf_kfunc void scx_bpf_dump_bstr(char *fmt__str, unsigned long long *data,
 
 	/* append the formatted string to the line buf */
 	ret = __bstr_format(buf->data, buf->line + dd->cursor,
-			    sizeof(buf->line) - dd->cursor, fmt, data, data__sz);
+			    sizeof(buf->line) - dd->cursor, fmt__str, data, data__sz);
 	if (ret < 0) {
 		dump_line(dd->s, "%s[!] (\"%s\", %p, %u) failed to format (%d)",
-			  dd->prefix, fmt, data, data__sz, ret);
+			  dd->prefix, fmt__str, data, data__sz, ret);
 		return;
 	}
 
-- 
2.47.0

Re: [PATCH for-6.12-fixes] sched_ext: fix fmt__str variables in kfuncs
Posted by Tejun Heo 1 month ago
On Tue, Oct 22, 2024 at 09:40:35AM +0200, Andrea Righi wrote:
> Commit 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in
> kfuncs") renamed some parameters without updating the body of the
> functions, triggering build errors like this:
> 
> kernel/sched/ext.c:6881:45: error: ‘fmt’ undeclared (first use in this function)
> 6881 |       if (bstr_format(&scx_exit_bstr_buf, fmt, data, data__sz) >= 0)
>      |                                             ^~~
> 
> Fix by renaming also the varibles in the affected kfuncs.
> 
> Fixes: 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in kfuncs")
> Signed-off-by: Andrea Righi <andrea.righi@linux.dev>

I removed this patch along with 3e99aee7ce48 ("sched-ext: Use correct
annotation for strings in kfuncs"). This breaks compatibility in a way which
is difficult to work around. If we want to do this, I think we should do it
by introducing new set of kfuncs and than phasing out the old ones. Also,
it's unclear what the practical benefits of the change are anyway.

Thanks.

-- 
tejun
Re: [PATCH for-6.12-fixes] sched_ext: fix fmt__str variables in kfuncs
Posted by Tejun Heo 1 month ago
On Tue, Oct 22, 2024 at 09:40:35AM +0200, Andrea Righi wrote:
> Commit 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in
> kfuncs") renamed some parameters without updating the body of the
> functions, triggering build errors like this:
> 
> kernel/sched/ext.c:6881:45: error: ‘fmt’ undeclared (first use in this function)
> 6881 |       if (bstr_format(&scx_exit_bstr_buf, fmt, data, data__sz) >= 0)
>      |                                             ^~~
> 
> Fix by renaming also the varibles in the affected kfuncs.
> 
> Fixes: 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in kfuncs")
> Signed-off-by: Andrea Righi <andrea.righi@linux.dev>

Applied to sched_ext/for-6.12-fixes.

Thanks.

-- 
tejun
Re: [PATCH for-6.12-fixes] sched_ext: fix fmt__str variables in kfuncs
Posted by Kumar Kartikeya Dwivedi 1 month ago
On Tue, 22 Oct 2024 at 09:40, Andrea Righi <andrea.righi@linux.dev> wrote:
>
> Commit 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in
> kfuncs") renamed some parameters without updating the body of the
> functions, triggering build errors like this:
>
> kernel/sched/ext.c:6881:45: error: ‘fmt’ undeclared (first use in this function)
> 6881 |       if (bstr_format(&scx_exit_bstr_buf, fmt, data, data__sz) >= 0)
>      |                                             ^~~
>
> Fix by renaming also the varibles in the affected kfuncs.
>
> Fixes: 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in kfuncs")
> Signed-off-by: Andrea Righi <andrea.righi@linux.dev>
> ---

Ah, thanks, this is embarrassing.
I didn't realize sched-ext was disabled in the .config when testing
this with other patches in the queue.
Sorry about that.

Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Re: [PATCH for-6.12-fixes] sched_ext: fix fmt__str variables in kfuncs
Posted by Thorsten Leemhuis 1 month ago
On 22.10.24 09:40, Andrea Righi wrote:
> Commit 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in
> kfuncs") renamed some parameters without updating the body of the
> functions, triggering build errors like this:
> 
> kernel/sched/ext.c:6881:45: error: ‘fmt’ undeclared (first use in this function)
> 6881 |       if (bstr_format(&scx_exit_bstr_buf, fmt, data, data__sz) >= 0)
>      |                                             ^~~
> 
> Fix by renaming also the varibles in the affected kfuncs.
> 
> Fixes: 3e99aee7ce48 ("sched-ext: Use correct annotation for strings in kfuncs")

Thx for this: ran into a build error with my daily -next builds earlier
today[1] and this fixes things (it's still compiling, but I'm past the
point where this happened afaics).

Tested-by: Thorsten Leemhuis <linux@leemhuis.info>

Ciao, Thorsten

[1]
https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-41-x86_64/08165136-next-next-all/builder-live.log.gz