Subject: Re: i386 interrupt counters
To: Noriyuki Soda <>
From: Chris G Demetriou <>
List: tech-kern
Date: 08/11/1996 21:14:28
> > The big lose is that you only can have one interrupt counter per
> > device, the device's evcnt counter with the name "intr."
> Yes, theoretically it is problem. But IMHO, it is not real problem.
> Because most devices only use one IRQ.

Right, but that also means that it's impossible for the IRQ
definitions to be done at the 'bus' level.

When I added interrupt counters to the Alpha code, I found some
serious bugs in my interrupt handling code, because i noticed that
"the wrong thing" was happening when dispatching interrupts.
I noticed this because I was using per-device and per-IRQ interrupt
counters (via the old-style mechanism).

My point is, 'evcnt' by itself just isn't sufficient to get you all
the information you want.

> > What that means is that you have to do interrupt counting in the
> > drivers.
> Why don't you think that evcnt can be handled by bus code ?
> (evcnt_attach() on xxx_intr_establish(), and dealing with interrupt
> handler's return value on bus level interrupt accounting routine)

(1) the first argument is a struct device *, which would mandate
changing the calling interfaces for all (except possibly tc; i forget
what that looks like) xxx_intr_establish() functions.

(2) if you do it in xxx_intr_establish, then you have no way of
knowing if a device has already done an xxx_intr_establish, i.e. the
device may already have an 'intr' counter.  There _are_ existing
devices that use two IRQs, even if the code in our tree can't handle
them.  they should not be ignored.

(3) where do you get the storage for the evcnt?  per-interrupt-line?
you lose, if you have interrupt sharing.

(4) what do you do for 'weird' cases, like multi-port serial cards,
where you potentially want to know how often each 'com' thinks it
took an interrupt (to see load on each port), how often each _card_
took an interrupt (to see if you want to reassign a serial line to
another card, i.e. swap cables with a more lightly loaded line), and
how often the IRQ took an interrupt (to see if you want to move the
card to a different IRQ, if it's shared).

As i said previously, neither per-device or per-interrupt-line
counting will get you everything you want.  Unfortunately, it's hard
to do per-device counting with old-style counters, and it's
_impossible_ to do per-interrupt-line counting with new-style
counters.  If you do both, the totals end up looking screwy.

Overall, it's much easier to do per-line counters, and has the
potential to screw things up less (esp. the totals).  It's also just
as useful, if you're not sharing interrupt lines.

So, in my opinion, the "Right" thing to do is fix evcnt interrupt
counters to be more useful, and, failing that, just use old-style