From owner-freebsd-hackers Thu Nov 8 8:51:44 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from rover.village.org (rover.bsdimp.com [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id C578F37B418 for ; Thu, 8 Nov 2001 08:51:39 -0800 (PST) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.11.3/8.11.3) with ESMTP id fA8Gpba14653; Thu, 8 Nov 2001 09:51:37 -0700 (MST) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost [127.0.0.1]) by harmony.village.org (8.11.6/8.11.6) with ESMTP id fA8Gpa744046; Thu, 8 Nov 2001 09:51:37 -0700 (MST) (envelope-from imp@harmony.village.org) Message-Id: <200111081651.fA8Gpa744046@harmony.village.org> To: Sansonetti Laurent Subject: Re: Measuring interrupt latency Cc: freebsd-hackers@FreeBSD.ORG In-reply-to: Your message of "08 Nov 2001 17:23:41 GMT." <1005240221.454.13.camel@teneriel.teledisnet.be> References: <1005240221.454.13.camel@teneriel.teledisnet.be> Date: Thu, 08 Nov 2001 09:51:36 -0700 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <1005240221.454.13.camel@teneriel.teledisnet.be> Sansonetti Laurent writes: : I have to measure ISR [*] under FreeBSD, so I'm building a small KLD : which is hijacking a misc driver with timestamps... : : Is there a way to simulate a hardware irq from kernel land ? : I saw swi_dispatcher() in /sys/kern/kern_intr.c, is this right ? : : In fact I have to start hardware irq by hand because I need to take : timestamp at this moment.. : : Anyone have already measured ISR for FreeBSD ? Is that way correct ? : : Thanks in advance ! The usual way to do this is to connect the IRQ line to 'Trigger' on the scope and toggle a line on the parallel port in your ISR and connect that to 'channel 1' or 'channel 2' of the scope. Note: you may wish to measure how long it takes to pull the parallel port line high, because that can be as long as a microsecond on some machines. The easiest way to do this is to toggle the line, measure the width of the pulse and then substract that value from other measurements that you get. You'll find that it is typically on the order of a microsecond (including time to bring the parallel port high) for a fast interrupt, and varies on non-fast interrupts (anywhere from one microsecond to as much as a millisecond on a very heavily loaded system). You can generate an IRQ in a number of ways. Likely the easiest is to have a tie a different line from the parallel port to the #ACK line and pulse that line. If you do this, then the two signals to measure is even easier. Note: you almost certainly will *NOT* be able to accuragely measure this in software. The getting of the time may swamp the latency for fast interrupts. Also, depending on the time keeping device in use, you may not have enough resolution for measuring it on a fast machine. And a good scope will give you *MUCH* better numbers. And if you are writing an article, people will make this criticism. We found at Timing Solutions when we were trying to measure interrupt latency that the system time (getnanotime()) gave us measurements with a larger variance than our expensive scopes that does statistical gathering. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message