2004-09-03 00:07:35

by Zwane Mwaikambo

[permalink] [raw]
Subject: [PATCH][6/8] Arch agnostic completely out of line locks / arm

arch/arm/kernel/time.c | 12 ++++++++++++
arch/arm/kernel/vmlinux.lds.S | 1 +
arch/arm/oprofile/op_model_xscale.c | 4 ++--
include/asm-arm/ptrace.h | 5 +++++
4 files changed, 20 insertions(+), 2 deletions(-)

Signed-off-by: Zwane Mwaikambo <[email protected]>

Index: linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/time.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.9-rc1-mm1/arch/arm/kernel/time.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 time.c
--- linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/time.c 26 Aug 2004 13:13:04 -0000 1.1.1.1
+++ linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/time.c 2 Sep 2004 15:51:37 -0000
@@ -52,6 +52,18 @@ EXPORT_SYMBOL(rtc_lock);
/* change this if you have some constant time drift */
#define USECS_PER_JIFFY (1000000/HZ)

+#ifdef CONFIG_SMP
+unsigned long profile_pc(struct pt_regs *regs)
+{
+ unsigned long pc = instruction_pointer(regs);
+
+ if (pc >= (unsigned long)&__lock_text_start &&
+ pc <= (unsigned long)&__lock_text_end)
+ return regs->ARM_lr;
+ return pc;
+}
+EXPORT_SYMBOL(profile_pc);
+#endif

/*
* hook for setting the RTC's idea of the current time.
Index: linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/vmlinux.lds.S
===================================================================
RCS file: /home/cvsroot/linux-2.6.9-rc1-mm1/arch/arm/kernel/vmlinux.lds.S,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 vmlinux.lds.S
--- linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/vmlinux.lds.S 26 Aug 2004 13:13:04 -0000 1.1.1.1
+++ linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/vmlinux.lds.S 2 Sep 2004 13:08:12 -0000
@@ -71,6 +71,7 @@ SECTIONS
_text = .; /* Text and read-only data */
*(.text)
SCHED_TEXT
+ LOCK_TEXT
*(.fixup)
*(.gnu.warning)
*(.rodata)
Index: linux-2.6.9-rc1-mm1-stage/arch/arm/oprofile/op_model_xscale.c
===================================================================
RCS file: /home/cvsroot/linux-2.6.9-rc1-mm1/arch/arm/oprofile/op_model_xscale.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 op_model_xscale.c
--- linux-2.6.9-rc1-mm1-stage/arch/arm/oprofile/op_model_xscale.c 26 Aug 2004 13:13:05 -0000 1.1.1.1
+++ linux-2.6.9-rc1-mm1-stage/arch/arm/oprofile/op_model_xscale.c 2 Sep 2004 15:52:39 -0000
@@ -343,7 +343,7 @@ static void inline __xsc2_check_ctrs(voi

static irqreturn_t xscale_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
{
- unsigned long eip = instruction_pointer(regs);
+ unsigned long pc = profile_pc(regs);
int i, is_kernel = !user_mode(regs);
u32 pmnc;

@@ -357,7 +357,7 @@ static irqreturn_t xscale_pmu_interrupt(
continue;

write_counter(i, -(u32)results[i].reset_counter);
- oprofile_add_sample(eip, is_kernel, i, smp_processor_id());
+ oprofile_add_sample(pc, is_kernel, i, smp_processor_id());
results[i].ovf--;
}

Index: linux-2.6.9-rc1-mm1-stage/include/asm-arm/ptrace.h
===================================================================
RCS file: /home/cvsroot/linux-2.6.9-rc1-mm1/include/asm-arm/ptrace.h,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 ptrace.h
--- linux-2.6.9-rc1-mm1-stage/include/asm-arm/ptrace.h 26 Aug 2004 13:13:12 -0000 1.1.1.1
+++ linux-2.6.9-rc1-mm1-stage/include/asm-arm/ptrace.h 2 Sep 2004 13:08:15 -0000
@@ -130,7 +130,12 @@ static inline int valid_user_regs(struct

#define instruction_pointer(regs) \
(pc_pointer((regs)->ARM_pc))
+
+#ifdef CONFIG_SMP
+extern unsigned long profile_pc(struct pt_regs *regs);
+#else
#define profile_pc(regs) instruction_pointer(regs)
+#endif

#ifdef __KERNEL__
extern void show_regs(struct pt_regs *);


2004-09-03 09:09:58

by Russell King

[permalink] [raw]
Subject: Re: [PATCH][6/8] Arch agnostic completely out of line locks / arm

On Thu, Sep 02, 2004 at 08:02:55PM -0400, Zwane Mwaikambo wrote:
> --- linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/time.c 26 Aug 2004 13:13:04 -0000 1.1.1.1
> +++ linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/time.c 2 Sep 2004 15:51:37 -0000
> @@ -52,6 +52,18 @@ EXPORT_SYMBOL(rtc_lock);
> /* change this if you have some constant time drift */
> #define USECS_PER_JIFFY (1000000/HZ)
>
> +#ifdef CONFIG_SMP
> +unsigned long profile_pc(struct pt_regs *regs)
> +{
> + unsigned long pc = instruction_pointer(regs);
> +
> + if (pc >= (unsigned long)&__lock_text_start &&
> + pc <= (unsigned long)&__lock_text_end)
> + return regs->ARM_lr;
> + return pc;
> +}
> +EXPORT_SYMBOL(profile_pc);
> +#endif

Looks good apart from this. There's no guarantee that LR will be the
return address inside one of these lock functions - indeed the compiler
may have saved it onto the stack and decided to use the register for
something else.

Your best bet is to look at the get_wchan() code which walks the stack
frames (if present.)

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core

2004-09-03 12:05:19

by Zwane Mwaikambo

[permalink] [raw]
Subject: Re: [PATCH][6/8] Arch agnostic completely out of line locks / arm

On Fri, 3 Sep 2004, Russell King wrote:

> On Thu, Sep 02, 2004 at 08:02:55PM -0400, Zwane Mwaikambo wrote:
> > --- linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/time.c 26 Aug 2004 13:13:04 -0000 1.1.1.1
> > +++ linux-2.6.9-rc1-mm1-stage/arch/arm/kernel/time.c 2 Sep 2004 15:51:37 -0000
> > @@ -52,6 +52,18 @@ EXPORT_SYMBOL(rtc_lock);
> > /* change this if you have some constant time drift */
> > #define USECS_PER_JIFFY (1000000/HZ)
> >
> > +#ifdef CONFIG_SMP
> > +unsigned long profile_pc(struct pt_regs *regs)
> > +{
> > + unsigned long pc = instruction_pointer(regs);
> > +
> > + if (pc >= (unsigned long)&__lock_text_start &&
> > + pc <= (unsigned long)&__lock_text_end)
> > + return regs->ARM_lr;
> > + return pc;
> > +}
> > +EXPORT_SYMBOL(profile_pc);
> > +#endif
>
> Looks good apart from this. There's no guarantee that LR will be the
> return address inside one of these lock functions - indeed the compiler
> may have saved it onto the stack and decided to use the register for
> something else.
>
> Your best bet is to look at the get_wchan() code which walks the stack
> frames (if present.)

Thanks, i'll change it in the followup.

Zwane