public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Ke Wei <kewei.mv@gmail.com>
Cc: linux-scsi@vger.kernel.org, jeff@garzik.org, qswang@marvell.com,
	jfeng@marvell.com, qzhao@marvell.com, kewei@marvell.com
Subject: Re: [PATCH] Marvell 6440 SAS/SATA driver
Date: Sun, 27 Jan 2008 12:13:46 -0600	[thread overview]
Message-ID: <1201457626.3746.21.camel@localhost.localdomain> (raw)
In-Reply-To: <20080127152733.GC21302@ubuntu.domain>

On Sun, 2008-01-27 at 23:27 +0800, Ke Wei wrote:
> > I really don't think you should be doing this.  That single ring governs
> > all the potential tag slots for everything in this device.  If you do a
> > simple head tail allocation, what can happen is that you get a slow tag
> > (attached to a format command, or a tape command) and then the ring head
> > will hit the slow tag and the entire device will halt.  I think you need
> > a bitmap based allocation algorithm to ensure that if you have a free
> > tag anywhere, you'll use it.
> > 
> > If you look at the aic94xx index functions in aic94xx_hwi.h you'll see
> > asd_tc_index_get() and asd_tc_index_release() doing exactly what you
> > want with the native linux bitmap functions (the aic also uses a single
> > issue queue with indexes into it).
> 
> I don't think we need to make use of a bitmap based allocation
> algorithm.
> My algorithm is a simple non-blocking scheduling. Some faster tag may
> be free in advance, so ring will alloc a tag number which has been
> stored in mvi->tags array instead of waiting to hit the slow tag. 

Ah, sorry I didn't see you were actually shuffling entries in the tag
array ... 

> I think that the bitmap based allocation algorithm try to poll and
> find
> the first zero bit. So process may be slow. 
> 
> pls point out anything wrong.

I think you'll find a bitmap based algorithm can be much faster.  The
linux bitmap routines are optimally coded on most architectures (large
numbers actually have a find bit in word/long word instruction).  Even
for a nearly full bitmap, a 512bit array can find the free tag in at
most sixteen machine instructions; if the array is sparse, it can do it
in about two.  Plus a bitmap based scheme has the advantage of tending
to allocate hot tags, thus usually keeping reasonable hot cache reuse.

A ring based algorithm will effectively do levelling to ensure that
every tag is used just about equally, which actually promotes pessimal
hot cache reuse.

Whether cache locality actually matters to the driver is something I
can't actually determine, so I'll leave it up to you to decide.

James



  reply	other threads:[~2008-01-27 18:13 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080122151857.GA8680@ubuntu.domain>
2008-01-22 15:24 ` [PATCH] Marvell 6440 SAS/SATA driver Ke Wei
2008-01-23  3:58   ` Jeff Garzik
2008-01-23 10:54     ` Ke Wei
2008-01-23 11:41       ` Jeff Garzik
2008-01-25 16:43         ` Ke Wei
2008-01-25 17:24           ` Grant Grundler
2008-01-25 17:38             ` James Bottomley
2008-01-25 22:12             ` Jeff Garzik
2008-01-25 17:38           ` Grant Grundler
2008-01-25 22:39           ` James Bottomley
2008-01-27 15:10             ` Ke Wei
2008-01-27 15:27             ` Ke Wei
2008-01-27 18:13               ` James Bottomley [this message]
2008-02-05 13:19                 ` Ke Wei
2008-02-05 21:00                   ` Luben Tuikov
2008-02-07  0:33                   ` Jeff Garzik
2008-01-25 23:00           ` James Bottomley
2008-01-25 23:05             ` Jeff Garzik
2008-01-25 21:27       ` James Bottomley
2008-01-23 19:23     ` Grant Grundler
     [not found] <FE3F06125A99254E8D92161AA4569C6F02310B1A@sc-exch02.marvell.com>
2008-02-22 16:26 ` Jeff Garzik
2008-02-22 16:38   ` James Bottomley

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=1201457626.3746.21.camel@localhost.localdomain \
    --to=james.bottomley@hansenpartnership.com \
    --cc=jeff@garzik.org \
    --cc=jfeng@marvell.com \
    --cc=kewei.mv@gmail.com \
    --cc=kewei@marvell.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=qswang@marvell.com \
    --cc=qzhao@marvell.com \
    /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