From: Jiri Pirko <jpirko@redhat.com>
To: Ben Hutchings <bhutchings@solarflare.com>
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
Date: Mon, 18 Jan 2010 22:30:29 +0100 [thread overview]
Message-ID: <20100118213028.GD4521@psychotron.redhat.com> (raw)
In-Reply-To: <1263849258.3667.43.camel@achroite.uk.solarflarecom.com>
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.
>
prev parent reply other threads:[~2010-01-18 21:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-18 16:23 [PATCH] list.h: add list_for_each_struct_entry macro Jiri Pirko
2010-01-18 17:17 ` Ben Hutchings
2010-01-18 21:07 ` Jiri Pirko
2010-01-18 21:14 ` Ben Hutchings
2010-01-18 21:30 ` Jiri Pirko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100118213028.GD4521@psychotron.redhat.com \
--to=jpirko@redhat.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).