Implementation of m0_thread on top of struct task_struct and kthread API.
Instead of creating a new kthread executing user-supplied function, all threads start executing the same trampoline function kthread_trampoline() that performs some generic book-keeping.
The kernel m0_thread_confine() implementation comes with strict usage restrictions. It manipulates fields of the task_struct directly rather than using set_cpus_allowed_ptr(), and it does not protect against concurrent task termination. set_cpus_allowed_ptr() is not used because of GPL restrictions. The task is not protected from termination because that requires the use of get_task_struct() and put_task_struct(), however put_task_struct() is inlined and references __put_task_struct() and the latter is not exported. An easy way to ensure the task will not terminate is to call m0_thread_confine() from the task to be confined.
- Note
- Unless the thread being confined by m0_thread_confine() is the current thread, the thread will not migrate to a CPU in the bitmap until the next time it next blocks (unschedules) and subsequently resumes. Task migration is not an exported function of kernel/sched.c. When the current thread is confined, m0_thread_confine() causes the task to block and resume, so this function must be used in a context where scheduling is allowed.
◆ kthread_trampoline()
static int kthread_trampoline |
( |
void * |
arg | ) |
|
|
static |
◆ m0_enter_awkward()
M0_INTERNAL void m0_enter_awkward |
( |
void |
| ) |
|
◆ m0_exit_awkward()
M0_INTERNAL void m0_exit_awkward |
( |
void |
| ) |
|
◆ m0_is_awkward()
M0_INTERNAL bool m0_is_awkward |
( |
void |
| ) |
|
◆ m0_pid()
M0_INTERNAL uint64_t m0_pid |
( |
void |
| ) |
|
◆ m0_process()
M0_INTERNAL uint64_t m0_process |
( |
void |
| ) |
|
◆ m0_thread__cleanup()
M0_INTERNAL void m0_thread__cleanup |
( |
struct m0_thread * |
bye | ) |
|
◆ m0_thread_arch_adopt()
M0_INTERNAL int m0_thread_arch_adopt |
( |
struct m0_thread * |
thread, |
|
|
struct m0 * |
instance, |
|
|
bool |
full |
|
) |
| |
◆ m0_thread_arch_shun()
M0_INTERNAL void m0_thread_arch_shun |
( |
void |
| ) |
|
◆ m0_thread_confine()
M0_INTERNAL int m0_thread_confine |
( |
struct m0_thread * |
q, |
|
|
const struct m0_bitmap * |
processors |
|
) |
| |
◆ m0_thread_enter()
M0_INTERNAL void m0_thread_enter |
( |
struct m0_thread * |
thread, |
|
|
bool |
full |
|
) |
| |
◆ m0_thread_init_impl()
M0_INTERNAL int m0_thread_init_impl |
( |
struct m0_thread * |
q, |
|
|
const char * |
name |
|
) |
| |
◆ m0_thread_join()
◆ m0_thread_leave()
M0_INTERNAL void m0_thread_leave |
( |
void |
| ) |
|
◆ m0_thread_signal()
M0_INTERNAL int m0_thread_signal |
( |
struct m0_thread * |
q, |
|
|
int |
sig |
|
) |
| |
◆ m0_thread_tls()
◆ m0_thread_tls_back()
M0_INTERNAL void m0_thread_tls_back |
( |
struct m0_thread_tls * |
tls | ) |
|
◆ m0_thread_tls_pop()
◆ m0_threads_fini()
M0_INTERNAL void m0_threads_fini |
( |
void |
| ) |
|
◆ m0_threads_init()
M0_INTERNAL int m0_threads_init |
( |
struct m0 * |
instance | ) |
|
◆ m0_threads_once_fini()
M0_INTERNAL void m0_threads_once_fini |
( |
void |
| ) |
|
◆ m0_threads_once_init()
M0_INTERNAL int m0_threads_once_init |
( |
void |
| ) |
|
◆ tls_fini()
◆ __instance