[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5048B0F5.9040000@redhat.com>
Date: Thu, 06 Sep 2012 15:19:33 +0100
From: Pedro Alves <palves@...hat.com>
To: Sasha Levin <levinsasha928@...il.com>
CC: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Steven Rostedt <rostedt@...dmis.org>,
Tejun Heo <tj@...nel.org>, torvalds@...ux-foundation.org,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, paul.gortmaker@...driver.com,
davem@...emloft.net, mingo@...e.hu, ebiederm@...ssion.com,
aarcange@...hat.com, ericvh@...il.com, netdev@...r.kernel.org,
josh@...htriplett.org, eric.dumazet@...il.com, axboe@...nel.dk,
agk@...hat.com, dm-devel@...hat.com, neilb@...e.de,
ccaulfie@...hat.com, teigland@...hat.com,
Trond.Myklebust@...app.com, bfields@...ldses.org,
fweisbec@...il.com, jesse@...ira.com,
venkat.x.venkatsubra@...cle.com, ejt@...hat.com,
snitzer@...hat.com, edumazet@...gle.com, linux-nfs@...r.kernel.org,
dev@...nvswitch.org, rds-devel@....oracle.com, lw@...fujitsu.com
Subject: Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable
On 09/06/2012 02:53 PM, Sasha Levin wrote:
> So I think that for the hash iterator it might actually be simpler.
>
> My solution to making 'break' work in the iterator is:
>
> for (bkt = 0, node = NULL; bkt < HASH_SIZE(name) && node == NULL; bkt++)
> hlist_for_each_entry(obj, node, &name[bkt], member)
>
> We initialize our node loop cursor with NULL in the external loop, and the
> external loop will have a new condition to loop while that cursor is NULL.
>
> My logic is that we can only 'break' when we are iterating over an object in the
> internal loop. If we're iterating over an object in that loop then 'node != NULL'.
>
> This way, if we broke from within the internal loop, the external loop will see
> node as not NULL, and so it will stop looping itself. On the other hand, if the
> internal loop has actually ended, then node will be NULL, and the outer loop
> will keep running.
>
> Is there anything I've missed?
Looks right to me, from a cursory look at hlist_for_each_entry. That's exactly
what I meant with this most often being trivial when the inner loop's iterator
is a pointer that goes NULL at the end.
--
Pedro Alves
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists