From: Dinakar Guniguntala <dino@in.ibm.com>
To: p_gortmaker@yahoo.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] lost RTC interrupts
Date: Fri, 4 Jun 2004 16:14:18 +0530 [thread overview]
Message-ID: <20040604104418.GA3911@in.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 322 bytes --]
Paul,
The calculation for the number of interrupts lost when the
RTC stops generating interrupts seems to be broken for HZ=1000
Also, the following patch returns more accurate lost interrupt
data (At the cost of some accounting for every interrupt)
Let me know if you think the accounting is unnecessary
Thanks
Dinakar
[-- Attachment #2: rtc-lost-ticks.patch --]
[-- Type: text/plain, Size: 1533 bytes --]
diff -Naurp linux-2.6.7-rc2/drivers/char/rtc.c linux-2.6.7-rc2-rtc/drivers/char/rtc.c
--- linux-2.6.7-rc2/drivers/char/rtc.c 2004-05-30 11:56:50.000000000 +0530
+++ linux-2.6.7-rc2-rtc/drivers/char/rtc.c 2004-06-03 13:09:04.000000000 +0530
@@ -169,6 +169,9 @@ static unsigned long rtc_freq = 0; /* Cu
static unsigned long rtc_irq_data = 0; /* our output to the world */
static unsigned long rtc_max_user_freq = 64; /* > this, need CAP_SYS_RESOURCE */
+static unsigned long prev_jiffies = 0;
+static unsigned long rtcticks_in_pjiffies = 0;
+
#ifdef RTC_IRQ
/*
* rtc_task_lock nests inside rtc_lock.
@@ -239,6 +242,12 @@ irqreturn_t rtc_interrupt(int irq, void
spin_unlock (&rtc_lock);
+ if (jiffies != prev_jiffies) {
+ prev_jiffies = jiffies;
+ rtcticks_in_pjiffies = 0;
+ }
+ rtcticks_in_pjiffies++;
+
/* Now do the rest of the actions */
spin_lock(&rtc_task_lock);
if (rtc_callback)
@@ -1094,7 +1103,7 @@ static void rtc_dropped_irq(unsigned lon
if (rtc_status & RTC_TIMER_ON)
mod_timer(&rtc_irq_timer, jiffies + HZ/rtc_freq + 2*HZ/100);
- rtc_irq_data += ((rtc_freq/HZ)<<8);
+ rtc_irq_data += ((rtc_freq/HZ * 2*HZ/100 - rtcticks_in_pjiffies)<<8);
rtc_irq_data &= ~0xff;
rtc_irq_data |= (CMOS_READ(RTC_INTR_FLAGS) & 0xF0); /* restart */
@@ -1102,6 +1111,9 @@ static void rtc_dropped_irq(unsigned lon
spin_unlock_irq(&rtc_lock);
+ prev_jiffies = jiffies;
+ rtcticks_in_pjiffies = 1;
+
printk(KERN_WARNING "rtc: lost some interrupts at %ldHz.\n", freq);
/* Now we have new data */
reply other threads:[~2004-06-04 10:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20040604104418.GA3911@in.ibm.com \
--to=dino@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=p_gortmaker@yahoo.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox