Skip to contentSkip to conversation

Adeos-main digest, Vol 1 #39 - 1 msg

Adeos-main Currie Reid 2 participants 5 messages Oct 27, 2004 – Oct 29, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hello,

It looks like spurious interrupts are ignored during kernel/device initialization until __adeos_takeover(). Then, any spurious interrupts that occur are counted in the total.

#2 lore raw
Quoted 6 lines · Currie Reid

Hello,

It looks like spurious interrupts are ignored during kernel/device initialization until __adeos_takeover(). Then, any spurious interrupts that occur are counted in the total.

[snip]

Quoted 5 lines

Should Adeos be ignoring these interrupts as the do_IRQ routine seems to be doing prior to Adeos pipelining being started? It seems to be on initialisation of the usb keyboards that is causing these interrupts. As I said in my previous e-mail, the total remains stable after the system is booted - no more spurious interrupts are registered.

My code looks bugous. Not all possible return values from ppc_md.get_irq() are checked against the current context (1st or subsequent IRQs), so ppc_spurious_interrupts gets spuriously incremented. Sorry, brain cells shortage...

Quoted 58 lines

It looks like Adeos for the 2.4 kernel did not increment the spurious interrupt count, so you don't see the same problem. I tried commenting out the increment in __adeos_grab_irq just to verify, and it seems to supress the count, but I'm sure that it is there for a reason.

Any insight into this is very much appreciated.

Currie

Quoted 39 lines

Date: Tue, 26 Oct 2004 10:31:07 -0400 (EDT)
From: Currie Reid <[email protected]>
To: [email protected]
Subject: [Adeos-main] Spurious interrupts on boot

Hello all,

I have applied adeos-linuxppc-2.6.8rc1-r6c8.patch to my kernel, and everything seems to be working fine so far, but I notice that the ppc_spurious_interrupts count runs up on boot:

CPU0

 19:       2239   OpenPIC   Level     ide0
 20:         12   OpenPIC   Level     ide1
 25:      10855   OpenPIC   Level     VIA-PMU
 41:       4415   OpenPIC   Level     eth0
 47:          0   OpenPIC   Level     GPIO1/ADB

BAD: 1426

The good news is that it doesn't increase, but without the patch, the BAD count stays at 0. Is this a known issue? I haven't found any reference to it on the mailing list.

My machine g4 powermac:
processor : 0
cpu : 7400, altivec supported
temperature : 7-9 C (uncalibrated)
clock : 400MHz
revision : 2.8 (pvr 000c 0208)
bogomips : 794.62
machine : PowerMac3,3
motherboard : PowerMac3,3 MacRISC2 MacRISC Power Macintosh
detected as : 65 (PowerMac G4 AGP Graphics)
pmac flags : 00000004
L2 cache : 1024K unified
memory : 1024MB
pmac-generation : NewWorld

Quoted 3 lines

Thanks

Currie Reid

_______________________________________________
Adeos-main mailing list
[email protected]
https://mail.gna.org/listinfo/adeos-main

Signature · 1 line
Philippe.
#3 lore raw

[Adeos-main] Question about adeos_alloc_irq

Hi Philippe,

I am basically trying to get some latency figures using Adeos, and I've hit a snag. Basically, I wanted to cause an interrupt, then measure the time it took in the root domain to respond to the interrupt. Then, I wanted to put the irq handler in a higher priority domain, and measure the response this latency and compare the 2. I thought that the second one would be lower, as the interrupt is sure not to be masked in the higher priority domain, while there are no such guarantees in the root domain (linux). But I'm finding the latencies higher; the average latency is higher and the max is higher as well - I don't know if this is because there is some context-switching overhead or what the problem might be. I'm including my module on the chance that you might spot something wrong with it immediately.

Thanks for your all of your help and patience,

Currie

#include <linux/module.h>
#include <linux/adeos.h>

#include <linux/proc_fs.h> /* for create_proc_entry */

MODULE_LICENSE("GPL");
MODULE_AUTHOR( "Currie Reid" ); MODULE_DESCRIPTION( "Measure interrupt latency." );

/* descriptor for our domain */
adomain_t domain_desc;

int interrupt_count = 0;

/* required for taking time measurements */
struct timeval t_assert, t_deassert;

/* IRQ that we will use to trigger ISR */
unsigned MY_IRQ = 0;

/* struct required for formatting proc fs entry */ static struct proc_dir_entry *interrupt_latency_file;

/* call this to handle the interrupt in the root domain */ void root_handle_interrupt( unsigned timer_irq ){

   do_gettimeofday( &t_deassert );

interrupt_count++;

printk( KERN_ALERT "ERROR: this should have been handled"

                      "in the interrupt_domain\n" );
}

/* call this to handle the interrupt in the interrupt domain */ void domain_handle_interrupt( unsigned timer_irq ){

   do_gettimeofday( &t_deassert );

interrupt_count++;
}

/* this formats the proc filesystem entry for public consumption */ static int proc_read_interrupt_latency( char* page, char** start,

      off_t off, int count, int *eof, void* data ){
   int len = 0;

   do_gettimeofday( &t_assert );

/* if first-read, trigger the IRQ - otherwise, we are coming
* back for more.
*/
if( off == 0 )

      adeos_trigger_irq( MY_IRQ );

len = sprintf( page, "latency %10i\n",

         (int)( t_deassert.tv_usec - t_assert.tv_usec ) );
   *eof = 1;

return len;
}

/* registers our domain and associated handlers */ void domain_entry( int iflag ){

if( iflag )
adeos_virtualize_irq( MY_IRQ, domain_handle_interrupt,
0, IPIPE_HANDLE_MASK );

for(;;)

      adeos_suspend_domain();
}

static int __init init_interrupt_latency( void ){

/* required for registering new domain */
adattr_t attr;
adeos_init_attr( &attr );

   /* RESOURCE interrupt_latency_file */
   interrupt_latency_file =
      create_proc_entry( "interrupt_latency", 0444, 0 );

   if( ! interrupt_latency_file ){
      printk( KERN_ALERT "Failed to create proc entry.\n" );
      return -ENOMEM;
   }

   interrupt_latency_file->data       = 0;
   interrupt_latency_file->read_proc  = &proc_read_interrupt_latency;
   interrupt_latency_file->write_proc = 0;
   interrupt_latency_file->owner      = THIS_MODULE;

   MY_IRQ = adeos_alloc_irq();

   if( ! MY_IRQ ){
      remove_proc_entry( "interrupt_latency", 0 );
      printk( KERN_ALERT "Failed to obtain IRQ number.\n" );
      return -ENOMEM;

}

if( adeos_virtualize_irq( MY_IRQ, root_handle_interrupt, 0,

                             IPIPE_DEFAULT_MASK ) != 0 ){

      remove_proc_entry( "interrupt_latency", 0 );
      printk( KERN_ALERT "Failed to set IRQ handler.\n" );
      return -ENOMEM;

}

   printk( KERN_INFO "interrupt allocated - IRQ %d.\n", MY_IRQ );

   attr.name      = "interrupt_domain";
   attr.domid     = 0x10101010;
   attr.entry     = &domain_entry;
   attr.priority  = ADEOS_ROOT_PRI + 1;

return adeos_register_domain( &domain_desc, &attr );
}

static void __exit exit_interrupt_latency( void ){

adeos_unregister_domain( &domain_desc ); adeos_free_irq( MY_IRQ ); remove_proc_entry( "interrupt_latency", 0 ); printk( KERN_INFO "interrupt_latency unloaded.\n" );
}

module_init( init_interrupt_latency );
module_exit( exit_interrupt_latency );

#4 lore raw

[Adeos-main] Re: Question about adeos_alloc_irq

Quoted 14 lines · Currie Reid

