Re: [PATCH 1/2] lib: more scalable list_sort()
From: Don Mullis
Date: Thu Jan 21 2010 - 22:17:26 EST
Andi Kleen <andi@xxxxxxxxxxxxxx> writes:
> On Wed, Jan 20, 2010 at 08:51:26PM -0800, Don Mullis wrote:
>> The use of list_sort() by UBIFS looks like it could generate long
>> lists; this alternative implementation scales better, reaching ~3x
>> performance gain as list length approaches the L2 cache size.
> If this can really be called with long lists
> the function likely needs (optional) need_resched()s
> Otherwise it could ruin scheduling latencies.
Being just a dumb library routine, list_sort() has no idea what context
it's been called in, how long a list a particular client could pass in,
nor how expensive the client's cmp() callback might be.
The cmp() callback already passes back a client-private pointer.
Hanging off of this could be a count of calls, or timing information,
maintained by the client. Whenever some threshold is reached, the
client's cmp() could do whatever good CPU-sharing citizenship required.
This doesn't address the final O(n) pass over the list to restore the
back links. So the cost of that pass would dictate the upper limit on
list length for a client already using the cmp() call-counting/timing
trick to break up the earlier compare-and-merge passes.
If that's not good enough, a more complicated solution would be
required. But I'm hoping we don't need to go there yet.
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/