[PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall

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

 



Use an independently-formatted "unsigned int" for data instead of a
restrictive "u16" to avoid instruction fetch pipeline stalls
probably caused by the byte calculations later.


ide_end_drive_cmd() uses an u16 variable for the result of an INW()
which it then does some byte masking operations on.
On my P3/700, this results in a highly visible IFU_MEM_STALL oprofile blip
when doing a simple "load 30 larger GUI apps in parallel" benchmark
(which takes about 1:30 or so, BTW):
The ide_end_drive_cmd() IFU_MEM_STALL amounts to 0.59% of all IFU_MEM_STALL
events during the profiling, with this opcode line amounting to > 95%
IFU_MEM_STALL within the function itself.

Replacing the u16 by an architecture-independently formatted unsigned int
to ease the byte-masking operations:

	/* no u16 here: caused severe IFU_MEM_STALL! */
	unsigned int data                               = hwif->INW(IDE_DATA_REG);
	args->tfRegister[IDE_DATA_OFFSET]       = (data) & 0xFF;
	args->hobRegister[IDE_DATA_OFFSET]      = (data >> 8) & 0xFF;

completely puts ide_end_drive_cmd() off the IFU_MEM_STALL radar during
repeated profiling attempts (after a fresh reboot with the modified kernel),
as opposed to having been the *top* oprofile trace item before.

I suppose that this is something like a textbook example of why it's
sometimes not beneficial to not use native-sized (i.e., 32bit) variables,
right?

Run-tested on 2.6.17-mm4.

Signed-off-by: Andreas Mohr <[email protected]>


diff -urN linux-2.6.17-mm4.orig/drivers/ide/ide-io.c linux-2.6.17-mm4.my/drivers/ide/ide-io.c
--- linux-2.6.17-mm4.orig/drivers/ide/ide-io.c	2006-06-29 11:57:12.000000000 +0200
+++ linux-2.6.17-mm4.my/drivers/ide/ide-io.c	2006-06-30 11:54:12.000000000 +0200
@@ -397,7 +397,8 @@
 			
 		if (args) {
 			if (args->tf_in_flags.b.data) {
-				u16 data				= hwif->INW(IDE_DATA_REG);
+				/* no u16 here: caused severe IFU_MEM_STALL! */
+				unsigned int data				= hwif->INW(IDE_DATA_REG);
 				args->tfRegister[IDE_DATA_OFFSET]	= (data) & 0xFF;
 				args->hobRegister[IDE_DATA_OFFSET]	= (data >> 8) & 0xFF;
 			}
-
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