From: Andreas Mohr <andi@rhlx01.fht-esslingen.de>
To: Andrew Morton <akpm@osdl.org>
Cc: B.Zolnierkiewicz@elka.pw.edu.pl, linux-ide@vger.kernel.org,
kernel list <linux-kernel@vger.kernel.org>
Subject: [PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall
Date: Fri, 30 Jun 2006 18:13:51 +0200 [thread overview]
Message-ID: <20060630161351.GA17434@rhlx01.fht-esslingen.de> (raw)
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;
}
next reply other threads:[~2006-06-30 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-30 16:13 Andreas Mohr [this message]
2006-06-30 17:26 ` [PATCH -mm] ide_end_drive_cmd(): avoid instruction pipeline stall Alan Cox
2006-06-30 18:00 ` Andrew Morton
2006-06-30 18:21 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060630161351.GA17434@rhlx01.fht-esslingen.de \
--to=andi@rhlx01.fht-esslingen.de \
--cc=B.Zolnierkiewicz@elka.pw.edu.pl \
--cc=akpm@osdl.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox