0

I am using Linux kernel with preempt-rt patch, I did a a simple test to measure time between interrupt and notification of the interrupt to userspace. The idea is quite simple I have a module, that implements a read:

static ssize_t my_read(struct file *filp, char __user *buf, size_t count,loff_t *f_pos)
{
   atomic_set(&intflag, 0);
   if (wait_event_interruptible(my_hack, atomic_read(&intflag) != 0))
        return -ERESTARTSYS;
   do_gettimeofday(&tv2);
   trace_printk("wait_event_interruptible% d\n",(int) (tv2.tv_usec - tv1.tv_usec));
    return 0;
}

then from the interrupt routine I wake the read:

static irqreturn_t

my_interrupt(int irq, void *dev_id)
{
 ...
 atomic_set(&intflag,1);
 do_gettimeofday(&tv1);
 wake_up_interruptible(&mm_fec_hack);

return IRQ_HANDLED;
}

The value printed is around 65 and 70 e.g.

myproc-532 [002] ....... 8049.789350: 0xbf0c81f0: wake_up_interruptible 65

My CPU is a 4 core:

model name : ARMv7 Processor rev 10 (v7l) BogoMIPS : 7.54

and frequency is

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 996000

I think that 65-70 us is pretty much to wakeup a process.

I tried to change irq and process priority with chrt and to relegate the irq to a specific core with smp_affinity and process to the same core or different core with taskset but the results basically are not changing.

What am I doing wrong?

ieio
  • 173
  • 9
  • *"What am I doing wrong?"* -- You have not clearly articulated a goal, perhaps reduce the wake-up time you report? What is `do_gettimeofday()`? Where is your [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)? FYI the realtime patch does not strive for fast response times, but rather predictable/consistent times. Maybe you need to read https://stackoverflow.com/questions/88/is-gettimeofday-guaranteed-to-be-of-microsecond-resolution – sawdust Oct 30 '19 at 21:32
  • Yes goal is to reduce wakeup time. I tried to measure it with ftrace and ftrace_prink and results are comparable to do_gettimeofday(), moreover the system is isolated from the network, so no NTP. – ieio Oct 31 '19 at 10:12

0 Answers0