Motr  M0
thread.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_LIB_LINUX_KERNEL_THREAD_H__
26 #define __MOTR_LIB_LINUX_KERNEL_THREAD_H__
27 
28 #include <linux/kthread.h>
29 #include <linux/hardirq.h>
30 
43 enum { M0_THREAD_NAME_LEN = TASK_COMM_LEN };
44 
46  struct task_struct *h_tsk;
47  unsigned long h_pid;
48 };
49 
52  void *tat_prev;
53 };
54 
55 struct m0_thread;
56 M0_INTERNAL void m0_thread_enter(struct m0_thread *thread, bool full);
57 M0_INTERNAL void m0_thread_leave(void);
58 M0_INTERNAL void m0_thread__cleanup(struct m0_thread *bye);
59 
60 #define M0_THREAD_ENTER \
61  struct m0_thread __th \
62  __attribute__((cleanup(m0_thread__cleanup))) = { 0, }; \
63  m0_thread_enter(&__th, true)
64 
65 M0_INTERNAL struct m0_thread_tls *m0_thread_tls_pop(void);
66 M0_INTERNAL void m0_thread_tls_back(struct m0_thread_tls *tls);
67 
69 #endif /* __MOTR_LIB_LINUX_KERNEL_THREAD_H__ */
70 
71 /*
72  * Local variables:
73  * c-indentation-style: "K&R"
74  * c-basic-offset: 8
75  * tab-width: 8
76  * fill-column: 80
77  * scroll-step: 1
78  * End:
79  */
M0_INTERNAL void m0_thread_enter(struct m0_thread *thread, bool full)
Definition: kthread.c:98
void * tat_prev
Definition: thread.h:52
struct task_struct * h_tsk
Definition: thread.h:46
static void full(void)
Definition: base.c:334
M0_INTERNAL struct m0_thread_tls * m0_thread_tls_pop(void)
Definition: kthread.c:274
M0_INTERNAL void m0_thread_leave(void)
Definition: kthread.c:108
M0_INTERNAL void m0_thread__cleanup(struct m0_thread *bye)
Definition: kthread.c:114
struct m0_thread thread
Definition: note.c:104
static __thread struct m0_thread_tls * tls
Definition: uthread.c:66
M0_INTERNAL void m0_thread_tls_back(struct m0_thread_tls *tls)
Definition: kthread.c:282
unsigned long h_pid
Definition: thread.h:47