From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>, Anton Blanchard <anton@samba.org>
Subject: [PATCH 13/14] powerpc/64: context switch can avoid reservation clear
Date: Fri, 2 Jun 2017 17:39:45 +1000 [thread overview]
Message-ID: <20170602073946.8983-14-npiggin@gmail.com> (raw)
In-Reply-To: <20170602073946.8983-1-npiggin@gmail.com>
There is no need to break reservation in _switch, because we are
guranteed that context switch path will include a larx/stcx.
Comment the guarantee and remove the reservation clear from _switch.
This is worth 1-2% in context switch performance.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/entry_64.S | 11 +++--------
kernel/sched/core.c | 6 ++++++
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 019a6322b982..012142fe39a4 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -521,15 +521,10 @@ _GLOBAL(_switch)
#endif /* CONFIG_SMP */
/*
- * If we optimise away the clear of the reservation in system
- * calls because we know the CPU tracks the address of the
- * reservation, then we need to clear it here to cover the
- * case that the kernel context switch path has no larx
- * instructions.
+ * The kernel context switch path must contain a spin_lock,
+ * which contains larx/stcx, which will clear any reservation
+ * of the task being switched.
*/
-BEGIN_FTR_SECTION
- ldarx r6,0,r1
-END_FTR_SECTION_IFSET(CPU_FTR_STCX_CHECKS_ADDRESS)
BEGIN_FTR_SECTION
/*
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 803c3bc274c4..1f0688ad09d7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2875,6 +2875,12 @@ context_switch(struct rq *rq, struct task_struct *prev,
rq_unpin_lock(rq, rf);
spin_release(&rq->lock.dep_map, 1, _THIS_IP_);
+ /*
+ * Some architectures require that a spin lock is taken before
+ * _switch. The rq_lock satisfies this condition. See powerpc
+ * _switch for details.
+ */
+
/* Here we just switch the register state and the stack. */
switch_to(prev, next, prev);
barrier();
--
2.11.0
next prev parent reply other threads:[~2017-06-02 7:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 7:39 [RFC][PATCH 00/14] syscall, context switch, idle performance stuff Nicholas Piggin
2017-06-02 7:39 ` [PATCH 01/14] powerpc/64s: optimize hypercall/syscall Nicholas Piggin
2017-06-02 7:39 ` [PATCH 02/14] powerpc/64: syscall avoid restore_math call if possible Nicholas Piggin
2017-06-02 7:39 ` [PATCH 03/14] powerpc/64s: idle move soft interrupt mask logic into C code Nicholas Piggin
2017-06-02 7:39 ` [PATCH 04/14] powerpc/64s: process interrupts from system reset wakeup Nicholas Piggin
2017-06-02 7:39 ` [PATCH 05/14] powerpc/64s: msgclr when handling doorbell exceptions Nicholas Piggin
2017-06-02 7:39 ` [PATCH 06/14] powerpc/64s: branch to idle handler with virtual mode offset Nicholas Piggin
2017-06-02 7:39 ` [PATCH 07/14] powerpc/64s: idle avoid SRR usage in idle sleep/wake paths Nicholas Piggin
2017-06-02 13:37 ` kbuild test robot
2017-06-02 7:39 ` [PATCH 08/14] powerpc/64s: idle set polling before enabling irqs Nicholas Piggin
2017-06-02 7:39 ` [PATCH 09/14] powerpc/64s: idle read mostly for common globals Nicholas Piggin
2017-06-02 7:39 ` [PATCH 10/14] powerpc/64: CTRL[RUN] run-latch setting optimisation Nicholas Piggin
2017-06-02 7:39 ` [PATCH 11/14] powerpc/64s: idle no memory barrier after break from idle Nicholas Piggin
2017-06-02 7:39 ` [PATCH 12/14] powerpc/64s: Leave IRQs hard enabled over context switch for radix Nicholas Piggin
2017-06-02 7:39 ` Nicholas Piggin [this message]
2017-06-02 7:39 ` [PATCH 14/14] powerpc/64: context switch additional hwsync can be avoided Nicholas Piggin
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=20170602073946.8983-14-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=anton@samba.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.