Date: Mon, 03 Jan 2005 09:45:09 -0800 From: Nate Lawson <nate@root.org> To: sos@deepcore.dk Cc: FreeBSD Current <freebsd-current@freebsd.org> Subject: ATA rman performance enhancement Message-ID: <41D984A5.7010408@root.org>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------060807040601090509030607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
While doing some benchmarking of other code, I noticed that there were a
lot of calls to rman_get_bustag/handle(). They weren't taking up much
actual time since they're pretty lightweight but seemed to be unnecessary.
I worked up the attached diff and benchmarked it. There are about 1000
calls a second to the rman routines without this patch and essentially
none with it. It makes about a 1% difference in throughput under some
IO loads. It is only for non-Promise or non-SII controllers right now
since I didn't extend the initialization step to more than ata-pci.c.
The same approach could be used for the other INW/OUTW calls as well but
they're not in the fast path. I think it may make more of a difference
with small reads.
Feel free to test, cleanup, and commit.
Thanks,
--
Nate
--------------060807040601090509030607
Content-Type: text/plain;
name="ata-rman.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="ata-rman.diff"
Index: ata-all.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/ata-all.h,v
retrieving revision 1.87
diff -u -r1.87 ata-all.h
--- ata-all.h 9 Dec 2004 07:31:06 -0000 1.87
+++ ata-all.h 3 Jan 2005 09:54:40 -0000
@@ -331,6 +331,8 @@
struct ata_resource {
struct resource *res;
int offset;
+ bus_space_tag_t tag;
+ bus_space_handle_t handle;
};
/* structure describing an ATA channel */
@@ -493,7 +495,7 @@
(offset), (addr), (count))
#define ATA_IDX_INB(ch, idx) \
- ATA_INB(ch->r_io[idx].res, ch->r_io[idx].offset)
+ bus_space_read_1(ch->r_io[idx].tag, ch->r_io[idx].handle, ch->r_io[idx].offset)
#define ATA_IDX_INW(ch, idx) \
ATA_INW(ch->r_io[idx].res, ch->r_io[idx].offset)
@@ -514,13 +516,13 @@
ATA_INSL_STRM(ch->r_io[idx].res, ch->r_io[idx].offset, addr, count)
#define ATA_IDX_OUTB(ch, idx, value) \
- ATA_OUTB(ch->r_io[idx].res, ch->r_io[idx].offset, value)
+ bus_space_write_1(ch->r_io[idx].tag, ch->r_io[idx].handle, ch->r_io[idx].offset, value)
#define ATA_IDX_OUTW(ch, idx, value) \
ATA_OUTW(ch->r_io[idx].res, ch->r_io[idx].offset, value)
#define ATA_IDX_OUTL(ch, idx, value) \
- ATA_OUTL(ch->r_io[idx].res, ch->r_io[idx].offset, value)
+ bus_space_write_4(ch->r_io[idx].tag, ch->r_io[idx].handle, ch->r_io[idx].offset, value)
#define ATA_IDX_OUTSW(ch, idx, addr, count) \
ATA_OUTSW(ch->r_io[idx].res, ch->r_io[idx].offset, addr, count)
Index: ata-pci.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/ata-pci.c,v
retrieving revision 1.91
diff -u -r1.91 ata-pci.c
--- ata-pci.c 8 Dec 2004 11:17:38 -0000 1.91
+++ ata-pci.c 3 Jan 2005 09:45:55 -0000
@@ -417,15 +417,23 @@
for (i = ATA_DATA; i <= ATA_STATUS; i ++) {
ch->r_io[i].res = io;
+ ch->r_io[i].tag = rman_get_bustag(io);
+ ch->r_io[i].handle = rman_get_bushandle(io);
ch->r_io[i].offset = i;
}
ch->r_io[ATA_ALTSTAT].res = altio;
+ ch->r_io[ATA_ALTSTAT].tag = rman_get_bustag(altio);
+ ch->r_io[ATA_ALTSTAT].handle = rman_get_bushandle(altio);
ch->r_io[ATA_ALTSTAT].offset = ata_legacy(device_get_parent(dev)) ? 0 : 2;
ch->r_io[ATA_IDX_ADDR].res = io;
+ ch->r_io[ATA_IDX_ADDR].tag = rman_get_bustag(io);
+ ch->r_io[ATA_IDX_ADDR].handle = rman_get_bushandle(io);
if (ctlr->r_res1) {
for (i = ATA_BMCMD_PORT; i <= ATA_BMDTP_PORT; i++) {
ch->r_io[i].res = ctlr->r_res1;
+ ch->r_io[i].tag = rman_get_bustag(ctlr->r_res1);
+ ch->r_io[i].handle = rman_get_bushandle(ctlr->r_res1);
ch->r_io[i].offset = (i - ATA_BMCMD_PORT)+(ch->unit * ATA_BMIOSIZE);
}
}
--------------060807040601090509030607--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41D984A5.7010408>
