Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] oprofile cleanups
@ 2006-02-16 14:45 Atsushi Nemoto
  2006-03-24  4:18 ` Atsushi Nemoto
  0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2006-02-16 14:45 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

1. Use CONFIG_OPROFILE to get rid of overhead for null_perf_irq() call.
2. Call perf_irq from timer_interrupt instead of ll_timer_interrupt.
   Most (non-SMP) boards will use timer_interrupt (instead of
   ll_timer_interrupt), so it would be better to move calling of
   perf_irq() to timer_interrupt().
3. Use jiffies instead of local timer_tick_count.

I can not test it by myself for now while I do not have any
MIPS32/MIPS64 board.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 7050b4f..7b5c5b9 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -414,6 +414,18 @@ void local_timer_interrupt(int irq, void
 	update_process_times(user_mode(regs));
 }
 
+#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE)
+int null_perf_irq(struct pt_regs *regs)
+{
+	return 0;
+}
+
+int (*perf_irq)(struct pt_regs *regs) = null_perf_irq;
+
+EXPORT_SYMBOL(null_perf_irq);
+EXPORT_SYMBOL(perf_irq);
+#endif
+
 /*
  * High-level timer interrupt service routines.  This function
  * is set as irqaction->handler and is invoked through do_IRQ.
@@ -422,6 +434,22 @@ irqreturn_t timer_interrupt(int irq, voi
 {
 	unsigned long j;
 	unsigned int count;
+#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE)
+	int r2 = cpu_has_mips_r2;
+
+	/*
+	 * Suckage alert:
+	 * Before R2 of the architecture there was no way to see if a
+	 * performance counter interrupt was pending, so we have to run the
+	 * performance counter interrupt handler anyway.
+	 */
+	if (!r2 || (read_c0_cause() & (1 << 26)))
+		if (perf_irq(regs))
+			return IRQ_HANDLED;
+
+	if (r2 && !(read_c0_cause() & (1 << 30)))
+		return IRQ_HANDLED;
+#endif
 
 	count = mips_hpt_read();
 	mips_timer_ack();
@@ -507,38 +535,14 @@ irqreturn_t timer_interrupt(int irq, voi
 	return IRQ_HANDLED;
 }
 
-int null_perf_irq(struct pt_regs *regs)
-{
-	return 0;
-}
-
-int (*perf_irq)(struct pt_regs *regs) = null_perf_irq;
-
-EXPORT_SYMBOL(null_perf_irq);
-EXPORT_SYMBOL(perf_irq);
-
 asmlinkage void ll_timer_interrupt(int irq, struct pt_regs *regs)
 {
-	int r2 = cpu_has_mips_r2;
-
 	irq_enter();
 	kstat_this_cpu.irqs[irq]++;
 
-	/*
-	 * Suckage alert:
-	 * Before R2 of the architecture there was no way to see if a
-	 * performance counter interrupt was pending, so we have to run the
-	 * performance counter interrupt handler anyway.
-	 */
-	if (!r2 || (read_c0_cause() & (1 << 26)))
-		if (perf_irq(regs))
-			goto out;
-
 	/* we keep interrupt disabled all the time */
-	if (!r2 || (read_c0_cause() & (1 << 30)))
-		timer_interrupt(irq, NULL, regs);
+	timer_interrupt(irq, NULL, regs);
 
-out:
 	irq_exit();
 }
 
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index 93f3bf2..f9471de 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -58,12 +58,11 @@ static char display_string[] = "        
 static unsigned int display_count = 0;
 #define MAX_DISPLAY_COUNT (sizeof(display_string) - 8)
 
-static unsigned int timer_tick_count=0;
 static int mips_cpu_timer_irq;
 
 static inline void scroll_display_message(void)
 {
-	if ((timer_tick_count++ % HZ) == 0) {
+	if ((jiffies % HZ) == 0) {
 		mips_display_message(&display_string[display_count++]);
 		if (display_count == MAX_DISPLAY_COUNT)
 			display_count = 0;
@@ -75,13 +74,8 @@ static void mips_timer_dispatch (struct 
 	do_IRQ (mips_cpu_timer_irq, regs);
 }
 
-extern int null_perf_irq(struct pt_regs *regs);
-
-extern int (*perf_irq)(struct pt_regs *regs);
-
 irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	int r2 = cpu_has_mips_r2;
 	int cpu = smp_processor_id();
 
 	if (cpu == 0) {
@@ -90,13 +84,7 @@ irqreturn_t mips_timer_interrupt(int irq
 		 * accounting resets count/compare registers to trigger next
 		 * timer int.
 		 */
-		if (!r2 || (read_c0_cause() & (1 << 26)))
-			if (perf_irq(regs))
-				goto out;
-
-		/* we keep interrupt disabled all the time */
-		if (!r2 || (read_c0_cause() & (1 << 30)))
-			timer_interrupt(irq, NULL, regs);
+		timer_interrupt(irq, NULL, regs);
 
 		scroll_display_message();
 	} else {
@@ -114,7 +102,6 @@ irqreturn_t mips_timer_interrupt(int irq
 		local_timer_interrupt (irq, dev_id, regs);
 	}
 
-out:
 	return IRQ_HANDLED;
 }
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] oprofile cleanups
  2006-02-16 14:45 [PATCH] oprofile cleanups Atsushi Nemoto
@ 2006-03-24  4:18 ` Atsushi Nemoto
  2006-03-24  7:07   ` compilartion error : label at end of compound statement Gowri Satish Adimulam
  2006-04-25 15:01   ` [PATCH] oprofile cleanups Atsushi Nemoto
  0 siblings, 2 replies; 7+ messages in thread
From: Atsushi Nemoto @ 2006-03-24  4:18 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

Revised for current git tree.


1. Use CONFIG_OPROFILE to get rid of overhead for null_perf_irq() call.
2. Call perf_irq from timer_interrupt() instead of
   ll_timer_interrupt().  Many boards are using timer_interrupt(), so
   it would be better to call perf_irq() here.
3. Use jiffies instead of timer_tick_count in scroll_display_message().

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 51273b7..43b4845 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -415,6 +415,18 @@ void local_timer_interrupt(int irq, void
 	update_process_times(user_mode(regs));
 }
 
+#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE)
+int null_perf_irq(struct pt_regs *regs)
+{
+	return 0;
+}
+
+int (*perf_irq)(struct pt_regs *regs) = null_perf_irq;
+
+EXPORT_SYMBOL(null_perf_irq);
+EXPORT_SYMBOL(perf_irq);
+#endif
+
 /*
  * High-level timer interrupt service routines.  This function
  * is set as irqaction->handler and is invoked through do_IRQ.
@@ -423,6 +435,22 @@ irqreturn_t timer_interrupt(int irq, voi
 {
 	unsigned long j;
 	unsigned int count;
+#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE)
+	int r2 = cpu_has_mips_r2;
+
+	/*
+	 * Suckage alert:
+	 * Before R2 of the architecture there was no way to see if a
+	 * performance counter interrupt was pending, so we have to run the
+	 * performance counter interrupt handler anyway.
+	 */
+	if (!r2 || (read_c0_cause() & (1 << 26)))
+		if (perf_irq(regs))
+			return IRQ_HANDLED;
+
+	if (r2 && !(read_c0_cause() & (1 << 30)))
+		return IRQ_HANDLED;
+#endif
 
 	write_seqlock(&xtime_lock);
 
@@ -510,38 +538,14 @@ irqreturn_t timer_interrupt(int irq, voi
 	return IRQ_HANDLED;
 }
 
-int null_perf_irq(struct pt_regs *regs)
-{
-	return 0;
-}
-
-int (*perf_irq)(struct pt_regs *regs) = null_perf_irq;
-
-EXPORT_SYMBOL(null_perf_irq);
-EXPORT_SYMBOL(perf_irq);
-
 asmlinkage void ll_timer_interrupt(int irq, struct pt_regs *regs)
 {
-	int r2 = cpu_has_mips_r2;
-
 	irq_enter();
 	kstat_this_cpu.irqs[irq]++;
 
-	/*
-	 * Suckage alert:
-	 * Before R2 of the architecture there was no way to see if a
-	 * performance counter interrupt was pending, so we have to run the
-	 * performance counter interrupt handler anyway.
-	 */
-	if (!r2 || (read_c0_cause() & (1 << 26)))
-		if (perf_irq(regs))
-			goto out;
-
 	/* we keep interrupt disabled all the time */
-	if (!r2 || (read_c0_cause() & (1 << 30)))
-		timer_interrupt(irq, NULL, regs);
+	timer_interrupt(irq, NULL, regs);
 
-out:
 	irq_exit();
 }
 
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index 93f3bf2..f9471de 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -58,12 +58,11 @@ static char display_string[] = "        
 static unsigned int display_count = 0;
 #define MAX_DISPLAY_COUNT (sizeof(display_string) - 8)
 
-static unsigned int timer_tick_count=0;
 static int mips_cpu_timer_irq;
 
 static inline void scroll_display_message(void)
 {
-	if ((timer_tick_count++ % HZ) == 0) {
+	if ((jiffies % HZ) == 0) {
 		mips_display_message(&display_string[display_count++]);
 		if (display_count == MAX_DISPLAY_COUNT)
 			display_count = 0;
@@ -75,13 +74,8 @@ static void mips_timer_dispatch (struct 
 	do_IRQ (mips_cpu_timer_irq, regs);
 }
 
-extern int null_perf_irq(struct pt_regs *regs);
-
-extern int (*perf_irq)(struct pt_regs *regs);
-
 irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	int r2 = cpu_has_mips_r2;
 	int cpu = smp_processor_id();
 
 	if (cpu == 0) {
@@ -90,13 +84,7 @@ irqreturn_t mips_timer_interrupt(int irq
 		 * accounting resets count/compare registers to trigger next
 		 * timer int.
 		 */
-		if (!r2 || (read_c0_cause() & (1 << 26)))
-			if (perf_irq(regs))
-				goto out;
-
-		/* we keep interrupt disabled all the time */
-		if (!r2 || (read_c0_cause() & (1 << 30)))
-			timer_interrupt(irq, NULL, regs);
+		timer_interrupt(irq, NULL, regs);
 
 		scroll_display_message();
 	} else {
@@ -114,7 +102,6 @@ irqreturn_t mips_timer_interrupt(int irq
 		local_timer_interrupt (irq, dev_id, regs);
 	}
 
-out:
 	return IRQ_HANDLED;
 }
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* compilartion error   : label at end of compound statement
  2006-03-24  4:18 ` Atsushi Nemoto
@ 2006-03-24  7:07   ` Gowri Satish Adimulam
  2006-03-24  8:18     ` Ralf Baechle
  2006-03-24 11:12     ` Thiemo Seufer
  2006-04-25 15:01   ` [PATCH] oprofile cleanups Atsushi Nemoto
  1 sibling, 2 replies; 7+ messages in thread
From: Gowri Satish Adimulam @ 2006-03-24  7:07 UTC (permalink / raw)
  To: linux-mips

Hi ,
Iam trying to compile simple application with mips cross compiler ,
Iam getting the below error , 
i tried to google but unable to find relavent solution

any pointers will be helpful , 

===============error==========

mipsel-linux-uclibc-gcc -Wall    -c -o ls.o ls.c
ls.c: In function `donlist':
ls.c:591: error: label at end of compound statement

==============end of error============
Thanks 
Gowri 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: compilartion error   : label at end of compound statement
  2006-03-24  7:07   ` compilartion error : label at end of compound statement Gowri Satish Adimulam
@ 2006-03-24  8:18     ` Ralf Baechle
  2006-03-27  1:15       ` Gowri Satish Adimulam
  2006-03-24 11:12     ` Thiemo Seufer
  1 sibling, 1 reply; 7+ messages in thread
From: Ralf Baechle @ 2006-03-24  8:18 UTC (permalink / raw)
  To: Gowri Satish Adimulam; +Cc: linux-mips

On Fri, Mar 24, 2006 at 04:07:52PM +0900, Gowri Satish Adimulam wrote:

> Hi ,
> Iam trying to compile simple application with mips cross compiler ,

You didn't say which one.

(Fortunately it's obvious enough in this case)

> Iam getting the below error , 
> i tried to google but unable to find relavent solution
> 
> any pointers will be helpful , 
> 
> ===============error==========
> 
> mipsel-linux-uclibc-gcc -Wall    -c -o ls.o ls.c
> ls.c: In function `donlist':
> ls.c:591: error: label at end of compound statement

Something like:

        switch (x) {
        case 3:
        }

will result in this error message in C9x.  Solution:  insert a semicolon
like:

        switch (x) {
        case 3:
	;
        }

The reason is that the C stanadard requires - and thus gcc since 3.4 (?) -
a label to be followed by a statement and a semicolon alone is already
an statement.

  Ralf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: compilartion error   : label at end of compound statement
  2006-03-24  7:07   ` compilartion error : label at end of compound statement Gowri Satish Adimulam
  2006-03-24  8:18     ` Ralf Baechle
@ 2006-03-24 11:12     ` Thiemo Seufer
  1 sibling, 0 replies; 7+ messages in thread
From: Thiemo Seufer @ 2006-03-24 11:12 UTC (permalink / raw)
  To: Gowri Satish Adimulam; +Cc: linux-mips

On Fri, Mar 24, 2006 at 04:07:52PM +0900, Gowri Satish Adimulam wrote:
> Hi ,
> Iam trying to compile simple application with mips cross compiler ,
> Iam getting the below error , 
> i tried to google but unable to find relavent solution
> 
> any pointers will be helpful , 
> 
> ===============error==========
> 
> mipsel-linux-uclibc-gcc -Wall    -c -o ls.o ls.c
> ls.c: In function `donlist':
> ls.c:591: error: label at end of compound statement
> 
> ==============end of error============

The compiler got pickier about such empty statements some years
ago, you'll have to update your source from .e.g.

	switch (.....) {
	case 1:
		.....
		break;

	default:
	}

to

	switch (.....) {
	case 1:
		.....
		break;

	default:
		break;
	}


Thiemo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: compilartion error   : label at end of compound statement
  2006-03-24  8:18     ` Ralf Baechle
@ 2006-03-27  1:15       ` Gowri Satish Adimulam
  0 siblings, 0 replies; 7+ messages in thread
From: Gowri Satish Adimulam @ 2006-03-27  1:15 UTC (permalink / raw)
  To: linux-mips

Thanks every body 

On Fri, 2006-03-24 at 08:18 +0000, Ralf Baechle wrote:
> On Fri, Mar 24, 2006 at 04:07:52PM +0900, Gowri Satish Adimulam wrote:
> 
> > Hi ,
> > Iam trying to compile simple application with mips cross compiler ,
> 
> You didn't say which one.
> 
> (Fortunately it's obvious enough in this case)
> 
> > Iam getting the below error , 
> > i tried to google but unable to find relavent solution
> > 
> > any pointers will be helpful , 
> > 
> > ===============error==========
> > 
> > mipsel-linux-uclibc-gcc -Wall    -c -o ls.o ls.c
> > ls.c: In function `donlist':
> > ls.c:591: error: label at end of compound statement
> 
> Something like:
> 
>         switch (x) {
>         case 3:
>         }
> 
> will result in this error message in C9x.  Solution:  insert a semicolon
> like:
> 
>         switch (x) {
>         case 3:
> 	;
>         }
> 
> The reason is that the C stanadard requires - and thus gcc since 3.4 (?) -
> a label to be followed by a statement and a semicolon alone is already
> an statement.
> 
>   Ralf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] oprofile cleanups
  2006-03-24  4:18 ` Atsushi Nemoto
  2006-03-24  7:07   ` compilartion error : label at end of compound statement Gowri Satish Adimulam
@ 2006-04-25 15:01   ` Atsushi Nemoto
  1 sibling, 0 replies; 7+ messages in thread
From: Atsushi Nemoto @ 2006-04-25 15:01 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

Revised for current git tree.


1. Use CONFIG_OPROFILE to get rid of overhead for null_perf_irq() call.
2. Call perf_irq from timer_interrupt() instead of
   ll_timer_interrupt().  Many boards are using timer_interrupt(), so
   it would be better to call perf_irq() here.
3. Use jiffies instead of timer_tick_count in scroll_display_message().

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index 13ff4da..f470ec5 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -414,6 +414,18 @@ void local_timer_interrupt(int irq, void
 	update_process_times(user_mode(regs));
 }
 
+#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE)
+int null_perf_irq(struct pt_regs *regs)
+{
+	return 0;
+}
+
+int (*perf_irq)(struct pt_regs *regs) = null_perf_irq;
+
+EXPORT_SYMBOL(null_perf_irq);
+EXPORT_SYMBOL(perf_irq);
+#endif
+
 /*
  * High-level timer interrupt service routines.  This function
  * is set as irqaction->handler and is invoked through do_IRQ.
@@ -422,6 +434,22 @@ irqreturn_t timer_interrupt(int irq, voi
 {
 	unsigned long j;
 	unsigned int count;
+#if defined(CONFIG_OPROFILE) || defined(CONFIG_OPROFILE_MODULE)
+	int r2 = cpu_has_mips_r2;
+
+	/*
+	 * Suckage alert:
+	 * Before R2 of the architecture there was no way to see if a
+	 * performance counter interrupt was pending, so we have to run the
+	 * performance counter interrupt handler anyway.
+	 */
+	if (!r2 || (read_c0_cause() & (1 << 26)))
+		if (perf_irq(regs))
+			return IRQ_HANDLED;
+
+	if (r2 && !(read_c0_cause() & (1 << 30)))
+		return IRQ_HANDLED;
+#endif
 
 	write_seqlock(&xtime_lock);
 
@@ -509,38 +537,14 @@ irqreturn_t timer_interrupt(int irq, voi
 	return IRQ_HANDLED;
 }
 
-int null_perf_irq(struct pt_regs *regs)
-{
-	return 0;
-}
-
-int (*perf_irq)(struct pt_regs *regs) = null_perf_irq;
-
-EXPORT_SYMBOL(null_perf_irq);
-EXPORT_SYMBOL(perf_irq);
-
 asmlinkage void ll_timer_interrupt(int irq, struct pt_regs *regs)
 {
-	int r2 = cpu_has_mips_r2;
-
 	irq_enter();
 	kstat_this_cpu.irqs[irq]++;
 
-	/*
-	 * Suckage alert:
-	 * Before R2 of the architecture there was no way to see if a
-	 * performance counter interrupt was pending, so we have to run the
-	 * performance counter interrupt handler anyway.
-	 */
-	if (!r2 || (read_c0_cause() & (1 << 26)))
-		if (perf_irq(regs))
-			goto out;
-
 	/* we keep interrupt disabled all the time */
-	if (!r2 || (read_c0_cause() & (1 << 30)))
-		timer_interrupt(irq, NULL, regs);
+	timer_interrupt(irq, NULL, regs);
 
-out:
 	irq_exit();
 }
 
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index a9f6124..4eb9b96 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -65,13 +65,12 @@ static unsigned int display_count;
 
 #define CPUCTR_IMASKBIT (0x100 << MIPSCPU_INT_CPUCTR)
 
-static unsigned int timer_tick_count;
 static int mips_cpu_timer_irq;
 extern void smtc_timer_broadcast(int);
 
 static inline void scroll_display_message(void)
 {
-	if ((timer_tick_count++ % HZ) == 0) {
+	if ((jiffies % HZ) == 0) {
 		mips_display_message(&display_string[display_count++]);
 		if (display_count == MAX_DISPLAY_COUNT)
 			display_count = 0;
@@ -83,17 +82,9 @@ static void mips_timer_dispatch (struct 
 	do_IRQ (mips_cpu_timer_irq, regs);
 }
 
-/*
- * Redeclare until I get around mopping the timer code insanity on MIPS.
- */
-extern int null_perf_irq(struct pt_regs *regs);
-
-extern int (*perf_irq)(struct pt_regs *regs);
-
 irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	int cpu = smp_processor_id();
-	int r2 = cpu_has_mips_r2;
 
 #ifdef CONFIG_MIPS_MT_SMTC
         /*
@@ -138,13 +129,7 @@ irqreturn_t mips_timer_interrupt(int irq
 		 * accounting resets count/compare registers to trigger next
 		 * timer int.
 		 */
-		if (!r2 || (read_c0_cause() & (1 << 26)))
-			if (perf_irq(regs))
-				goto out;
-
-		/* we keep interrupt disabled all the time */
-		if (!r2 || (read_c0_cause() & (1 << 30)))
-			timer_interrupt(irq, NULL, regs);
+		timer_interrupt(irq, NULL, regs);
 
 		scroll_display_message();
 	} else {
@@ -164,7 +149,6 @@ irqreturn_t mips_timer_interrupt(int irq
 	}
 #endif /* CONFIG_MIPS_MT_SMTC */
 
-out:
 	return IRQ_HANDLED;
 }
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-04-25 14:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-16 14:45 [PATCH] oprofile cleanups Atsushi Nemoto
2006-03-24  4:18 ` Atsushi Nemoto
2006-03-24  7:07   ` compilartion error : label at end of compound statement Gowri Satish Adimulam
2006-03-24  8:18     ` Ralf Baechle
2006-03-27  1:15       ` Gowri Satish Adimulam
2006-03-24 11:12     ` Thiemo Seufer
2006-04-25 15:01   ` [PATCH] oprofile cleanups Atsushi Nemoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox