Thread (23 messages) flat view 23 messages, 4 authors, 2017-11-22

Re: [PATCH v3 13/18] powerpc: Add support for setting SPRN_TIDR

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2017-11-09 11:53:08
Also in: lkml

Sukadev Bhattiprolu [off-list ref] writes:
quoted hunk ↗ jump to hunk
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 37ed60b..d861fcd 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1120,6 +1120,13 @@ static inline void restore_sprs(struct thread_struct *old_thread,
 			mtspr(SPRN_TAR, new_thread->tar);
 	}
 #endif
+#ifdef CONFIG_PPC64
+	if (old_thread->tidr != new_thread->tidr) {
+		/* TIDR should be non-zero only with ISA3.0. */
+		WARN_ON_ONCE(!cpu_has_feature(CPU_FTR_ARCH_300));
This is silly, just make the whole block depend on CPU_FTR_ARCH_300.

I've fixed it up.
quoted hunk ↗ jump to hunk
@@ -1466,6 +1581,10 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 
 	clear_task_ebb(dst);
 
+#ifdef CONFIG_PPC64
+	dst->thread.tidr = 0;
+#endif
+
 	return 0;
 }
This is called from clone().

quoted hunk ↗ jump to hunk
@@ -1576,6 +1695,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 #endif
 
 	setup_ksp_vsid(p, sp);
+#ifdef CONFIG_PPC64
+	p->thread.tidr = 0;
+#endif
  
And so is this.

So I think you only need the latter.

That does mean you're clearing the TIDR on fork(), but not exec().

Typically you'd do the reverse, ie. clear it on exec() but leave it the
same on fork().

Because this is a "thread id" I think it does make sense to clear it on
fork(), otherwise you potentially have two processes with the same id
and only one of them will be woken up by the AS_notify.

So I'll drop the clear from arch_dup_task_struct().

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help