Skip to content

Commit 6720a30

Browse files
committed
locking: avoid passing around 'thread_info' in mutex debugging code
None of the code actually wants a thread_info, it all wants a task_struct, and it's just converting back and forth between the two ("ti->task" to get the task_struct from the thread_info, and "task_thread_info(task)" to go the other way). No semantic change. Acked-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f9020d1 commit 6720a30

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

‎kernel/locking/mutex-debug.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
4949
}
5050

5151
void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
52-
struct thread_info *ti)
52+
struct task_struct *task)
5353
{
5454
SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
5555

5656
/* Mark the current thread as blocked on the lock: */
57-
ti->task->blocked_on = waiter;
57+
task->blocked_on = waiter;
5858
}
5959

6060
void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
61-
struct thread_info *ti)
61+
struct task_struct *task)
6262
{
6363
DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
64-
DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
65-
DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
66-
ti->task->blocked_on = NULL;
64+
DEBUG_LOCKS_WARN_ON(waiter->task != task);
65+
DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
66+
task->blocked_on = NULL;
6767

6868
list_del_init(&waiter->list);
6969
waiter->task = NULL;

‎kernel/locking/mutex-debug.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
2020
extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
2121
extern void debug_mutex_add_waiter(struct mutex *lock,
2222
struct mutex_waiter *waiter,
23-
struct thread_info *ti);
23+
struct task_struct *task);
2424
extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
25-
struct thread_info *ti);
25+
struct task_struct *task);
2626
extern void debug_mutex_unlock(struct mutex *lock);
2727
extern void debug_mutex_init(struct mutex *lock, const char *name,
2828
struct lock_class_key *key);

‎kernel/locking/mutex.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
537537
goto skip_wait;
538538

539539
debug_mutex_lock_common(lock, &waiter);
540-
debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
540+
debug_mutex_add_waiter(lock, &waiter, task);
541541

542542
/* add waiting tasks to the end of the waitqueue (FIFO): */
543543
list_add_tail(&waiter.list, &lock->wait_list);
@@ -584,7 +584,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
584584
}
585585
__set_task_state(task, TASK_RUNNING);
586586

587-
mutex_remove_waiter(lock, &waiter, current_thread_info());
587+
mutex_remove_waiter(lock, &waiter, task);
588588
/* set it to 0 if there are no waiters left: */
589589
if (likely(list_empty(&lock->wait_list)))
590590
atomic_set(&lock->count, 0);
@@ -605,7 +605,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
605605
return 0;
606606

607607
err:
608-
mutex_remove_waiter(lock, &waiter, task_thread_info(task));
608+
mutex_remove_waiter(lock, &waiter, task);
609609
spin_unlock_mutex(&lock->wait_lock, flags);
610610
debug_mutex_free_waiter(&waiter);
611611
mutex_release(&lock->dep_map, 1, ip);

‎kernel/locking/mutex.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
do { spin_lock(lock); (void)(flags); } while (0)
1414
#define spin_unlock_mutex(lock, flags) \
1515
do { spin_unlock(lock); (void)(flags); } while (0)
16-
#define mutex_remove_waiter(lock, waiter, ti) \
16+
#define mutex_remove_waiter(lock, waiter, task) \
1717
__list_del((waiter)->list.prev, (waiter)->list.next)
1818

1919
#ifdef CONFIG_MUTEX_SPIN_ON_OWNER

0 commit comments

Comments
 (0)