Hi Philippe,

I am basically trying to get some latency figures using Adeos, and I've hit a snag. Basically, I wanted to cause an interrupt, then measure the time it took in the root domain to respond to the interrupt. Then, I wanted to put the irq handler in a higher priority domain, and measure the response this latency and compare the 2. I thought that the second one would be lower, as the interrupt is sure not to be masked in the higher priority domain, while there are no such guarantees in the root domain (linux). But I'm finding the latencies higher; the average latency is higher and the max is higher as well - I don't know if this is because there is some context-switching overhead or what the problem might be. I'm including my module on the chance that you might spot something wrong with it immediately.

Calling adeos_trigger_irq() with irqs on over the root domain while a handler exists in the same domain will immediately run the IRQ handler on behalf of adeos_trigger_irq(), with no more CPU cost than a simple function call. OTOH, switching to the interrupt domain will require a full domain switch, hence the higher cost. This said, a better way to measure the latency is not by using virtual IRQs, which exhibit the specific behaviour above, but rather a real external IRQ, such as the timer one.

Just hook _adeos_timer_virq on PPC in a prioritary domain, and compare the max jitter obtained between two ticks to the same measurement in timer_interrupt() from a vanilla kernel. The figures should confirm what's expected.

PS: calling do_gettimeofday() outside the root domain is unsafe, since you could have preempted any critical Linux section to enter this code. This looks like working somewhat, but only because the caller is usually lucky.
Using adeos_hw_tsc() to collect the TBL/U then scale the value to nanoseconds is safe in any case.

Signature · 1 line
Philippe.
#5 lore raw

[Adeos-main] Re: Question about adeos_alloc_irq

Hi Philippe,

Thank you for your quick reply - I was sure that it was just something that I was doing incorrectly. I am quite new to kernel programming, hence the errors that you have noted. I have re-coded the time measurement code as per your suggestion and I'm in the process of re-writing to measure a real external IRQ. As an exercise to focus my understanding of Adeos and in preparation for looking at the RTAI implementation above it, I'm trying to write a simple hi-res timer implementation over the adeos layer (in my readings I saw where Karim had suggested this as an alternative to the hi-res timer patches and I thought that this might be an interesting thing to try for learning purposes).

Thanks for all of your help and suggestions,
Currie

Quoted 42 lines · Philippe Gerum
Quoted 14 lines · Currie Reid

Hi Philippe,

I am basically trying to get some latency figures using Adeos, and I've hit a snag. Basically, I wanted to cause an interrupt, then measure the time it took in the root domain to respond to the interrupt. Then, I wanted to put the irq handler in a higher priority domain, and measure the response this latency and compare the 2. I thought that the second one would be lower, as the interrupt is sure not to be masked in the higher priority domain, while there are no such guarantees in the root domain (linux). But I'm finding the latencies higher; the average latency is higher and the max is higher as well - I don't know if this is because there is some context-switching overhead or what the problem might be. I'm including my module on the chance that you might spot something wrong with it immediately.

Calling adeos_trigger_irq() with irqs on over the root domain while a handler exists in the same domain will immediately run the IRQ handler on behalf of adeos_trigger_irq(), with no more CPU cost than a simple function call. OTOH, switching to the interrupt domain will require a full domain switch, hence the higher cost. This said, a better way to measure the latency is not by using virtual IRQs, which exhibit the specific behaviour above, but rather a real external IRQ, such as the timer one.

Just hook _adeos_timer_virq on PPC in a prioritary domain, and compare the max jitter obtained between two ticks to the same measurement in timer_interrupt() from a vanilla kernel. The figures should confirm what's expected.

PS: calling do_gettimeofday() outside the root domain is unsafe, since you could have preempted any critical Linux section to enter this code. This looks like working somewhat, but only because the caller is usually lucky.
Using adeos_hw_tsc() to collect the TBL/U then scale the value to nanoseconds is safe in any case.

--

Philippe.