the helper macro kthread_run_on_cpu() inculdes
kthread_create_on_cpu/wake_up_process().
In some cases, use kthread_run_on_cpu() directly instead of
kthread_create_on_node/kthread_bind/wake_up_process() or
kthread_create_on_cpu/wake_up_process() or
kthreadd_create/kthread_bind/wake_up_process() to simplify the code.
v1->v2:
*[1/6]Remove cpu_to_node from kthread_create_on_cpu params.
*[1/6]Updated the macro description comment.
*[4,5/6]Update changelog
Cai Huoqing (6):
kthread: Add the helper macro kthread_run_on_cpu()
RDMA/siw: Make use of the helper macro kthread_run_on_cpu()
ring-buffer: Make use of the helper macro kthread_run_on_cpu()
rcutorture: Make use of the helper macro kthread_run_on_cpu()
trace/osnoise: Make use of the helper macro kthread_run_on_cpu()
trace/hwlat: Make use of the helper macro kthread_run_on_cpu()
drivers/infiniband/sw/siw/siw_main.c | 7 +++----
include/linux/kthread.h | 21 +++++++++++++++++++++
kernel/rcu/rcutorture.c | 7 ++-----
kernel/trace/ring_buffer.c | 7 ++-----
kernel/trace/trace_hwlat.c | 6 +-----
kernel/trace/trace_osnoise.c | 3 +--
6 files changed, 31 insertions(+), 21 deletions(-)
--
2.25.1
Repalce kthread_create_on_cpu/wake_up_process()
with kthread_run_on_cpu() to simplify the code.
Signed-off-by: Cai Huoqing <[email protected]>
---
v1->v2: Update changelog.
kernel/trace/trace_hwlat.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index 1b83d75eb103..0e555335f095 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -491,18 +491,14 @@ static void stop_per_cpu_kthreads(void)
static int start_cpu_kthread(unsigned int cpu)
{
struct task_struct *kthread;
- char comm[24];
- snprintf(comm, 24, "hwlatd/%d", cpu);
-
- kthread = kthread_create_on_cpu(kthread_fn, NULL, cpu, comm);
+ kthread = kthread_run_on_cpu(kthread_fn, NULL, cpu, "hwlatd/%u");
if (IS_ERR(kthread)) {
pr_err(BANNER "could not start sampling thread\n");
return -ENOMEM;
}
per_cpu(hwlat_per_cpu_data, cpu).kthread = kthread;
- wake_up_process(kthread);
return 0;
}
--
2.25.1
Repalce kthread_create/kthread_bind/wake_up_process()
with kthread_run_on_cpu() to simplify the code.
Signed-off-by: Cai Huoqing <[email protected]>
---
kernel/trace/ring_buffer.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index c5a3fbf19617..afb306e21e5b 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -5898,16 +5898,13 @@ static __init int test_ringbuffer(void)
rb_data[cpu].buffer = buffer;
rb_data[cpu].cpu = cpu;
rb_data[cpu].cnt = cpu;
- rb_threads[cpu] = kthread_create(rb_test, &rb_data[cpu],
- "rbtester/%d", cpu);
+ rb_threads[cpu] = kthread_run_on_cpu(rb_test, &rb_data[cpu],
+ cpu, "rbtester/%u");
if (WARN_ON(IS_ERR(rb_threads[cpu]))) {
pr_cont("FAILED\n");
ret = PTR_ERR(rb_threads[cpu]);
goto out_free;
}
-
- kthread_bind(rb_threads[cpu], cpu);
- wake_up_process(rb_threads[cpu]);
}
/* Now create the rb hammer! */
--
2.25.1
On 10/21/21 5:27 AM, Cai Huoqing wrote:
> the helper macro kthread_run_on_cpu() inculdes
Consider using a spelling checker (inculdes -> includes).
Thanks,
Bart.
On 10/21/21 5:27 AM, Cai Huoqing wrote:
> Repalce kthread_create_on_cpu/wake_up_process()
Repalce -> Replace ?
Thanks,
Bart.