Re: [PATCH] hpsa: SCSI driver for HP Smart Array controllers

From: Grant Grundler
Date: Mon Mar 02 2009 - 12:19:35 EST


On Sun, Mar 1, 2009 at 10:32 PM, FUJITA Tomonori
<fujita.tomonori@xxxxxxxxxxxxx> wrote:
...
>> +/*
>> + * For operations that cannot sleep, a command block is allocated at init,
>> + * and managed by cmd_alloc() and cmd_free() using a simple bitmap to track
>> + * which ones are free or in use. ÂLock must be held when calling this.
>> + * cmd_free() is the complement.
>> + */
>> +static struct CommandList_struct *cmd_alloc(struct ctlr_info *h)
>> +{
>> + Â Â struct CommandList_struct *c;
>> + Â Â int i;
>> + Â Â union u64bit temp64;
>> + Â Â dma_addr_t cmd_dma_handle, err_dma_handle;
>> +
>> + Â Â do {
>> + Â Â Â Â Â Â i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
>> + Â Â Â Â Â Â if (i == h->nr_cmds)
>> + Â Â Â Â Â Â Â Â Â Â return NULL;
>> + Â Â } while (test_and_set_bit
>> + Â Â Â Â Â Â Â(i & (BITS_PER_LONG - 1),
>> + Â Â Â Â Â Â Â h->cmd_pool_bits + (i / BITS_PER_LONG)) != 0);
>
> Using bitmap to manage free commands looks too complicated a bit to
> me. Can we just use lists for command management?

Bit maps are generally more efficient than lists since we touch less data.
For both search and moving elements from free<->busy lists. This probably
won't matter if we are talking less than 10K IOPS. And willy demonstrated
other layers have pretty high overhead (block, libata and SCSI midlayer)
at high transaction rates.

If nr_cmds can be greater than 8*BITS_PER_LONG or so, it would
be more efficient to save the allocation offset and start the next search
from that location. But I can't tell from the code since nr_cmds is
coming from the controller:

+ /* Query controller for max supported commands: */
+ c->max_commands = readl(&(c->cfgtable->CmdsOutMax));
...
+ c->nr_cmds = c->max_commands - 4;


hth,
grant
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/