mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-15 11:44:11 +00:00
kthread: add the helper function kthread_run_on_cpu()
[ Upstream commit800977f6f3
] Add a new helper function kthread_run_on_cpu(), which includes 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. [akpm@linux-foundation.org: export kthread_create_on_cpu to modules] Link: https://lkml.kernel.org/r/20211022025711.3673-2-caihuoqing@baidu.com Signed-off-by: Cai Huoqing <caihuoqing@baidu.com> Cc: Bernard Metzler <bmt@zurich.ibm.com> Cc: Cai Huoqing <caihuoqing@baidu.com> Cc: Daniel Bristot de Oliveira <bristot@kernel.org> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Doug Ledford <dledford@redhat.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Joel Fernandes (Google) <joel@joelfernandes.org> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Lai Jiangshan <jiangshanlai@gmail.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: "Paul E . McKenney" <paulmck@kernel.org> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Stable-dep-of:08697bca9b
("trace/hwlat: Do not start per-cpu thread if it is already running") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
2905cc857f
commit
bd7e0de0af
2 changed files with 26 additions and 0 deletions
|
@ -56,6 +56,31 @@ bool kthread_is_per_cpu(struct task_struct *k);
|
|||
__k; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kthread_run_on_cpu - create and wake a cpu bound thread.
|
||||
* @threadfn: the function to run until signal_pending(current).
|
||||
* @data: data ptr for @threadfn.
|
||||
* @cpu: The cpu on which the thread should be bound,
|
||||
* @namefmt: printf-style name for the thread. Format is restricted
|
||||
* to "name.*%u". Code fills in cpu number.
|
||||
*
|
||||
* Description: Convenient wrapper for kthread_create_on_cpu()
|
||||
* followed by wake_up_process(). Returns the kthread or
|
||||
* ERR_PTR(-ENOMEM).
|
||||
*/
|
||||
static inline struct task_struct *
|
||||
kthread_run_on_cpu(int (*threadfn)(void *data), void *data,
|
||||
unsigned int cpu, const char *namefmt)
|
||||
{
|
||||
struct task_struct *p;
|
||||
|
||||
p = kthread_create_on_cpu(threadfn, data, cpu, namefmt);
|
||||
if (!IS_ERR(p))
|
||||
wake_up_process(p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void free_kthread_struct(struct task_struct *k);
|
||||
void kthread_bind(struct task_struct *k, unsigned int cpu);
|
||||
void kthread_bind_mask(struct task_struct *k, const struct cpumask *mask);
|
||||
|
|
|
@ -523,6 +523,7 @@ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
|
|||
to_kthread(p)->cpu = cpu;
|
||||
return p;
|
||||
}
|
||||
EXPORT_SYMBOL(kthread_create_on_cpu);
|
||||
|
||||
void kthread_set_per_cpu(struct task_struct *k, int cpu)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue