public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
	a.p.zijlstra@chello.nl, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:sched/core] sched: remove extra call overhead for schedule()
Date: Mon, 20 Apr 2009 19:00:45 GMT	[thread overview]
Message-ID: <tip-ff743345bf7685a207868048a70e23164c4785e5@git.kernel.org> (raw)
In-Reply-To: <20090313112300.927414207@chello.nl>

Commit-ID:  ff743345bf7685a207868048a70e23164c4785e5
Gitweb:     http://git.kernel.org/tip/ff743345bf7685a207868048a70e23164c4785e5
Author:     Peter Zijlstra <a.p.zijlstra@chello.nl>
AuthorDate: Fri, 13 Mar 2009 12:21:26 +0100
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 20 Apr 2009 20:49:53 +0200

sched: remove extra call overhead for schedule()

Lai Jiangshan's patch reminded me that I promised Nick to remove
that extra call overhead in schedule().

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20090313112300.927414207@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 kernel/mutex.c |    4 +++-
 kernel/sched.c |   12 ++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/kernel/mutex.c b/kernel/mutex.c
index 5d79781..e1fb735 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -248,7 +248,9 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 
 		/* didnt get the lock, go to sleep: */
 		spin_unlock_mutex(&lock->wait_lock, flags);
-		__schedule();
+		preempt_enable_no_resched();
+		schedule();
+		preempt_disable();
 		spin_lock_mutex(&lock->wait_lock, flags);
 	}
 
diff --git a/kernel/sched.c b/kernel/sched.c
index 7601cee..797f6fd 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5131,13 +5131,15 @@ pick_next_task(struct rq *rq)
 /*
  * schedule() is the main scheduler function.
  */
-asmlinkage void __sched __schedule(void)
+asmlinkage void __sched schedule(void)
 {
 	struct task_struct *prev, *next;
 	unsigned long *switch_count;
 	struct rq *rq;
 	int cpu;
 
+need_resched:
+	preempt_disable();
 	cpu = smp_processor_id();
 	rq = cpu_rq(cpu);
 	rcu_qsctr_inc(cpu);
@@ -5194,15 +5196,9 @@ need_resched_nonpreemptible:
 
 	if (unlikely(reacquire_kernel_lock(current) < 0))
 		goto need_resched_nonpreemptible;
-}
 
-asmlinkage void __sched schedule(void)
-{
-need_resched:
-	preempt_disable();
-	__schedule();
 	preempt_enable_no_resched();
-	if (unlikely(test_thread_flag(TIF_NEED_RESCHED)))
+	if (need_resched())
 		goto need_resched;
 }
 EXPORT_SYMBOL(schedule);

  parent reply	other threads:[~2009-04-20 19:01 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-13 11:21 [PATCH 00/11] generic software counters -v2 Peter Zijlstra
2009-03-13 11:21 ` [PATCH 01/11] sched: remove extra call overhead for schedule() Peter Zijlstra
2009-03-13 13:00   ` [tip:core/locking] " Peter Zijlstra
2009-04-20 19:00   ` tip-bot for Peter Zijlstra [this message]
2009-03-13 11:21 ` [PATCH 02/11] hrtimer: fix rq->lock inversion (again) Peter Zijlstra
2009-03-13 13:00   ` [tip:core/locking] " Peter Zijlstra
2009-03-13 13:27   ` Peter Zijlstra
2009-03-13 14:57   ` Peter Zijlstra
2009-03-31 12:57   ` Peter Zijlstra
2009-04-02 19:45   ` [tip:timers/urgent] " Peter Zijlstra
2009-03-13 11:21 ` [PATCH 03/11] perf_counter: x86: fix 32bit irq_period assumption Peter Zijlstra
2009-03-13 13:00   ` [tip:perfcounters/core] perf_counter: x86: fix 32-bit " Peter Zijlstra
2009-03-13 13:06   ` Peter Zijlstra
2009-03-13 11:21 ` [PATCH 04/11] perf_counter: use list_move_tail Peter Zijlstra
2009-03-13 13:00   ` [tip:perfcounters/core] perf_counter: use list_move_tail() Peter Zijlstra
2009-03-13 13:06   ` Peter Zijlstra
2009-03-13 11:21 ` [PATCH 05/11] perf_counter: add comment to barrier Peter Zijlstra
2009-03-13 13:01   ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-13 13:06   ` Peter Zijlstra
2009-03-13 11:21 ` [PATCH 06/11] perf_counter: x86: use ULL postfix for 64bit constants Peter Zijlstra
2009-03-13 13:01   ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-13 13:06   ` Peter Zijlstra
2009-03-13 11:21 ` [PATCH 07/11] perf_counter: software counter event infrastructure Peter Zijlstra
2009-03-13 13:01   ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-13 13:07   ` Peter Zijlstra
2009-03-13 11:21 ` [PATCH 08/11] perf_counter: provide pagefault software events Peter Zijlstra
2009-03-13 13:01   ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-13 13:07   ` Peter Zijlstra
2009-03-13 11:21 ` [PATCH 09/11] perf_counter: provide major/minor page fault " Peter Zijlstra
2009-03-13 13:01   ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-13 13:07   ` Peter Zijlstra
2009-03-13 11:21 ` [PATCH 10/11] perf_counter: hrtimer based sampling for software time events Peter Zijlstra
2009-03-13 13:01   ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-13 13:07   ` Peter Zijlstra
2009-03-13 15:43   ` [PATCH 10.5/11] perf_counter: fix hrtimer sampling Peter Zijlstra
2009-03-13 16:09     ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-13 11:21 ` [PATCH 11/11] perf_counter: add an event_list Peter Zijlstra
2009-03-13 13:02   ` [tip:perfcounters/core] " Peter Zijlstra
2009-03-13 13:07   ` Peter Zijlstra
2009-03-13 13:07 ` [PATCH 00/11] generic software counters -v2 Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-ff743345bf7685a207868048a70e23164c4785e5@git.kernel.org \
    --to=a.p.zijlstra@chello.nl \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox