Commit 5376f2e7 authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Ingo Molnar

drivers/tty: Compute 'current' directly

This patch effectively replaces the tsk pointer dereference
(which is obviously == current), to directly use get_current()
macro. This is to make the removal of setting foreign task
states smoother and painfully obvious. Performance win on some
archs such as x86-64 and ppc64 -- arm64 is no longer an issue.
Signed-off-by: default avatarDavidlohr Bueso <dave@stgolabs.net>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: mark.rutland@arm.com
Link: http://lkml.kernel.org/r/1483479794-14013-3-git-send-email-dave@stgolabs.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 0039962a
...@@ -200,7 +200,6 @@ static struct ld_semaphore __sched * ...@@ -200,7 +200,6 @@ static struct ld_semaphore __sched *
down_read_failed(struct ld_semaphore *sem, long count, long timeout) down_read_failed(struct ld_semaphore *sem, long count, long timeout)
{ {
struct ldsem_waiter waiter; struct ldsem_waiter waiter;
struct task_struct *tsk = current;
long adjust = -LDSEM_ACTIVE_BIAS + LDSEM_WAIT_BIAS; long adjust = -LDSEM_ACTIVE_BIAS + LDSEM_WAIT_BIAS;
/* set up my own style of waitqueue */ /* set up my own style of waitqueue */
...@@ -221,8 +220,8 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout) ...@@ -221,8 +220,8 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout)
list_add_tail(&waiter.list, &sem->read_wait); list_add_tail(&waiter.list, &sem->read_wait);
sem->wait_readers++; sem->wait_readers++;
waiter.task = tsk; waiter.task = current;
get_task_struct(tsk); get_task_struct(current);
/* if there are no active locks, wake the new lock owner(s) */ /* if there are no active locks, wake the new lock owner(s) */
if ((count & LDSEM_ACTIVE_MASK) == 0) if ((count & LDSEM_ACTIVE_MASK) == 0)
...@@ -232,7 +231,7 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout) ...@@ -232,7 +231,7 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout)
/* wait to be given the lock */ /* wait to be given the lock */
for (;;) { for (;;) {
set_task_state(tsk, TASK_UNINTERRUPTIBLE); set_task_state(current, TASK_UNINTERRUPTIBLE);
if (!waiter.task) if (!waiter.task)
break; break;
...@@ -241,7 +240,7 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout) ...@@ -241,7 +240,7 @@ down_read_failed(struct ld_semaphore *sem, long count, long timeout)
timeout = schedule_timeout(timeout); timeout = schedule_timeout(timeout);
} }
__set_task_state(tsk, TASK_RUNNING); __set_task_state(current, TASK_RUNNING);
if (!timeout) { if (!timeout) {
/* lock timed out but check if this task was just /* lock timed out but check if this task was just
...@@ -268,7 +267,6 @@ static struct ld_semaphore __sched * ...@@ -268,7 +267,6 @@ static struct ld_semaphore __sched *
down_write_failed(struct ld_semaphore *sem, long count, long timeout) down_write_failed(struct ld_semaphore *sem, long count, long timeout)
{ {
struct ldsem_waiter waiter; struct ldsem_waiter waiter;
struct task_struct *tsk = current;
long adjust = -LDSEM_ACTIVE_BIAS; long adjust = -LDSEM_ACTIVE_BIAS;
int locked = 0; int locked = 0;
...@@ -289,16 +287,16 @@ down_write_failed(struct ld_semaphore *sem, long count, long timeout) ...@@ -289,16 +287,16 @@ down_write_failed(struct ld_semaphore *sem, long count, long timeout)
list_add_tail(&waiter.list, &sem->write_wait); list_add_tail(&waiter.list, &sem->write_wait);
waiter.task = tsk; waiter.task = current;
set_task_state(tsk, TASK_UNINTERRUPTIBLE); set_task_state(current, TASK_UNINTERRUPTIBLE);
for (;;) { for (;;) {
if (!timeout) if (!timeout)
break; break;
raw_spin_unlock_irq(&sem->wait_lock); raw_spin_unlock_irq(&sem->wait_lock);
timeout = schedule_timeout(timeout); timeout = schedule_timeout(timeout);
raw_spin_lock_irq(&sem->wait_lock); raw_spin_lock_irq(&sem->wait_lock);
set_task_state(tsk, TASK_UNINTERRUPTIBLE); set_task_state(current, TASK_UNINTERRUPTIBLE);
locked = writer_trylock(sem); locked = writer_trylock(sem);
if (locked) if (locked)
break; break;
...@@ -309,7 +307,7 @@ down_write_failed(struct ld_semaphore *sem, long count, long timeout) ...@@ -309,7 +307,7 @@ down_write_failed(struct ld_semaphore *sem, long count, long timeout)
list_del(&waiter.list); list_del(&waiter.list);
raw_spin_unlock_irq(&sem->wait_lock); raw_spin_unlock_irq(&sem->wait_lock);
__set_task_state(tsk, TASK_RUNNING); __set_task_state(current, TASK_RUNNING);
/* lock wait may have timed out */ /* lock wait may have timed out */
if (!locked) if (!locked)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment