All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: linux-parisc@vger.kernel.org,
	James Bottomley <James.Bottomley@HansenPartnership.com>
Subject: [PATCH] parisc: optimize timer_interrupt() function
Date: Thu, 10 Oct 2013 00:12:50 +0200	[thread overview]
Message-ID: <20131009221250.GA1618@p100.box> (raw)

Optimize the timer interrupt function to avoid timer_interrupt
delayed/SLOW messages:
- always do the "cheap" math, it's much faster.
- avoid calling mtctl() twice if we want to skip one clocktick
- do the house keeping (update counters) before we printk() some
  warnings

Overall those changes reduced the amount of timer_interrupt kernel
warnings a lot for me.

Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c
index 70e105d..5a16c12 100644
--- a/arch/parisc/kernel/time.c
+++ b/arch/parisc/kernel/time.c
@@ -77,7 +77,7 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
 
 	cycles_elapsed = now - next_tick;
 
-	if ((cycles_elapsed >> 6) < cpt) {
+	if (1 || (cycles_elapsed >> 6) < cpt) {
 		/* use "cheap" math (add/subtract) instead
 		 * of the more expensive div/mul method
 		 */
@@ -105,10 +105,8 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
 
 	/* Program the IT when to deliver the next interrupt.
 	 * Only bottom 32-bits of next_tick are writable in CR16!
-	 */
-	mtctl(next_tick, 16);
-
-	/* Skip one clocktick on purpose if we missed next_tick.
+	 *
+	 * Skip one clocktick on purpose if we missed next_tick.
 	 * The new CR16 must be "later" than current CR16 otherwise
 	 * itimer would not fire until CR16 wrapped - e.g 4 seconds
 	 * later on a 1Ghz processor. We'll account for the missed
@@ -121,6 +119,20 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
 	now2 = mfctl(16);
 	if (next_tick - now2 > cpt)
 		mtctl(next_tick+cpt, 16);
+	else
+		mtctl(next_tick, 16);
+
+	/* Done mucking with unreliable delivery of interrupts.
+	 * Go do system house keeping.
+	 */
+
+	if (!--cpuinfo->prof_counter) {
+		cpuinfo->prof_counter = cpuinfo->prof_multiplier;
+		update_process_times(user_mode(get_irq_regs()));
+	}
+
+	if (cpu == 0)
+		xtime_update(ticks_elapsed);
 
 #if 1
 /*
@@ -154,18 +166,6 @@ irqreturn_t __irq_entry timer_interrupt(int irq, void *dev_id)
 			next_tick, now );
 	}
 
-	/* Done mucking with unreliable delivery of interrupts.
-	 * Go do system house keeping.
-	 */
-
-	if (!--cpuinfo->prof_counter) {
-		cpuinfo->prof_counter = cpuinfo->prof_multiplier;
-		update_process_times(user_mode(get_irq_regs()));
-	}
-
-	if (cpu == 0)
-		xtime_update(ticks_elapsed);

             reply	other threads:[~2013-10-09 22:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-09 22:12 Helge Deller [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-12-20 19:51 [PATCH] parisc: Optimize timer interrupt function Helge Deller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131009221250.GA1618@p100.box \
    --to=deller@gmx.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-parisc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.