Re: [PATCH] list.h: add list_for_each_struct_entry macro

From: Jiri Pirko
Date: Mon Jan 18 2010 - 16:30:56 EST


Mon, Jan 18, 2010 at 10:14:18PM CET, bhutchings@xxxxxxxxxxxxxx wrote:
>On Mon, 2010-01-18 at 22:07 +0100, Jiri Pirko wrote:
>> Mon, Jan 18, 2010 at 06:17:13PM CET, bhutchings@xxxxxxxxxxxxxx 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/