Re: [PATCH v16 19/21] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU

2019-02-06 Thread Nicholas Piggin
Nicholas Piggin's on February 7, 2019 2:27 pm:
> Michael Ellerman's on February 5, 2019 9:32 pm:
>> From: Christophe Leroy 
>> 
>> Now that thread_info is similar to task_struct, its address is in r2
>> so CURRENT_THREAD_INFO() macro is useless. This patch removes it.
> 
> You wouldn't want to keep CURRENT_THREAD_INFO(r2) to mean get the thread 
> info out of current, as just a no-op for documentation purpose? I don't 
> know /32 code at all so it's up to you.

I see that I said roughly the opposite last year, if that helps to 
determine the importance of my opinion.

Thanks,
Nick



Re: [PATCH v16 19/21] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU

2019-02-06 Thread Nicholas Piggin
Michael Ellerman's on February 5, 2019 9:32 pm:
> From: Christophe Leroy 
> 
> Now that thread_info is similar to task_struct, its address is in r2
> so CURRENT_THREAD_INFO() macro is useless. This patch removes it.

You wouldn't want to keep CURRENT_THREAD_INFO(r2) to mean get the thread 
info out of current, as just a no-op for documentation purpose? I don't 
know /32 code at all so it's up to you.

> This patch also moves the 'tovirt(r2, r2)' down just before the
> reactivation of MMU translation, so that we keep the physical address
> of 'current' in r2 until then. It avoids a few calls to tophys().
> 
> At the same time, as the 'cpu' field is not anymore in thread_info,
> TI_CPU is renamed TASK_CPU by this patch.
> 
> It also allows to get rid of a couple of
> '#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE' as ACCOUNT_CPU_USER_ENTRY()
> and ACCOUNT_CPU_USER_EXIT() are empty when
> CONFIG_VIRT_CPU_ACCOUNTING_NATIVE is not defined.

May want to split these a little more?



Re: [PATCH v16 19/21] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU

2019-02-06 Thread Michael Ellerman
Michael Ellerman  writes:

> diff --git a/arch/powerpc/kernel/idle_6xx.S b/arch/powerpc/kernel/idle_6xx.S
> index d9b6e7e0b5e3..5e69fefcd9c4 100644
> --- a/arch/powerpc/kernel/idle_6xx.S
> +++ b/arch/powerpc/kernel/idle_6xx.S
> @@ -159,9 +158,7 @@ _GLOBAL(power_save_ppc32_restore)
>   stw r9,_NIP(r11)/* make it do a blr */
>  
>  #ifdef CONFIG_SMP
> - CURRENT_THREAD_INFO(r12, r1)
> - tophys(r12, r12)
> - lwz r11,TI_CPU(r12) /* get cpu number * 4 */
> + lwz r11,TI_CPU(r2)  /* get cpu number * 4 */
^
missed conversion to TASK_CPU here. I've fixed it up.

cheers


[PATCH v16 19/21] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU

2019-02-05 Thread Michael Ellerman
From: Christophe Leroy 

Now that thread_info is similar to task_struct, its address is in r2
so CURRENT_THREAD_INFO() macro is useless. This patch removes it.

This patch also moves the 'tovirt(r2, r2)' down just before the
reactivation of MMU translation, so that we keep the physical address
of 'current' in r2 until then. It avoids a few calls to tophys().

At the same time, as the 'cpu' field is not anymore in thread_info,
TI_CPU is renamed TASK_CPU by this patch.

It also allows to get rid of a couple of
'#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE' as ACCOUNT_CPU_USER_ENTRY()
and ACCOUNT_CPU_USER_EXIT() are empty when
CONFIG_VIRT_CPU_ACCOUNTING_NATIVE is not defined.

