From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763708AbYEFCJs (ORCPT ); Mon, 5 May 2008 22:09:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757344AbYEFCJg (ORCPT ); Mon, 5 May 2008 22:09:36 -0400 Received: from x35.xmailserver.org ([64.71.152.41]:38267 "EHLO x35.xmailserver.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757230AbYEFCJf (ORCPT ); Mon, 5 May 2008 22:09:35 -0400 X-AuthUser: davidel@xmailserver.org Date: Mon, 5 May 2008 19:09:32 -0700 (PDT) From: Davide Libenzi X-X-Sender: davide@alien.or.mcafeemobile.com To: Andrew Morton cc: Ulrich Drepper , Linux Kernel Mailing List , netdev@vger.kernel.org, mtk.manpages@gmail.com, Linus Torvalds Subject: Re: [PATCH 01/18] flag parameters: helper function In-Reply-To: <20080505185103.b9299541.akpm@linux-foundation.org> Message-ID: References: <200805050342.m453gkY4029814@devserv.devel.redhat.com> <20080505185103.b9299541.akpm@linux-foundation.org> X-GPG-FINGRPRINT: CFAE 5BEE FD36 F65E E640 56FE 0974 BF23 270F 474E X-GPG-PUBLIC_KEY: http://www.xmailserver.org/davidel.asc MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 5 May 2008, Andrew Morton wrote: > > +int flags_remap(const struct flags_rmap *m, int n, > > + int f, int *rf) > > +{ > > + int i; > > + for (i = 0, *rf = 0; f && i < n; i++, m++) > > + if (f & m->f) { > > + *rf |= m->of; > > + f &= ~m->f; > > + } > > + return f; > > +} > > hm, that looks expensive. The compiler will need to generate a deref of m > and rf multiple times around the loop. Copying them into locals does > improve that a lot. That's not a fast path. The extra cycles in the ldr/str get lost in the overall syscall cost. But I guess Uli (or myself afterward) can change it if you fill picky about it ;) > I'm only on [1/18] so I don't know how often this code gets executed. If > it's "on each open" then ouch, perhaps it might even be worth investigating a > table-based implementation. > > Also: sorry, but ugh-at-the-naming. We don't *gain* anything from having > idenitifers called f, of, m, n and rf. And we lose quite a lot in > readability and understandability. It would be much nicer to invest a > little bit more typing-time here, IMO. Why? Don't you like nibble-sized variable names? :) Uli took my email-code as is, so either he changes it, or I'll post patches over it later. - Davide