Skip to contentSkip to conversation

remove hardcoded offsets from ppc asm

PATCH In review Vincent Hanquez 2 participants 5 messages Aug 7, 2004 – Aug 8, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove hardcoded offsets from ppc asm

Hi LKML,

This patch removes hardcoded offsets from ppc asm.
It generate offsets for thread_info structure instead of hardcoding them.

Please apply or comments,

arch/ppc/kernel/asm-offsets.c +7 -0
diff -Naur linux-2.6.8-rc3.orig/arch/ppc/kernel/asm-offsets.c linux-2.6.8-rc3/arch/ppc/kernel/asm-offsets.c
@@ -129,6 +129,13 @@
 	DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features));
 	DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
 
+	DEFINE(TI_task, offsetof(struct thread_info, task));
+	DEFINE(TI_exec_domain, offsetof(struct thread_info, exec_domain));
+	DEFINE(TI_flags, offsetof(struct thread_info, flags));
+	DEFINE(TI_local_flags, offsetof(struct thread_info, local_flags));
+	DEFINE(TI_cpu, offsetof(struct thread_info, cpu));
+	DEFINE(TI_preempt_count, offsetof(struct thread_info, preempt_count));
+	
 	DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28);
 	return 0;
 }
arch/ppc/kernel/entry.S +14 -14
diff -Naur linux-2.6.8-rc3.orig/arch/ppc/kernel/entry.S linux-2.6.8-rc3/arch/ppc/kernel/entry.S
@@ -199,10 +199,10 @@
 	bl	do_show_syscall
 #endif /* SHOW_SYSCALLS */
 	rlwinm	r10,r1,0,0,18	/* current_thread_info() */
-	lwz	r11,TI_LOCAL_FLAGS(r10)
+	lwz	r11,TI_local_flags(r10)
 	rlwinm	r11,r11,0,~_TIFL_FORCE_NOERROR
-	stw	r11,TI_LOCAL_FLAGS(r10)
-	lwz	r11,TI_FLAGS(r10)
+	stw	r11,TI_local_flags(r10)
+	lwz	r11,TI_flags(r10)
 	andi.	r11,r11,_TIF_SYSCALL_TRACE
 	bne-	syscall_dotrace
 syscall_dotrace_cont:
@@ -225,7 +225,7 @@
 	cmpl	0,r3,r11
 	rlwinm	r12,r1,0,0,18	/* current_thread_info() */
 	blt+	30f
-	lwz	r11,TI_LOCAL_FLAGS(r12)
+	lwz	r11,TI_local_flags(r12)
 	andi.	r11,r11,_TIFL_FORCE_NOERROR
 	bne	30f
 	neg	r3,r3
@@ -237,7 +237,7 @@
 30:	LOAD_MSR_KERNEL(r10,MSR_KERNEL)	/* doesn't include MSR_EE */
 	SYNC
 	MTMSRD(r10)
-	lwz	r9,TI_FLAGS(r12)
+	lwz	r9,TI_flags(r12)
 	andi.	r0,r9,(_TIF_SYSCALL_TRACE|_TIF_SIGPENDING|_TIF_NEED_RESCHED)
 	bne-	syscall_exit_work
 syscall_exit_cont:
@@ -311,7 +311,7 @@
 	SYNC
 	MTMSRD(r10)		/* disable interrupts again */
 	rlwinm	r12,r1,0,0,18	/* current_thread_info() */
-	lwz	r9,TI_FLAGS(r12)
+	lwz	r9,TI_flags(r12)
 5:
 	andi.	r0,r9,_TIF_NEED_RESCHED
 	bne	1f
@@ -567,7 +567,7 @@
 sigreturn_exit:
 	subi	r1,r3,STACK_FRAME_OVERHEAD
 	rlwinm	r12,r1,0,0,18	/* current_thread_info() */
-	lwz	r9,TI_FLAGS(r12)
+	lwz	r9,TI_flags(r12)
 	andi.	r0,r9,_TIF_SYSCALL_TRACE
 	bnel-	do_syscall_trace
 	/* fall through */
@@ -593,7 +593,7 @@
 user_exc_return:		/* r10 contains MSR_KERNEL here */
 	/* Check current_thread_info()->flags */
 	rlwinm	r9,r1,0,0,18
-	lwz	r9,TI_FLAGS(r9)
+	lwz	r9,TI_flags(r9)
 	andi.	r0,r9,(_TIF_SIGPENDING|_TIF_NEED_RESCHED)
 	bne	do_work
 
@@ -612,16 +612,16 @@
 resume_kernel:
 	/* check current_thread_info->preempt_count */
 	rlwinm	r9,r1,0,0,18
-	lwz	r0,TI_PREEMPT(r9)
+	lwz	r0,TI_preempt_count(r9)
 	cmpwi	0,r0,0		/* if non-zero, just restore regs and return */
 	bne	restore
