Subject: Re: i386 interrupt counters
To: Noriyuki Soda <soda@sra.co.jp>
From: Chris G Demetriou <Chris_G_Demetriou@ux2.sp.cs.cmu.edu>
List: tech-kern
Date: 08/14/1996 00:08:10
> > Would it be possible to, somehow, build a hierachy by calling the event
> > attach routine with some handle to the parent's counter?
> 
> I think it would not work.

Uh, perhaps you're using a different definition of 'work' than I am...
8-)


> Please consider following case...
> 
> PCI shared IRQ:
> 	Both device A and device B use same irq.
> 	Both devices raise interrupt at the almost same time.
> 	CPU receives only one interrupt (PCI interrupt is level triggered
> 		wired OR). NetBSD's interrupt handling routine calls
> 		both A's interrupt handler and B's interrupt handler.
> 	So, not always
> 		(A's interrupt count) + (B's interrupt count) ==
> 			(total interrupt count on the irq)
> 	But always
> 		(A's interrupt count) + (B's interrupt count) >=
> 			(total interrupt count on the irq)

That is correct.

interrupt count on IRQ is total # of interrupts caused by that IRQ.

interrupt count for each device is total number of 'useful interrupt
processing' sessions for that device.


> multi-port serial card:
> 	multi-port serial card provides com2 and com3
> 	Both com2 and com3 receives the character at the almost same time.
> 	multi-port serial card raises interrupt, so ttys which are attached
> 		to com2 and com3 receive characters
> 	So, not always
> 		(interrupt count for com2) + (interrupt count for com3) ==
> 			(total interrupt count of the card)
> 	But always
> 		(interrupt count for com2) + (interrupt count for com3) >=
> 			(total interrupt count of the card)

Again, that's correct.


> Hierachy of interrupt counter screws up the totals, too.

No it doesn't.  It's just totalling different things.


In my opinion, there are several correct things to be looking for:

	Total number of times the CPU was interrupted (the 'total').

	Total number of times each IRQ line caused an interrupt (i.e.
	    each line's count).

	Total number of times each device on an IRQ line did useful
	    work as a result of an IRQ on that line.

	Total number of times a subdevice on a device ...

at each level, you have a <= relationship.  (Actually, on the pc,
all at the second level may sum to the first level, but that's not
true on other machines.)

Actually, thinking about it that way, you never want to _calculate_
totals at all.  Rather, you want to use the v_intr count as the total.


However:

	(1) you still need the ability to add multiple 'intr' counters
	    per devices (distinguished with different names), and

	(2) if you want to allow vmstat to pretty-print the output (or
	    other programs to do more complex manipulation of the
	    output), you need do encode some sort of hierarchy.

I'd like (2), but i think i'd settle for (1) as long as vmstat was
modified to no longer calculate totals, and instead use v_intr as
the total interrupt count.


On a slightly different note, i'd also like the ability to avoid
associating event counters with devices.  in particular, the Alpha
can see events which are logically (to the CPU and code which handles
them) interrupts, but which may not be associated with a device.
(The ones that I think match this description are Machine Checks.
Interprocessor interrupts could be associated with the receiving CPU.)


cgd