From: Neil Brown <neilb@suse.de>
To: Raz <raziebe@gmail.com>
Cc: Linux RAID Mailing List <linux-raid@vger.kernel.org>
Subject: Re: raid0 hashing funtion
Date: Wed, 13 May 2009 08:12:44 +1000 [thread overview]
Message-ID: <18953.62556.265428.572219@notabene.brown> (raw)
In-Reply-To: message from Raz on Sunday May 3
On Sunday May 3, raziebe@gmail.com wrote:
> Neil Hello
> I am reading the raid0 code, and I do not understand what is the
> rational behind this hashing and spacing ?
> I am asking because I am working on the chunk size restrictions.
> in raid0_make_request the zone calculation is as follows:
>
> {
> sector_t x = sector >> conf->sector_shift;
> sector_div(x, (u32)conf->spacing);
> zone = conf->hash_table[x];
> }
> while (sector >= zone->zone_start + zone->sectors)
> zone++;
>
> I replaced it with the code :
> zone = &conf->strip_zone[0];
> while (sector >= zone->zone_start + zone->sectors)
> zone++;
> and all is fine . why do we need the hashing/spacing complication ?
> thank you
> raz
(Sorry for the delay in replying).
The existence of the hashing function predates my involvement with md.
As I understand it, the purpose was do perform the lookup as fast as
possible. Rather than search through a list, just go straight to the
correct point in the list.
The original code did not have the "while ... zone++". It just has a
simple "if" - either the right location was "this" one or the next
one, based on a similar test.
I added the while when I changed the hash_table to use kmalloc rather
than vmalloc. In order to ensure the hash table never exceeded one
page, I had to allow that occasionally we had to probe more than one
location in the table. Hence the 'while'.
On reflection, I am not convinced that the hash really does add value.
You cannot have more entries in the list than there are drives, and
you usually have much fewer.
Given that consecutive entries in the list are likely to be in the
same cache line, and the hash_table is in a totally different page,
probing 3 or 4 locations in the list is probably faster than doing a
lookup in the hash table.
And as we would be able to get rid of that sector_div, we would
probably get even more saving.
The only cost would be if someone had a raid0 with lots of devices all
of very different sizes. I suspect that case does not need to be
optimised for.
So I would probably be happy to accept a patch which removed that hash
table.
NeilBrown
next prev parent reply other threads:[~2009-05-12 22:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-03 13:29 raid0 hashing funtion Raz
2009-05-12 22:12 ` Neil Brown [this message]
2009-05-13 13:18 ` Andre Noll
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=18953.62556.265428.572219@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=raziebe@gmail.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