Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754899Ab1EBRgx (ORCPT ); Mon, 2 May 2011 13:36:53 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:49713 "EHLO e9.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752453Ab1EBRgw (ORCPT ); Mon, 2 May 2011 13:36:52 -0400 Subject: Re: [PATCH] flex_array: avoid divisions when accessing elements From: Dave Hansen To: Eric Paris Cc: linux-kernel@vger.kernel.org, Jesse Gross , David Rientjes , Andrew Morton In-Reply-To: <1304357194-19308-1-git-send-email-eparis@redhat.com> References: <1304357194-19308-1-git-send-email-eparis@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Date: Mon, 02 May 2011 10:36:45 -0700 Message-ID: <1304357805.30823.18.camel@nimitz> Mime-Version: 1.0 X-Mailer: Evolution 2.32.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1181 Lines: 27 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 > Cc: David Rientjes > Cc: Eric Paris > Signed-off-by: Andrew Morton > [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 This seems sane to me, especially in the element access case. Acked-by: Dave Hansen -- Dave -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/