linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux/libata.h/ata_busy_wait() inefficiencies?
@ 2008-03-25 20:59 Andreas Mohr
  2008-03-26 14:11 ` Mark Lord
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Mohr @ 2008-03-25 20:59 UTC (permalink / raw)
  To: linux-ide

Hello all,

originally I just intended to prepare a patch (to -mm),
but it seems better to discuss this first.

Currently (2.6.25-rc6) we have:

static inline u8 ata_busy_wait(struct ata_port *ap, unsigned int bits,
                               unsigned int max)
{
        u8 status;

        do {
                udelay(10);
                status = ata_chk_status(ap);
                max--;
        } while (status != 0xff && (status & bits) && (max > 0));

        return status;
}

This can easily be improved to have merged max handling
by doing a single (--max > 0) instead, without any change in behaviour.
Building this on i386 showed combined image savings of almost 100 bytes,
most likely due to not having to re-fetch max again for the duplicate
max access.

However we're not finished yet:
Since status != 0xff is most certainly a check for the "unplugged hotplug"
case, it's a bit wasteful to check this as the very first abort condition.
By moving this more towards the end one should be able to improve exit latency
of this loop, without altering behaviour here as well (- right??).
Since the "(status != 0xff && (status & bits)" part is being used verbatim
(ICK, COPY&PASTE!! ;) many times (e.g. also in libata-core.c),
IMHO the best way going forward would be to create another fittingly named
inline header helper for this combined check which could then have its
check order swapped for better exit latency.

Those two tweaks alone may already be able to deliver a noticeable speedup
of ata operations given that this is frequently used inner libata code.

Thoughts on this?

Thanks,

Andreas Mohr

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-26 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-25 20:59 linux/libata.h/ata_busy_wait() inefficiencies? Andreas Mohr
2008-03-26 14:11 ` Mark Lord
2008-03-26 21:34   ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).