Remove release and acquire semantics when accessing the "state" field of the
LinuxKPI task struct. Change type of "state" variable from "int" to "atomic_t" to simplify code and avoid unneccessary casting. MFC after: 1 week Sponsored by: Mellanox Technologies
This commit is contained in:
parent
e0390735d3
commit
ef9257491d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=325708
@ -67,7 +67,7 @@ struct task_struct {
|
||||
void *task_data;
|
||||
int task_ret;
|
||||
atomic_t usage;
|
||||
int state;
|
||||
atomic_t state;
|
||||
atomic_t kthread_flags;
|
||||
pid_t pid; /* BSD thread ID */
|
||||
const char *comm;
|
||||
@ -92,9 +92,8 @@ struct task_struct {
|
||||
#define put_pid(x) do { } while (0)
|
||||
#define current_euid() (curthread->td_ucred->cr_uid)
|
||||
|
||||
#define set_task_state(task, x) \
|
||||
atomic_store_rel_int((volatile int *)&task->state, (x))
|
||||
#define __set_task_state(task, x) (task->state = (x))
|
||||
#define set_task_state(task, x) atomic_set(&(task)->state, (x))
|
||||
#define __set_task_state(task, x) ((task)->state.counter = (x))
|
||||
#define set_current_state(x) set_task_state(current, x)
|
||||
#define __set_current_state(x) __set_task_state(current, x)
|
||||
|
||||
|
@ -68,7 +68,7 @@ linux_alloc_current(struct thread *td, int flags)
|
||||
ts->comm = td->td_name;
|
||||
ts->pid = td->td_tid;
|
||||
atomic_set(&ts->usage, 1);
|
||||
ts->state = TASK_RUNNING;
|
||||
atomic_set(&ts->state, TASK_RUNNING);
|
||||
init_completion(&ts->parked);
|
||||
init_completion(&ts->exited);
|
||||
|
||||
|
@ -78,7 +78,7 @@ wake_up_task(struct task_struct *task, unsigned int state)
|
||||
|
||||
ret = wakeup_swapper = 0;
|
||||
sleepq_lock(task);
|
||||
if ((atomic_load_acq_int(&task->state) & state) != 0) {
|
||||
if ((atomic_read(&task->state) & state) != 0) {
|
||||
set_task_state(task, TASK_WAKING);
|
||||
wakeup_swapper = sleepq_signal(task, SLEEPQ_SLEEP, 0, 0);
|
||||
ret = 1;
|
||||
@ -234,7 +234,7 @@ linux_wait_event_common(wait_queue_head_t *wqh, wait_queue_t *wq, int timeout,
|
||||
*/
|
||||
PHOLD(task->task_thread->td_proc);
|
||||
sleepq_lock(task);
|
||||
if (atomic_load_acq_int(&task->state) != TASK_WAKING) {
|
||||
if (atomic_read(&task->state) != TASK_WAKING) {
|
||||
ret = linux_add_to_sleepqueue(task, "wevent", timeout, state);
|
||||
} else {
|
||||
sleepq_release(task);
|
||||
@ -269,7 +269,7 @@ linux_schedule_timeout(int timeout)
|
||||
DROP_GIANT();
|
||||
|
||||
sleepq_lock(task);
|
||||
state = atomic_load_acq_int(&task->state);
|
||||
state = atomic_read(&task->state);
|
||||
if (state != TASK_WAKING)
|
||||
(void)linux_add_to_sleepqueue(task, "sched", timeout, state);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user