* [PATCH v3] sched_ext: fix application of sizeof to pointer
@ 2024-11-17 2:51 guanjing
2024-11-20 13:59 ` Andrea Righi
2024-12-04 19:48 ` Tejun Heo
0 siblings, 2 replies; 3+ messages in thread
From: guanjing @ 2024-11-17 2:51 UTC (permalink / raw)
To: tj, void, joshdon, haoluo, brho; +Cc: linux-kernel, guanjing
sizeof when applied to a pointer typed expression gives the size of
the pointer.
The proper fix in this particular case is to code sizeof(*cpuset)
instead of sizeof(cpuset).
This issue was detected with the help of Coccinelle.
Fixes: 22a920209ab6 ("sched_ext: Implement tickless support")
Signed-off-by: guanjing <guanjing@cmss.chinamobile.com>
---
tools/sched_ext/scx_central.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/sched_ext/scx_central.c b/tools/sched_ext/scx_central.c
index 21deea320bd7..e938156ed0a0 100644
--- a/tools/sched_ext/scx_central.c
+++ b/tools/sched_ext/scx_central.c
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
SCX_BUG_ON(!cpuset, "Failed to allocate cpuset");
CPU_ZERO(cpuset);
CPU_SET(skel->rodata->central_cpu, cpuset);
- SCX_BUG_ON(sched_setaffinity(0, sizeof(cpuset), cpuset),
+ SCX_BUG_ON(sched_setaffinity(0, sizeof(*cpuset), cpuset),
"Failed to affinitize to central CPU %d (max %d)",
skel->rodata->central_cpu, skel->rodata->nr_cpu_ids - 1);
CPU_FREE(cpuset);
--
2.33.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] sched_ext: fix application of sizeof to pointer
2024-11-17 2:51 [PATCH v3] sched_ext: fix application of sizeof to pointer guanjing
@ 2024-11-20 13:59 ` Andrea Righi
2024-12-04 19:48 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Andrea Righi @ 2024-11-20 13:59 UTC (permalink / raw)
To: guanjing; +Cc: tj, void, joshdon, haoluo, brho, linux-kernel
On Sun, Nov 17, 2024 at 10:51:29AM +0800, guanjing wrote:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer.
>
> The proper fix in this particular case is to code sizeof(*cpuset)
> instead of sizeof(cpuset).
>
> This issue was detected with the help of Coccinelle.
>
> Fixes: 22a920209ab6 ("sched_ext: Implement tickless support")
> Signed-off-by: guanjing <guanjing@cmss.chinamobile.com>
Thanks for catching this, it looks good to me.
Could you send a PR for https://github.com/sched-ext/scx? We usually
sync the C schedulers from this repository into the kernel.
If you want you can add my:
Acked-by: Andrea Righi <arighi@nvidia.com>
Thanks,
-Andrea
> ---
> tools/sched_ext/scx_central.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/sched_ext/scx_central.c b/tools/sched_ext/scx_central.c
> index 21deea320bd7..e938156ed0a0 100644
> --- a/tools/sched_ext/scx_central.c
> +++ b/tools/sched_ext/scx_central.c
> @@ -97,7 +97,7 @@ int main(int argc, char **argv)
> SCX_BUG_ON(!cpuset, "Failed to allocate cpuset");
> CPU_ZERO(cpuset);
> CPU_SET(skel->rodata->central_cpu, cpuset);
> - SCX_BUG_ON(sched_setaffinity(0, sizeof(cpuset), cpuset),
> + SCX_BUG_ON(sched_setaffinity(0, sizeof(*cpuset), cpuset),
> "Failed to affinitize to central CPU %d (max %d)",
> skel->rodata->central_cpu, skel->rodata->nr_cpu_ids - 1);
> CPU_FREE(cpuset);
> --
> 2.33.0
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] sched_ext: fix application of sizeof to pointer
2024-11-17 2:51 [PATCH v3] sched_ext: fix application of sizeof to pointer guanjing
2024-11-20 13:59 ` Andrea Righi
@ 2024-12-04 19:48 ` Tejun Heo
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2024-12-04 19:48 UTC (permalink / raw)
To: guanjing; +Cc: void, joshdon, haoluo, brho, linux-kernel
On Sun, Nov 17, 2024 at 10:51:29AM +0800, guanjing wrote:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer.
>
> The proper fix in this particular case is to code sizeof(*cpuset)
> instead of sizeof(cpuset).
>
> This issue was detected with the help of Coccinelle.
>
> Fixes: 22a920209ab6 ("sched_ext: Implement tickless support")
> Signed-off-by: guanjing <guanjing@cmss.chinamobile.com>
Applied to sched_ext/for-6.13-fixes.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-04 19:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-17 2:51 [PATCH v3] sched_ext: fix application of sizeof to pointer guanjing
2024-11-20 13:59 ` Andrea Righi
2024-12-04 19:48 ` Tejun Heo
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®