i8259.c dummy I/O operation?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I just wanted to direct attention to further somewhat wasteful aspects
in kernel code ;)

Since this extra inb() is in IRQ handler hotpath (called at least a
couple hundred times per second without dynticks patch),
it hurts quite obviously, potentially with several hundred CPU cycles
per I/O due to slow PIC access (haven't actually profiled it, though).

This dummy op can be found in i8259.c of i386/, x86_64/ and mips/.

There seem to be no adverse effects on three systems that I tested it on:
- P4 HT
- P3/700
- Athlon on VIA chipset

Comments?
Further testing on various chipsets by more people would also be useful,
I think...
(however testing might be dangerous, of course, since it's a quite invasive
change and might even corrupt data or so!)

Thanks,

Andreas Mohr

P.S.: the outb() change is just a minor comment correction...


diff -urN linux-2.6.17-mm4.orig/arch/i386/kernel/i8259.c linux-2.6.17-mm4.my/arch/i386/kernel/i8259.c
--- linux-2.6.17-mm4.orig/arch/i386/kernel/i8259.c	2006-06-29 11:57:11.000000000 +0200
+++ linux-2.6.17-mm4.my/arch/i386/kernel/i8259.c	2006-06-29 21:17:33.000000000 +0200
@@ -191,13 +191,13 @@
 	cached_irq_mask |= irqmask;
 
 handle_real_irq:
+	/* we used to first do a dummy inb() on PIC_SLAVE_IMR/PIC_MASTER_IMR
+	   here, but this doesn't seem to actually be necessary... */
 	if (irq & 8) {
-		inb(PIC_SLAVE_IMR);	/* DUMMY - (do we need this?) */
 		outb(cached_slave_mask, PIC_SLAVE_IMR);
 		outb(0x60+(irq&7),PIC_SLAVE_CMD);/* 'Specific EOI' to slave */
 		outb(0x60+PIC_CASCADE_IR,PIC_MASTER_CMD); /* 'Specific EOI' to master-IRQ2 */
 	} else {
-		inb(PIC_MASTER_IMR);	/* DUMMY - (do we need this?) */
 		outb(cached_master_mask, PIC_MASTER_IMR);
 		outb(0x60+irq,PIC_MASTER_CMD);	/* 'Specific EOI to master */
 	}
@@ -272,7 +272,7 @@
 	 * out of.
 	 */
 	outb(0xff, PIC_MASTER_IMR);	/* mask all of 8259A-1 */
-	outb(0xff, PIC_SLAVE_IMR);	/* mask all of 8259A-1 */
+	outb(0xff, PIC_SLAVE_IMR);	/* mask all of 8259A-2 */
 	return 0;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux