Motr  M0
Kernel Thread Implementation
Collaboration diagram for Kernel Thread Implementation:

Functions

M0_INTERNAL struct m0_thread_tlsm0_thread_tls (void)
 
M0_INTERNAL int m0_threads_init (struct m0 *instance)
 
M0_INTERNAL void m0_threads_fini (void)
 
M0_INTERNAL int m0_threads_once_init (void)
 
M0_INTERNAL void m0_threads_once_fini (void)
 
M0_INTERNAL void m0_thread_enter (struct m0_thread *thread, bool full)
 
static void tls_fini (struct m0_thread_tls *tls)
 
M0_INTERNAL void m0_thread_leave (void)
 
M0_INTERNAL void m0_thread__cleanup (struct m0_thread *bye)
 
static int kthread_trampoline (void *arg)
 
M0_INTERNAL int m0_thread_init_impl (struct m0_thread *q, const char *name)
 
int m0_thread_join (struct m0_thread *q)
 
M0_INTERNAL int m0_thread_signal (struct m0_thread *q, int sig)
 
M0_INTERNAL int m0_thread_confine (struct m0_thread *q, const struct m0_bitmap *processors)
 
M0_INTERNAL void m0_enter_awkward (void)
 
M0_INTERNAL void m0_exit_awkward (void)
 
M0_INTERNAL bool m0_is_awkward (void)
 
M0_INTERNAL struct m0_thread_tlsm0_thread_tls_pop (void)
 
M0_INTERNAL void m0_thread_tls_back (struct m0_thread_tls *tls)
 
M0_INTERNAL uint64_t m0_pid (void)
 
M0_INTERNAL uint64_t m0_process (void)
 
M0_INTERNAL int m0_thread_arch_adopt (struct m0_thread *thread, struct m0 *instance, bool full)
 
M0_INTERNAL void m0_thread_arch_shun (void)
 

Variables

static struct m0__instance
 

Detailed Description

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.

Function Documentation

◆ kthread_trampoline()

static int kthread_trampoline ( void *  arg)
static

Definition at line 120 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_enter_awkward()

M0_INTERNAL void m0_enter_awkward ( void  )

Definition at line 249 of file kthread.c.

Here is the caller graph for this function:

◆ m0_exit_awkward()

M0_INTERNAL void m0_exit_awkward ( void  )

Definition at line 262 of file kthread.c.

Here is the caller graph for this function:

◆ m0_is_awkward()

M0_INTERNAL bool m0_is_awkward ( void  )

Definition at line 269 of file kthread.c.

Here is the caller graph for this function:

◆ m0_pid()

M0_INTERNAL uint64_t m0_pid ( void  )

Definition at line 290 of file kthread.c.

Here is the caller graph for this function:

◆ m0_process()

M0_INTERNAL uint64_t m0_process ( void  )

Definition at line 295 of file kthread.c.

Here is the caller graph for this function:

◆ m0_thread__cleanup()

M0_INTERNAL void m0_thread__cleanup ( struct m0_thread bye)

Definition at line 114 of file kthread.c.

Here is the call graph for this function:

◆ m0_thread_arch_adopt()

M0_INTERNAL int m0_thread_arch_adopt ( struct m0_thread thread,
struct m0 instance,
bool  full 
)

Definition at line 300 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_thread_arch_shun()

M0_INTERNAL void m0_thread_arch_shun ( void  )

Definition at line 320 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_thread_confine()

M0_INTERNAL int m0_thread_confine ( struct m0_thread q,
const struct m0_bitmap processors 
)

Definition at line 197 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_thread_enter()

M0_INTERNAL void m0_thread_enter ( struct m0_thread thread,
bool  full 
)

Definition at line 98 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_thread_init_impl()

M0_INTERNAL int m0_thread_init_impl ( struct m0_thread q,
const char *  name 
)

Definition at line 150 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_thread_join()

int m0_thread_join ( struct m0_thread q)

Definition at line 169 of file kthread.c.

Here is the call graph for this function:

◆ m0_thread_leave()

M0_INTERNAL void m0_thread_leave ( void  )

Definition at line 108 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_thread_signal()

M0_INTERNAL int m0_thread_signal ( struct m0_thread q,
int  sig 
)

Definition at line 192 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_thread_tls()

M0_INTERNAL struct m0_thread_tls * m0_thread_tls ( void  )

Definition at line 67 of file kthread.c.

Here is the caller graph for this function:

◆ m0_thread_tls_back()

M0_INTERNAL void m0_thread_tls_back ( struct m0_thread_tls tls)

Definition at line 282 of file kthread.c.

Here is the caller graph for this function:

◆ m0_thread_tls_pop()

M0_INTERNAL struct m0_thread_tls* m0_thread_tls_pop ( void  )

Definition at line 274 of file kthread.c.

Here is the caller graph for this function:

◆ m0_threads_fini()

M0_INTERNAL void m0_threads_fini ( void  )

Definition at line 85 of file kthread.c.

Here is the caller graph for this function:

◆ m0_threads_init()

M0_INTERNAL int m0_threads_init ( struct m0 instance)

Definition at line 77 of file kthread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_threads_once_fini()

M0_INTERNAL void m0_threads_once_fini ( void  )

Definition at line 94 of file kthread.c.

◆ m0_threads_once_init()

M0_INTERNAL int m0_threads_once_init ( void  )

Definition at line 89 of file kthread.c.

Here is the caller graph for this function:

◆ tls_fini()

static void tls_fini ( struct m0_thread_tls tls)
static

Definition at line 104 of file kthread.c.

Here is the caller graph for this function:

Variable Documentation

◆ __instance

struct m0* __instance
static

Definition at line 65 of file kthread.c.