* [PATCH 4/6] powerpc: Define ppr in thread_struct
@ 2012-10-31 6:55 Haren Myneni
2012-11-23 3:21 ` Michael Neuling
0 siblings, 1 reply; 3+ messages in thread
From: Haren Myneni @ 2012-10-31 6:55 UTC (permalink / raw)
To: benh, paulus, anton, mikey; +Cc: linuxppc-dev
[PATCH 4/6] powerpc: Define ppr in thread_struct
ppr in thread_struct is used to save PPR and restore it before process exits
from kernel.
This patch sets the default priority to 3 when tasks are created such
that users can use 4 for higher priority tasks.
Signed-off-by: Haren Myneni <haren@us.ibm.com>
---
arch/powerpc/include/asm/processor.h | 6 ++++++
arch/powerpc/kernel/asm-offsets.c | 1 +
arch/powerpc/kernel/process.c | 2 ++
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 8750204..7db5df4 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -245,6 +245,7 @@ struct thread_struct {
#ifdef CONFIG_PPC64
unsigned long dscr;
int dscr_inherit;
+ unsigned long ppr;
#endif
};
@@ -270,6 +271,10 @@ struct thread_struct {
SPEFSCR_INIT \
}
#else
+/* Default SMT priority is 3. Use 11- 13bits to save priority. */
+/* .ppr is used to save/restore only on P7 or later processors */
+#define INIT_PPR (3ull << 50)
+
#define INIT_THREAD { \
.ksp = INIT_SP, \
.ksp_limit = INIT_SP_LIMIT, \
@@ -278,6 +283,7 @@ struct thread_struct {
.fpr = {{0}}, \
.fpscr = { .val = 0, }, \
.fpexc_mode = 0, \
+ .ppr = INIT_PPR, \
}
#endif
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 7523539..41f65ec 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -77,6 +77,7 @@ int main(void)
DEFINE(NMI_MASK, NMI_MASK);
DEFINE(THREAD_DSCR, offsetof(struct thread_struct, dscr));
DEFINE(THREAD_DSCR_INHERIT, offsetof(struct thread_struct, dscr_inherit));
+ DEFINE(TASKTHREADPPR, offsetof(struct task_struct, thread.ppr));
#else
DEFINE(THREAD_INFO, offsetof(struct task_struct, stack));
#endif /* CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index ba48233..2563acc 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -814,6 +814,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
p->thread.dscr_inherit = current->thread.dscr_inherit;
p->thread.dscr = current->thread.dscr;
}
+ if (cpu_has_feature(CPU_FTR_HAS_PPR))
+ p->thread.ppr = INIT_PPR;
#endif
/*
* The PPC64 ABI makes use of a TOC to contain function
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4/6] powerpc: Define ppr in thread_struct
2012-10-31 6:55 [PATCH 4/6] powerpc: Define ppr in thread_struct Haren Myneni
@ 2012-11-23 3:21 ` Michael Neuling
0 siblings, 0 replies; 3+ messages in thread
From: Michael Neuling @ 2012-11-23 3:21 UTC (permalink / raw)
To: Haren Myneni; +Cc: anton, paulus, linuxppc-dev
Haren Myneni <haren@linux.vnet.ibm.com> wrote:
> [PATCH 4/6] powerpc: Define ppr in thread_struct
>
> ppr in thread_struct is used to save PPR and restore it before process exits
> from kernel.
>
> This patch sets the default priority to 3 when tasks are created such
> that users can use 4 for higher priority tasks.
>
> Signed-off-by: Haren Myneni <haren@us.ibm.com>
> ---
> arch/powerpc/include/asm/processor.h | 6 ++++++
> arch/powerpc/kernel/asm-offsets.c | 1 +
> arch/powerpc/kernel/process.c | 2 ++
> 3 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
> index 8750204..7db5df4 100644
> --- a/arch/powerpc/include/asm/processor.h
> +++ b/arch/powerpc/include/asm/processor.h
> @@ -245,6 +245,7 @@ struct thread_struct {
> #ifdef CONFIG_PPC64
> unsigned long dscr;
> int dscr_inherit;
> + unsigned long ppr;
> #endif
> };
>
> @@ -270,6 +271,10 @@ struct thread_struct {
> SPEFSCR_INIT \
> }
> #else
> +/* Default SMT priority is 3. Use 11- 13bits to save priority. */
> +/* .ppr is used to save/restore only on P7 or later processors */
> +#define INIT_PPR (3ull << 50)
Can you split this into two macros so that we can use the '3' elsewhere.
Like in patch 5, you do this:
+ lis ra,0xc; /* default ppr=3 */ \
where you could reuse the '3' so that we don't have to change it in two
places later.
Mikey
> +
> #define INIT_THREAD { \
> .ksp = INIT_SP, \
> .ksp_limit = INIT_SP_LIMIT, \
> @@ -278,6 +283,7 @@ struct thread_struct {
> .fpr = {{0}}, \
> .fpscr = { .val = 0, }, \
> .fpexc_mode = 0, \
> + .ppr = INIT_PPR, \
> }
> #endif
>
> diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
> index 7523539..41f65ec 100644
> --- a/arch/powerpc/kernel/asm-offsets.c
> +++ b/arch/powerpc/kernel/asm-offsets.c
> @@ -77,6 +77,7 @@ int main(void)
> DEFINE(NMI_MASK, NMI_MASK);
> DEFINE(THREAD_DSCR, offsetof(struct thread_struct, dscr));
> DEFINE(THREAD_DSCR_INHERIT, offsetof(struct thread_struct, dscr_inherit));
> + DEFINE(TASKTHREADPPR, offsetof(struct task_struct, thread.ppr));
> #else
> DEFINE(THREAD_INFO, offsetof(struct task_struct, stack));
> #endif /* CONFIG_PPC64 */
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index ba48233..2563acc 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -814,6 +814,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
> p->thread.dscr_inherit = current->thread.dscr_inherit;
> p->thread.dscr = current->thread.dscr;
> }
> + if (cpu_has_feature(CPU_FTR_HAS_PPR))
> + p->thread.ppr = INIT_PPR;
> #endif
> /*
> * The PPC64 ABI makes use of a TOC to contain function
> --
> 1.7.1
>
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 4/6] powerpc: Define ppr in thread_struct
@ 2012-12-07 7:49 Haren Myneni
0 siblings, 0 replies; 3+ messages in thread
From: Haren Myneni @ 2012-12-07 7:49 UTC (permalink / raw)
To: benh, paulus, anton, michael.neuling, linuxppc-dev
[PATCH 4/6] powerpc: Define ppr in thread_struct
ppr in thread_struct is used to save PPR and restore it before process exits
from kernel.
This patch sets the default priority to 3 when tasks are created such
that users can use 4 for higher priority tasks.
Signed-off-by: Haren Myneni <haren@us.ibm.com>
---
arch/powerpc/include/asm/processor.h | 12 ++++++++++++
arch/powerpc/kernel/asm-offsets.c | 1 +
arch/powerpc/kernel/process.c | 2 ++
3 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 8750204..37f87f0 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -18,6 +18,16 @@
#define TS_FPRWIDTH 1
#endif
+#ifdef CONFIG_PPC64
+/* Default SMT priority is set to 3. Use 11- 13bits to save priority. */
+#define PPR_PRIORITY 3
+#ifdef __ASSEMBLY__
+#define INIT_PPR (PPR_PRIORITY << 50)
+#else
+#define INIT_PPR ((u64)PPR_PRIORITY << 50)
+#endif /* __ASSEMBLY__ */
+#endif /* CONFIG_PPC64 */
+
#ifndef __ASSEMBLY__
#include <linux/compiler.h>
#include <linux/cache.h>
@@ -245,6 +255,7 @@ struct thread_struct {
#ifdef CONFIG_PPC64
unsigned long dscr;
int dscr_inherit;
+ unsigned long ppr; /* used to save/restore SMT priority */
#endif
};
@@ -278,6 +289,7 @@ struct thread_struct {
.fpr = {{0}}, \
.fpscr = { .val = 0, }, \
.fpexc_mode = 0, \
+ .ppr = INIT_PPR, \
}
#endif
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 7523539..41f65ec 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -77,6 +77,7 @@ int main(void)
DEFINE(NMI_MASK, NMI_MASK);
DEFINE(THREAD_DSCR, offsetof(struct thread_struct, dscr));
DEFINE(THREAD_DSCR_INHERIT, offsetof(struct thread_struct, dscr_inherit));
+ DEFINE(TASKTHREADPPR, offsetof(struct task_struct, thread.ppr));
#else
DEFINE(THREAD_INFO, offsetof(struct task_struct, stack));
#endif /* CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index ba48233..2563acc 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -814,6 +814,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
p->thread.dscr_inherit = current->thread.dscr_inherit;
p->thread.dscr = current->thread.dscr;
}
+ if (cpu_has_feature(CPU_FTR_HAS_PPR))
+ p->thread.ppr = INIT_PPR;
#endif
/*
* The PPC64 ABI makes use of a TOC to contain function
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-07 7:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-31 6:55 [PATCH 4/6] powerpc: Define ppr in thread_struct Haren Myneni
2012-11-23 3:21 ` Michael Neuling
2012-12-07 7:49 Haren Myneni
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).