Skip to contentSkip to conversation

locking/mutex: Explicitly mark task as running after wakeup

PATCH New Davidlohr Bueso 2 participants 2 messages Jan 20, 2015 – Feb 4, 2015 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 locking/mutex: Explicitly mark task as running after wakeup

By the time we wake up and get the lock after being asleep in the slowpath, we better be running. As good practice, be explicit about this and avoid any mischief.

---
 kernel/locking/mutex.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/locking/mutex.c +2 -0
index c67a60b..5740706 100644
@@ -587,6 +587,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 		schedule_preempt_disabled();
 		spin_lock_mutex(&lock->wait_lock, flags);
 	}
+	__set_task_state(task, TASK_RUNNING);
+
 	mutex_remove_waiter(lock, &waiter, current_thread_info());
 	/* set it to 0 if there are no waiters left: */
 	if (likely(list_empty(&lock->wait_list)))
Signature · 1 line
2.1.2
#1 lore raw
locking/mutex: Explicitly mark task as running after wakeup
Commit-ID:  51587bcf31d070119d37de6103543c807f5ccdb3
Gitweb:     http://git.kernel.org/tip/51587bcf31d070119d37de6103543c807f5ccdb3
Author:     Davidlohr Bueso <[email protected]>
AuthorDate: Mon, 19 Jan 2015 17:39:21 -0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 4 Feb 2015 07:57:33 +0100

locking/mutex: Explicitly mark task as running after wakeup

By the time we wake up and get the lock after being asleep in the slowpath, we better be running. As good practice, be explicit about this and avoid any mischief.

---
 kernel/locking/mutex.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/locking/mutex.c +2 -0
index c67a60b..5740706 100644
@@ -587,6 +587,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 		schedule_preempt_disabled();
 		spin_lock_mutex(&lock->wait_lock, flags);
 	}
+	__set_task_state(task, TASK_RUNNING);
+
 	mutex_remove_waiter(lock, &waiter, current_thread_info());
 	/* set it to 0 if there are no waiters left: */
 	if (likely(list_empty(&lock->wait_list)))