* [PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall
@ 2006-06-30 16:13 Andreas Mohr
2006-06-30 17:26 ` Alan Cox
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Mohr @ 2006-06-30 16:13 UTC (permalink / raw)
To: Andrew Morton; +Cc: B.Zolnierkiewicz, linux-ide, kernel list
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 <andi@lisas.de>
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;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall
2006-06-30 16:13 [PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall Andreas Mohr
@ 2006-06-30 17:26 ` Alan Cox
2006-06-30 18:00 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Alan Cox @ 2006-06-30 17:26 UTC (permalink / raw)
To: Andreas Mohr; +Cc: Andrew Morton, B.Zolnierkiewicz, linux-ide, kernel list
Ar Gwe, 2006-06-30 am 18:13 +0200, ysgrifennodd Andreas Mohr:
> 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.
drivers/ide is on its way out. I'm also curious that this shows up given
that the inw() is going to cause a PCI sequence and stall the CPU
entirely for ages anyway.
NAK because
1. This is a gcc problem
2. Not everyone is using an intel x86-32 box which has such problems
3. IDE is in life-support mode and the relatives are already planning
the flowers.
Alan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall
2006-06-30 17:26 ` Alan Cox
@ 2006-06-30 18:00 ` Andrew Morton
2006-06-30 18:21 ` Alan Cox
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2006-06-30 18:00 UTC (permalink / raw)
To: Alan Cox; +Cc: andi, B.Zolnierkiewicz, linux-ide, linux-kernel
On Fri, 30 Jun 2006 18:26:56 +0100
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> Ar Gwe, 2006-06-30 am 18:13 +0200, ysgrifennodd Andreas Mohr:
> > 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.
>
> drivers/ide is on its way out.
Like sound/oss ;)
> I'm also curious that this shows up given
> that the inw() is going to cause a PCI sequence and stall the CPU
> entirely for ages anyway.
I guess because he was profiling for IFU_MEM_STALL, not for wall-time.
> NAK because
> 1. This is a gcc problem
> 2. Not everyone is using an intel x86-32 box which has such problems
> 3. IDE is in life-support mode and the relatives are already planning
> the flowers.
Well. If the patch breaks anything we can dine on hats for a month. Seems
pretty inoffensive to me.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall
2006-06-30 18:00 ` Andrew Morton
@ 2006-06-30 18:21 ` Alan Cox
0 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2006-06-30 18:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: andi, B.Zolnierkiewicz, linux-ide, linux-kernel
Ar Gwe, 2006-06-30 am 11:00 -0700, ysgrifennodd Andrew Morton:
> I guess because he was profiling for IFU_MEM_STALL, not for wall-time.
>
> > NAK because
> > 1. This is a gcc problem
> > 2. Not everyone is using an intel x86-32 box which has such problems
> > 3. IDE is in life-support mode and the relatives are already planning
> > the flowers.
>
> Well. If the patch breaks anything we can dine on hats for a month. Seems
> pretty inoffensive to me.
Yeah its a do nothing change that has no value. We can equally not apply
it and see no difference. Its make-work that might slow down some
systems.
Send it to the gcc people see if its a case they could/should optimise
Alan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-06-30 18:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-30 16:13 [PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall Andreas Mohr
2006-06-30 17:26 ` Alan Cox
2006-06-30 18:00 ` Andrew Morton
2006-06-30 18:21 ` Alan Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox