From: Michael Neuling <mikey@neuling.org>
To: mpe@ellerman.id.au, benh@kernel.crashing.org
Cc: linuxppc-dev@ozlabs.org, anton@samba.org, Cyril Bur <cyrilbur@gmail.com>
Subject: [PATCH v2 2/2] powerpc: Copy only required pieces of the mm_context_t to the paca
Date: Thu, 10 Dec 2015 14:46:51 +1100 [thread overview]
Message-ID: <1449719211.29188.5.camel@neuling.org> (raw)
In-Reply-To: <1446008047-2393-2-git-send-email-mikey@neuling.org>
Currently we copy the whole mm_context_t to the paca but only access a
few bits of it. This is wasteful of space paca and also takes quite
some time in the hot path of context switching.
This patch pulls in only the required bits from the mm_context_t to
the paca and on context switch, copies only those.
Benchmarking this (On top of Anton's recent MSR context switching
changes [1]) using processes and yield shows an improvement of almost
3% on POWER8:
http://ozlabs.org/~anton/junkcode/context_switch2.c
./context_switch2 --test=3Dyield --process 0 0
1. https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-October/135700.
html
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
v2:
Added missing include which broke allmodconfig (noticed by anton)
include/asm/paca.h | 18 ++++++++++++++++--
kernel/asm-offsets.c | 8 ++++----
mm/hash_utils_64.c | 4 ++--
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/include/asm/paca.h
b/arch/powerpc/include/asm/paca.h
index 1cc6e08..06cdaee 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -16,6 +16,7 @@
=20
#ifdef CONFIG_PPC64
=20
+#include <linux/string.h>
#include <asm/types.h>
#include <asm/lppaca.h>
#include <asm/mmu.h>
@@ -132,7 +133,13 @@ struct paca_struct {
#endif /* CONFIG_PPC_BOOK3E */
=20
#ifdef CONFIG_PPC_BOOK3S
- mm_context_t context;
+ mm_context_id_t context_id;
+#ifdef CONFIG_PPC_MM_SLICES
+ u64 context_low_slices_psize;
+ unsigned char context_high_slices_psize[SLICE_ARRAY_SIZE];
+#else
+ u16 context_sllp;
+#endif
#endif
=20
/*
@@ -199,7 +206,14 @@ struct paca_struct {
#ifdef CONFIG_PPC_BOOK3S
static inline void copy_mm_to_paca(mm_context_t *context)
{
- get_paca()->context =3D *context;
+ get_paca()->context_id =3D context->id;
+#ifdef CONFIG_PPC_MM_SLICES
+ get_paca()->context_low_slices_psize =3D context
->low_slices_psize;
+ memcpy(&get_paca()->context_high_slices_psize,
+ &context->high_slices_psize, SLICE_ARRAY_SIZE);
+#else
+ get_paca()->context_sllp =3D context->sllp;
+#endif
}
#else
static inline void copy_mm_to_paca(mm_context_t *context){}
diff --git a/arch/powerpc/kernel/asm-offsets.c
b/arch/powerpc/kernel/asm-offsets.c
index 9db7be2..d5903a9 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -186,12 +186,12 @@ int main(void)
DEFINE(PACASOFTIRQEN, offsetof(struct paca_struct,
soft_enabled));
DEFINE(PACAIRQHAPPENED, offsetof(struct paca_struct,
irq_happened));
#ifdef CONFIG_PPC_BOOK3S
- DEFINE(PACACONTEXTID, offsetof(struct paca_struct,
context.id));
+ DEFINE(PACACONTEXTID, offsetof(struct paca_struct,
context_id));
#ifdef CONFIG_PPC_MM_SLICES
DEFINE(PACALOWSLICESPSIZE, offsetof(struct paca_struct,
- =20
context.low_slices_psize));
+ =20
context_low_slices_psize));
DEFINE(PACAHIGHSLICEPSIZE, offsetof(struct paca_struct,
- =20
context.high_slices_psize));
+ =20
context_high_slices_psize));
DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def));
#endif /* CONFIG_PPC_MM_SLICES */
#endif
@@ -224,7 +224,7 @@ int main(void)
#ifdef CONFIG_PPC_MM_SLICES
DEFINE(MMUPSIZESLLP, offsetof(struct mmu_psize_def, sllp));
#else
- DEFINE(PACACONTEXTSLLP, offsetof(struct paca_struct,
context.sllp));
+ DEFINE(PACACONTEXTSLLP, offsetof(struct paca_struct,
context_sllp));
#endif /* CONFIG_PPC_MM_SLICES */
DEFINE(PACA_EXGEN, offsetof(struct paca_struct, exgen));
DEFINE(PACA_EXMC, offsetof(struct paca_struct, exmc));
diff --git a/arch/powerpc/mm/hash_utils_64.c
b/arch/powerpc/mm/hash_utils_64.c
index 0aa526e..ae98d58 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -877,11 +877,11 @@ static unsigned int get_paca_psize(unsigned long
addr)
unsigned long index, mask_index;
=20
if (addr < SLICE_LOW_TOP) {
- lpsizes =3D get_paca()->context.low_slices_psize;
+ lpsizes =3D get_paca()->context_low_slices_psize;
index =3D GET_LOW_SLICE_INDEX(addr);
return (lpsizes >> (index * 4)) & 0xF;
}
- hpsizes =3D get_paca()->context.high_slices_psize;
+ hpsizes =3D get_paca()->context_high_slices_psize;
index =3D GET_HIGH_SLICE_INDEX(addr);
mask_index =3D index & 0x1;
return (hpsizes[index >> 1] >> (mask_index * 4)) & 0xF;
next prev parent reply other threads:[~2015-12-10 3:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-28 4:54 [PATCH 1/2] powerpc: Add function to copy mm_context_t to the paca Michael Neuling
2015-10-28 4:54 ` [PATCH 2/2] powerpc: Copy only required pieces of the " Michael Neuling
2015-12-09 12:17 ` Anton Blanchard
2015-12-10 3:46 ` Michael Neuling [this message]
2015-12-10 10:00 ` [PATCH v2 " Michael Ellerman
2015-12-10 22:34 ` [PATCH v3 " Michael Neuling
2016-01-11 9:14 ` [v3, " Michael Ellerman
2016-01-11 9:14 ` [1/2] powerpc: Add function to copy " Michael Ellerman
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=1449719211.29188.5.camel@neuling.org \
--to=mikey@neuling.org \
--cc=anton@samba.org \
--cc=benh@kernel.crashing.org \
--cc=cyrilbur@gmail.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mpe@ellerman.id.au \
/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;
as well as URLs for NNTP newsgroup(s).