Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756083Ab0ARVaw (ORCPT ); Mon, 18 Jan 2010 16:30:52 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756052Ab0ARVav (ORCPT ); Mon, 18 Jan 2010 16:30:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52561 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755761Ab0ARVas (ORCPT ); Mon, 18 Jan 2010 16:30:48 -0500 Date: Mon, 18 Jan 2010 22:30:29 +0100 From: Jiri Pirko To: Ben Hutchings Cc: linux-kernel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org Subject: Re: [PATCH] list.h: add list_for_each_struct_entry macro Message-ID: <20100118213028.GD4521@psychotron.redhat.com> References: <20100118162338.GD4229@psychotron.lab.eng.brq.redhat.com> <1263835033.3667.23.camel@achroite.uk.solarflarecom.com> <20100118210718.GC4521@psychotron.redhat.com> <1263849258.3667.43.camel@achroite.uk.solarflarecom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1263849258.3667.43.camel@achroite.uk.solarflarecom.com> User-Agent: Mutt/1.5.20 (2009-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1648 Lines: 41 Mon, Jan 18, 2010 at 10:14:18PM CET, bhutchings@solarflare.com wrote: >On Mon, 2010-01-18 at 22:07 +0100, Jiri Pirko wrote: >> Mon, Jan 18, 2010 at 06:17:13PM CET, bhutchings@solarflare.com wrote: >[...] >> >#define list_for_each_struct_entry(pos, head, type, posmember, member) \ >> > for (pos = list_empty(head) ? NULL : \ >> > &list_first_entry(head, type, member)->posmember; \ >> > prefetch(container_of(pos, type, posmember)->member.next), pos; \ >> > pos = list_is_last(&container_of(pos, type, posmember)->member, \ >> > head) ? NULL : \ >> > &list_entry(container_of(pos, type, posmember)->member.next, \ >> > type, member)->posmember) >> > >> >> At the first glance, this would take even more cputime for lists longer >> than 2 or so, wouldn't it? > >If you're concerned about speed, measure it, don't guess. Well I just see extra code "list_is_last(&container_of(pos, type, posmember)->member, head)" to be done in each iteration. Also I do not see additional value in doing this. (Unlike in checking list_empty(head)). Anyway, if you want to use this optimization, I guess more code in list.h could use this. Jirka > >Ben. > >-- >Ben Hutchings, Senior Software Engineer, Solarflare Communications >Not speaking for my employer; that's the marketing department's job. >They asked us to note that Solarflare product names are trademarked. > -- 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/