Signed-off-by: Christophe Leroy 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/Makefile  |  2 +-
 arch/powerpc/include/asm/thread_info.h |  2 -
 arch/powerpc/kernel/asm-offsets.c  |  2 +-
 arch/powerpc/kernel/entry_32.S | 55 +-
 arch/powerpc/kernel/epapr_hcalls.S |  5 +--
 arch/powerpc/kernel/head_fsl_booke.S   |  5 +--
 arch/powerpc/kernel/idle_6xx.S |  9 ++---
 arch/powerpc/kernel/idle_e500.S|  8 ++--
 arch/powerpc/kernel/misc_32.S  |  3 +-
 arch/powerpc/mm/hash_low_32.S  | 14 +++
 arch/powerpc/sysdev/6xx-suspend.S  |  5 +--
 11 files changed, 38 insertions(+), 72 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 53ffe935f3b0..7de49889bd5d 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -431,7 +431,7 @@ ifdef CONFIG_SMP
 prepare: task_cpu_prepare
 
 task_cpu_prepare: prepare0
-   $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TI_CPU") 
print $$3;}' include/generated/asm-offsets.h))
+   $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == 
"TASK_CPU") print $$3;}' include/generated/asm-offsets.h))
 endif
 
 # Check toolchain versions:
diff --git a/arch/powerpc/include/asm/thread_info.h 
b/arch/powerpc/include/asm/thread_info.h
index d91523c2c7d8..c959b8d66cac 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -19,8 +19,6 @@
 
 #ifdef CONFIG_PPC64
 #define CURRENT_THREAD_INFO(dest, sp)  stringify_in_c(ld dest, 
PACACURRENT(r13))
-#else
-#define CURRENT_THREAD_INFO(dest, sp)  stringify_in_c(mr dest, r2)
 #endif
 
 #ifndef __ASSEMBLY__
diff --git a/arch/powerpc/kernel/asm-offsets.c 
b/arch/powerpc/kernel/asm-offsets.c
index 94ac190a0b16..03439785c2ea 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -96,7 +96,7 @@ int main(void)
 #endif /* CONFIG_PPC64 */
OFFSET(TASK_STACK, task_struct, stack);
 #ifdef CONFIG_SMP
-   OFFSET(TI_CPU, task_struct, cpu);
+   OFFSET(TASK_CPU, task_struct, cpu);
 #endif
 
 #ifdef CONFIG_LIVEPATCH
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index aea22c7b891f..a5e2d5585dcb 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -151,7 +151,6 @@
stw r2,_XER(r11)
mfspr   r12,SPRN_SPRG_THREAD
addir2,r12,-THREAD
-   tovirt(r2,r2)   /* set r2 to current */
beq 2f  /* if from user, fix up THREAD.regs */
addir11,r1,STACK_FRAME_OVERHEAD
stw r11,PT_REGS(r12)
@@ -161,11 +160,7 @@
lwz r12,THREAD_DBCR0(r12)
andis.  r12,r12,DBCR0_IDM@h
 #endif
-#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-   CURRENT_THREAD_INFO(r9, r1)
-   tophys(r9, r9)
-   ACCOUNT_CPU_USER_ENTRY(r9, r11, r12)
-#endif
+   ACCOUNT_CPU_USER_ENTRY(r2, r11, r12)
 #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
beq+3f
/* From user and task is ptraced - load up global dbcr0 */
@@ -175,8 +170,7 @@
tophys(r11,r11)
addir11,r11,global_dbcr0@l
 #ifdef CONFIG_SMP
-   CURRENT_THREAD_INFO(r9, r1)
-   lwz r9,TI_CPU(r9)
+   lwz r9,TASK_CPU(r2)
slwir9,r9,3
add r11,r11,r9
 #endif
@@ -197,9 +191,7 @@
ble-stack_ovf   /* then the kernel stack overflowed */
 5:
 #if defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500)
-   CURRENT_THREAD_INFO(r9, r1)
-   tophys(r9,r9)   /* check local flags */
-   lwz r12,TI_LOCAL_FLAGS(r9)
+   lwz r12,TI_LOCAL_FLAGS(r2)
mtcrf   0x01,r12
bt- 31-TLF_NAPPING,4f
bt- 31-TLF_SLEEPING,7f
@@ -208,6 +200,7 @@
 transfer_to_handler_cont:
 3:
mflrr9
+   tovirt(r2, r2)  /* set r2 to current */
lwz r11,0(r9)   /* virtual address of handler */
lwz r9,4(r9)/* where to go when done */
 #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS)
@@ -271,11 +264,11 @@ reenable_mmu: /* re-enable 
mmu so we can */
 
 #if defined (CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500)
 4: rlwinm