-	lwz	r0,TI_FLAGS(r9)
+	lwz	r0,TI_flags(r9)
 	andi.	r0,r0,_TIF_NEED_RESCHED
 	beq+	restore
 	andi.	r0,r3,MSR_EE	/* interrupts off? */
 	beq	restore		/* don't schedule if so */
 1:	lis	r0,PREEMPT_ACTIVE@h
-	stw	r0,TI_PREEMPT(r9)
+	stw	r0,TI_preempt_count(r9)
 	ori	r10,r10,MSR_EE
 	SYNC
 	MTMSRD(r10)		/* hard-enable interrupts */
@@ -631,8 +631,8 @@
 	MTMSRD(r10)		/* disable interrupts */
 	rlwinm	r9,r1,0,0,18
 	li	r0,0
-	stw	r0,TI_PREEMPT(r9)
-	lwz	r3,TI_FLAGS(r9)
+	stw	r0,TI_preempt_count(r9)
+	lwz	r3,TI_flags(r9)
 	andi.	r0,r3,_TIF_NEED_RESCHED
 	bne-	1b
 #else
@@ -913,7 +913,7 @@
 	SYNC
 	MTMSRD(r10)		/* disable interrupts */
 	rlwinm	r9,r1,0,0,18
-	lwz	r9,TI_FLAGS(r9)
+	lwz	r9,TI_flags(r9)
 	andi.	r0,r9,_TIF_NEED_RESCHED
 	bne-	do_resched
 	andi.	r0,r9,_TIF_SIGPENDING
arch/ppc/kernel/head.S +1 -1
diff -Naur linux-2.6.8-rc3.orig/arch/ppc/kernel/head.S linux-2.6.8-rc3/arch/ppc/kernel/head.S
@@ -1240,7 +1240,7 @@
 	tophys(r1,r1)
 	lwz	r1,secondary_ti@l(r1)
 	tophys(r2,r1)
-	lwz	r2,TI_TASK(r2)
+	lwz	r2,TI_task(r2)
 
 	/* stack */
 	addi	r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD
arch/ppc/kernel/idle_6xx.S +2 -2
diff -Naur linux-2.6.8-rc3.orig/arch/ppc/kernel/idle_6xx.S linux-2.6.8-rc3/arch/ppc/kernel/idle_6xx.S
@@ -94,7 +94,7 @@
 
 	/* Check current_thread_info()->flags */
 	rlwinm	r4,r1,0,0,18
-	lwz	r4,TI_FLAGS(r4)
+	lwz	r4,TI_flags(r4)
 	andi.	r0,r4,_TIF_NEED_RESCHED
 	beq	1f
 	mtmsr	r7	/* out of line this ? */
@@ -191,7 +191,7 @@
 	
 	rlwinm	r9,r1,0,0,18
 	tophys(r9,r9)
-	lwz	r11,TI_CPU(r9)
+	lwz	r11,TI_cpu(r9)
 	slwi	r11,r11,2
 	/* Todo make sure all these are in the same page
 	 * and load r22 (@ha part + CPU offset) only once
arch/ppc/kernel/idle_power4.S +1 -1
diff -Naur linux-2.6.8-rc3.orig/arch/ppc/kernel/idle_power4.S linux-2.6.8-rc3/arch/ppc/kernel/idle_power4.S
@@ -66,7 +66,7 @@
 
 	/* Check current_thread_info()->flags */
 	rlwinm	r4,r1,0,0,18
-	lwz	r4,TI_FLAGS(r4)
+	lwz	r4,TI_flags(r4)
 	andi.	r0,r4,_TIF_NEED_RESCHED
 	beq	1f
 	mtmsr	r7	/* out of line this ? */
arch/ppc/kernel/misc.S +3 -3
diff -Naur linux-2.6.8-rc3.orig/arch/ppc/kernel/misc.S linux-2.6.8-rc3/arch/ppc/kernel/misc.S
@@ -233,7 +233,7 @@
 
 	/* Store new HID1 image */
 	rlwinm	r6,r1,0,0,18
-	lwz	r6,TI_CPU(r6)
+	lwz	r6,TI_cpu(r6)
 	slwi	r6,r6,2
 	addis	r6,r6,nap_save_hid1@ha
 	stw	r4,nap_save_hid1@l(r6)
@@ -457,7 +457,7 @@
 #else /* !(CONFIG_40x || CONFIG_44x || CONFIG_FSL_BOOKE) */
 #if defined(CONFIG_SMP)
 	rlwinm	r8,r1,0,0,18
-	lwz	r8,TI_CPU(r8)
+	lwz	r8,TI_cpu(r8)
 	oris	r8,r8,10
 	mfmsr	r10
 	SYNC
