Re: calling hooks from inside timer interrupt handler freezes machine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
  Can you post your kernel module code too. I am interested in knowing which function in the kernel module does the registration. Do you find anything suspicious in the dmesg output? Like multiple registration calls etc?

  Namaste,

  Sameer

On 10/3/07, Mohammad M Molla <merajul_i@xxxxxxxxx> wrote:
Hi

I am trying to reigster a hook and then call it from timer interrupt handler do_timer so that I can schedule a tasklet from inside my registered function (It might not have any practical value, but I want to learn the process, scheduling tasklet from timer interrupt context).

Changes I have made in kernel/timer.c to pass the function to register from a kernel module is -

------------------------------------------
--- linux-2.6.22/kernel/timer.c    2007-09-22 21:29:12.000000000 -0400
+++ linux-2.6.22-dev/kernel/timer.c    2007-09-30 22:24:31.000000000 -0400
@@ -895,7 +895,44 @@
     update_wall_time();
     calc_load(ticks);
 }

+
+/* Timer hook to use with klife */
+#define CONFIG_GAMEOFLIFE
+
+struct timer_interrupt_hook
+{
+       void (*func)(void*);
+       void* data;
+};
+
+static struct timer_interrupt_hook *timer_interrupt_hook;
+
+int register_timer_interrupt(struct timer_interrupt_hook *hook)
+{
+    pr_debug("registering timer_interrupt_hook (%p), hook->func (%p), hook->data (%p)\n", hook, hook->func, hook->data);
+
+    xchg(&timer_interrupt_hook, hook);
+   
+    return 0;
+}
+
+
+void unregister_timer_interrupt(struct timer_interrupt_hook *hook)
+{
+    pr_debug("unregistering timer_interrupt_hook\n");
+
+    xchg(&timer_interrupt_hook, 0);
+}
+
+static void call_timer_hook(void)
+{
+    struct timer_interrupt_hook *hook = timer_interrupt_hook;
+
+    if (hook && hook->func)
+        hook->func(hook->data);
+}
+
+
 /*
  * The 64-bit jiffies value is not atomic - you MUST NOT read it
  * without sampling the sequence number in xtime_lock.
@@ -906,6 +943,10 @@
 {
     jiffies_64 += ticks;
     update_times(ticks);
+
+#ifdef CONFIG_GAMEOFLIFE   
+    call_timer_hook();
+#endif
 }
 
 #ifdef __ARCH_WANT_SYS_ALARM
@@ -1549,4 +1590,6 @@
     return jiffies_to_msecs(timeout);
 }
 
+EXPORT_SYMBOL(register_timer_interrupt);
+EXPORT_SYMBOL(unregister_timer_interrupt);
 EXPORT_SYMBOL(msleep_interruptible);

-------------------------------------------------

From a kernel module, I call the register_timer_interrupt to register my hook inside open function of the module and the function currently does not do anything, its empty.

-------------------------------
static void
klife_timer_irq_handler(void *data)
{

}
-------------------------------

But after I open the device node from a userspace program, it freezes the system after a while. However, if I don't register the hook in my module,  everything works fine.

Why is registering an empty function and calling it from inside do_timer  freezing the system after a short period of good run?

Can anyone help?


Thanks in advance.


- Meraj






Need a vacation? Get great deals to amazing places on Yahoo! Travel.



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux