Re: [PATCH] flex_array: avoid divisions when accessing elements

From: Jesse Gross
Date: Mon May 02 2011 - 16:24:04 EST


On Mon, May 2, 2011 at 10:36 AM, Dave Hansen <dave@xxxxxxxxxxxxxxxxxx> wrote:
> On Mon, 2011-05-02 at 13:26 -0400, Eric Paris wrote:
>> On most architectures division is an expensive operation and accessing an
>> element currently requires four of them.  This performance penalty
>> effectively precludes flex arrays from being used on any kind of fast
>> path.  However, two of these divisions can be handled at creation time and
>> the others can be replaced by a reciprocal divide, completely avoiding
>> real divisions on access.
>>
>> Signed-off-by: Jesse Gross <jesse@xxxxxxxxxx>
>> Cc: David Rientjes <rientjes@xxxxxxxxxx>
>> Cc: Eric Paris <eparis@xxxxxxxxxx>
>> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>> [rebase on top of changes to support 0 len elements: eparis]
>> [initialize part_nr when array fits entirely in base: eparis]
>> Signed-off-by: Eric Paris <eparis@xxxxxxxxxx>
>
> This seems sane to me, especially in the element access case.
>
> Acked-by: Dave Hansen <dave@xxxxxxxxxxxxxxxxxx>

Thanks Eric!
--
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/