@@ -538,7 +538,7 @@
 #else /* !(CONFIG_40x || CONFIG_44x || CONFIG_FSL_BOOKE) */
 #if defined(CONFIG_SMP)
 	rlwinm	r8,r1,0,0,18
-	lwz	r8,TI_CPU(r8)
+	lwz	r8,TI_cpu(r8)
 	oris	r8,r8,11
 	mfmsr	r10
 	SYNC
include/asm-ppc/thread_info.h +0 -10
diff -Naur linux-2.6.8-rc3.orig/include/asm-ppc/thread_info.h linux-2.6.8-rc3/include/asm-ppc/thread_info.h
@@ -65,16 +65,6 @@
  */
 #define THREAD_SIZE		8192	/* 2 pages */
 
-/*
- * Offsets in thread_info structure, used in assembly code
- */
-#define TI_TASK		0
-#define TI_EXECDOMAIN	4
-#define TI_FLAGS	8
-#define TI_LOCAL_FLAGS	12
-#define TI_CPU		16
-#define TI_PREEMPT	20
-
 #define PREEMPT_ACTIVE		0x4000000
 
 /*
#1 lore raw
Quoted 8 lines · Vincent Hanquez

Hi LKML,

This patch removes hardcoded offsets from ppc asm.
It generate offsets for thread_info structure instead of hardcoding them.

Please apply or comments,

I have nothing against the idea, but why the hell did you change the constant names, turning them partially to lowercase ? They are just fine beeing uppercase, this is more consistent, and that would reduce the size of your patch signficantly.

Ben.

#2 lore raw
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines · Vincent Hanquez

Hi LKML,

This patch removes hardcoded offsets from ppc asm.
It generate offsets for thread_info structure instead of hardcoding them.

Quoted 8 lines
Quoted 3 lines

Please apply or comments,

I have nothing against the idea, but why the hell did you change the constant names, turning them partially to lowercase ? They are just fine beeing uppercase, this is more consistent, and that would reduce the size of your patch signficantly.

Hi Benjamin, it seems to be the 'convention'. I did the same comment some time ago to Brian Gerst with his patch for i386.

http://marc.theaimsgroup.com/?l=linux-kernel&m=108454158825656&w=2

But if you prefer a smaller patch, without changing the constant name, I can do that too.

Sorry about the first set of patch, I didn't see your reply. I just saw it today on the archive.

Signature · 1 line
Tab
#3 lore raw
Quoted 7 lines · Vincent Hanquez

Hi Benjamin, it seems to be the 'convention'. I did the same comment some time ago to Brian Gerst with his patch for i386.

http://marc.theaimsgroup.com/?l=linux-kernel&m=108454158825656&w=2

But if you prefer a smaller patch, without changing the constant name, I can do that too.

I don't know about this "convention", we certainly don't apply it on ppc, I'd suggest doing the simpler patch instead.

Ben.

#4 lore raw
Quoted 5 lines · Benjamin Herrenschmidt
Quoted 3 lines · Vincent Hanquez

Hi Benjamin, it seems to be the 'convention'. I did the same comment some time ago to Brian Gerst with his patch for i386.

Quoted 7 lines
Quoted 4 lines

http://marc.theaimsgroup.com/?l=linux-kernel&m=108454158825656&w=2

But if you prefer a smaller patch, without changing the constant name, I can do that too.

I don't know about this "convention", we certainly don't apply it on ppc, I'd suggest doing the simpler patch instead.

ok thanks, here it is:

arch/ppc/kernel/asm-offsets.c +7 -0
diff -Naur linux-2.6.8-rc3.orig/arch/ppc/kernel/asm-offsets.c linux-2.6.8-rc3/arch/ppc/kernel/asm-offsets.c
@@ -129,6 +129,13 @@
 	DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features));
 	DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
 
+	DEFINE(TI_TASK, offsetof(struct thread_info, task));
+	DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));
+	DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
+	DEFINE(TI_LOCAL_FLAGS, offsetof(struct thread_info, local_flags));
+	DEFINE(TI_CPU, offsetof(struct thread_info, cpu));
+	DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
+	
 	DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28);
 	return 0;
 }
include/asm-ppc/thread_info.h +0 -10
diff -Naur linux-2.6.8-rc3.orig/include/asm-ppc/thread_info.h linux-2.6.8-rc3/include/asm-ppc/thread_info.h
@@ -65,16 +65,6 @@
  */
 #define THREAD_SIZE		8192	/* 2 pages */
 
-/*
- * Offsets in thread_info structure, used in assembly code
- */
-#define TI_TASK		0
-#define TI_EXECDOMAIN	4
-#define TI_FLAGS	8
-#define TI_LOCAL_FLAGS	12
-#define TI_CPU		16
-#define TI_PREEMPT	20
-
 #define PREEMPT_ACTIVE		0x4000000
 
 /*