Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Steven Rostedt
On Thu, 2012-09-06 at 18:21 +0200, Sasha Levin wrote: > On 09/06/2012 06:00 PM, Steven Rostedt wrote: > >> > I think that that code doesn't make sense. The users of hlist_for_each_* > >> > aren't > >> > supposed to be changing the loop cursor. > > I totally agree. Modifying the 'node' pointer is j

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Mathieu Desnoyers
* Sasha Levin (levinsasha...@gmail.com) wrote: > On 09/06/2012 06:50 PM, Mathieu Desnoyers wrote: > > * Sasha Levin (levinsasha...@gmail.com) wrote: > >> On 09/06/2012 06:00 PM, Steven Rostedt wrote: > > I think that that code doesn't make sense. The users of > > hlist_for_each_* aren't >

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Sasha Levin
On 09/06/2012 06:50 PM, Mathieu Desnoyers wrote: > * Sasha Levin (levinsasha...@gmail.com) wrote: >> On 09/06/2012 06:00 PM, Steven Rostedt wrote: > I think that that code doesn't make sense. The users of hlist_for_each_* > aren't > supposed to be changing the loop cursor. >>> I totall

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Mathieu Desnoyers
* Sasha Levin (levinsasha...@gmail.com) wrote: > On 09/06/2012 06:00 PM, Steven Rostedt wrote: > >> > I think that that code doesn't make sense. The users of hlist_for_each_* > >> > aren't > >> > supposed to be changing the loop cursor. > > I totally agree. Modifying the 'node' pointer is just ask

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Sasha Levin
On 09/06/2012 06:00 PM, Steven Rostedt wrote: >> > I think that that code doesn't make sense. The users of hlist_for_each_* >> > aren't >> > supposed to be changing the loop cursor. > I totally agree. Modifying the 'node' pointer is just asking for issues. > Yes that is error prone, but not due to

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Steven Rostedt
On Thu, 2012-09-06 at 17:49 +0200, Sasha Levin wrote: > > > Looks reasonable. However, it would break (or rather, not break) on > > code like this: > > > > hash_for_each_entry(...) { > > if (...) { > > foo(node); > > node = NULL; ug, I di

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Sasha Levin
On 09/06/2012 04:55 PM, Josh Triplett wrote: > On Thu, Sep 06, 2012 at 03:53:58PM +0200, Sasha Levin wrote: >> On 09/04/2012 07:01 PM, Mathieu Desnoyers wrote: #define do_for_each_ftrace_rec(pg, rec) \ > for (pg = ftrace_pages_start, r

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Steven Rostedt
On Thu, 2012-09-06 at 07:55 -0700, Josh Triplett wrote: > > 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) > > > > Looks reasonable.

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Josh Triplett
On Thu, Sep 06, 2012 at 03:53:58PM +0200, Sasha Levin wrote: > On 09/04/2012 07:01 PM, Mathieu Desnoyers wrote: > >> #define do_for_each_ftrace_rec(pg, rec) > >> \ > >> > for (pg = ftrace_pages_start, rec = &pg->records[pg->index]; > >> >

RE: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread David Laight
> 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) I'd take a look at the generated code. Might come out a bit better if the condition is ch

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Mathieu Desnoyers
* Sasha Levin (levinsasha...@gmail.com) wrote: > On 09/04/2012 07:01 PM, Mathieu Desnoyers wrote: > >> #define do_for_each_ftrace_rec(pg, rec) > >> \ > >> > for (pg = ftrace_pages_start, rec = &pg->records[pg->index]; > >> > \ > >> >

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Pedro Alves
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,

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-06 Thread Sasha Levin
On 09/04/2012 07:01 PM, Mathieu Desnoyers wrote: >> #define do_for_each_ftrace_rec(pg, rec) >> \ >> > for (pg = ftrace_pages_start, rec = &pg->records[pg->index]; >> > \ >> > pg && rec == &pg->records[pg->index];

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Steven Rostedt
On Tue, 2012-09-04 at 23:58 +0100, Pedro Alves wrote: > Not true. The comma operator introduces a sequence point. It's the comma > that separates function parameters that doesn't guarantee ordering. Bah! C language is almost as confusing as English. -- Steve -- To unsubscribe from this list

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Pedro Alves
On 09/04/2012 11:41 PM, Steven Rostedt wrote: > Ah, I missed the condition with the rec == &pg->records[pg->index]. But > if ftrace_pages_start is NULL, the rec = &pg->records[pg->index] will > fault. Right. > > You could do something like rec = pg ? &pg->records[pg->index] : NULL, Right. > bu

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Steven Rostedt
On Tue, 2012-09-04 at 22:51 +0100, Pedro Alves wrote: > On 09/04/2012 09:59 PM, Steven Rostedt wrote: > > On Tue, 2012-09-04 at 18:21 +0100, Pedro Alves wrote: > >> On 09/04/2012 06:17 PM, Steven Rostedt wrote: > >>> On Tue, 2012-09-04 at 17:40 +0100, Pedro Alves wrote: > >>> > BTW, you can al

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Pedro Alves
On 09/04/2012 09:59 PM, Steven Rostedt wrote: > On Tue, 2012-09-04 at 18:21 +0100, Pedro Alves wrote: >> On 09/04/2012 06:17 PM, Steven Rostedt wrote: >>> On Tue, 2012-09-04 at 17:40 +0100, Pedro Alves wrote: >>> BTW, you can also go a step further and remove the need to close with doubl

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Steven Rostedt
On Tue, 2012-09-04 at 18:21 +0100, Pedro Alves wrote: > On 09/04/2012 06:17 PM, Steven Rostedt wrote: > > On Tue, 2012-09-04 at 17:40 +0100, Pedro Alves wrote: > > > >> BTW, you can also go a step further and remove the need to close with > >> double }}, > >> with something like: > >> > >> #defin

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Pedro Alves
On 09/04/2012 06:17 PM, Steven Rostedt wrote: > On Tue, 2012-09-04 at 17:40 +0100, Pedro Alves wrote: > >> BTW, you can also go a step further and remove the need to close with double >> }}, >> with something like: >> >> #define do_for_each_ftrace_rec(pg, rec)

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Steven Rostedt
On Tue, 2012-09-04 at 17:40 +0100, Pedro Alves wrote: > BTW, you can also go a step further and remove the need to close with double > }}, > with something like: > > #define do_for_each_ftrace_rec(pg, rec) >\ > for (pg = ftrace_pages_start, rec

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Mathieu Desnoyers
* Pedro Alves (pal...@redhat.com) wrote: > On 09/04/2012 05:30 PM, Pedro Alves wrote: > > On 09/04/2012 04:35 PM, Steven Rostedt wrote: > >> On Tue, 2012-08-28 at 19:00 -0400, Mathieu Desnoyers wrote: > >> > >>> Looking again at: > >>> > >>> +#define hash_for_each_size(name, bits, bkt, node, obj, m

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Pedro Alves
On 09/04/2012 05:30 PM, Pedro Alves wrote: > On 09/04/2012 04:35 PM, Steven Rostedt wrote: >> On Tue, 2012-08-28 at 19:00 -0400, Mathieu Desnoyers wrote: >> >>> Looking again at: >>> >>> +#define hash_for_each_size(name, bits, bkt, node, obj, member) >>> \ >>> + for (bkt = 0;

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Mathieu Desnoyers
* Steven Rostedt (rost...@goodmis.org) wrote: > On Tue, 2012-08-28 at 19:00 -0400, Mathieu Desnoyers wrote: > > > Looking again at: > > > > +#define hash_for_each_size(name, bits, bkt, node, obj, member) > > \ > > + for (bkt = 0; bkt < HASH_SIZE(bits); bkt++)

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Pedro Alves
On 09/04/2012 04:35 PM, Steven Rostedt wrote: > On Tue, 2012-08-28 at 19:00 -0400, Mathieu Desnoyers wrote: > >> Looking again at: >> >> +#define hash_for_each_size(name, bits, bkt, node, obj, member) >>\ >> + for (bkt = 0; bkt < HASH_SIZE(bits); bkt++)

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-09-04 Thread Steven Rostedt
On Tue, 2012-08-28 at 19:00 -0400, Mathieu Desnoyers wrote: > Looking again at: > > +#define hash_for_each_size(name, bits, bkt, node, obj, member) > \ > + for (bkt = 0; bkt < HASH_SIZE(bits); bkt++) > \ > + hlist_for_each_entry(ob

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-28 Thread Mathieu Desnoyers
* Mathieu Desnoyers (mathieu.desnoy...@efficios.com) wrote: > * Sasha Levin (levinsasha...@gmail.com) wrote: > > On 08/28/2012 12:11 PM, Mathieu Desnoyers wrote: > > > * Sasha Levin (levinsasha...@gmail.com) wrote: > > >> On 08/25/2012 06:24 AM, Mathieu Desnoyers wrote: > > >>> * Tejun Heo (t...@ke

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-28 Thread Mathieu Desnoyers
* Sasha Levin (levinsasha...@gmail.com) wrote: > On 08/28/2012 12:11 PM, Mathieu Desnoyers wrote: > > * Sasha Levin (levinsasha...@gmail.com) wrote: > >> On 08/25/2012 06:24 AM, Mathieu Desnoyers wrote: > >>> * Tejun Heo (t...@kernel.org) wrote: > Hello, > > On Sat, Aug 25, 2012 at 1

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-28 Thread Sasha Levin
On 08/28/2012 12:11 PM, Mathieu Desnoyers wrote: > * Sasha Levin (levinsasha...@gmail.com) wrote: >> On 08/25/2012 06:24 AM, Mathieu Desnoyers wrote: >>> * Tejun Heo (t...@kernel.org) wrote: Hello, On Sat, Aug 25, 2012 at 12:59:25AM +0200, Sasha Levin wrote: > Thats the thing, th

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-28 Thread Mathieu Desnoyers
* Sasha Levin (levinsasha...@gmail.com) wrote: > On 08/25/2012 06:24 AM, Mathieu Desnoyers wrote: > > * Tejun Heo (t...@kernel.org) wrote: > >> Hello, > >> > >> On Sat, Aug 25, 2012 at 12:59:25AM +0200, Sasha Levin wrote: > >>> Thats the thing, the amount of things of things you can do with a given

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-28 Thread Sasha Levin
On 08/25/2012 06:24 AM, Mathieu Desnoyers wrote: > * Tejun Heo (t...@kernel.org) wrote: >> Hello, >> >> On Sat, Aug 25, 2012 at 12:59:25AM +0200, Sasha Levin wrote: >>> Thats the thing, the amount of things of things you can do with a given >>> bucket >>> is very limited. You can't add entries to

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Mathieu Desnoyers
* Tejun Heo (t...@kernel.org) wrote: > Hello, > > On Sat, Aug 25, 2012 at 12:59:25AM +0200, Sasha Levin wrote: > > Thats the thing, the amount of things of things you can do with a given > > bucket > > is very limited. You can't add entries to any point besides the head > > (without > > walking

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Tejun Heo
Hello, On Sat, Aug 25, 2012 at 12:59:25AM +0200, Sasha Levin wrote: > Thats the thing, the amount of things of things you can do with a given bucket > is very limited. You can't add entries to any point besides the head (without > walking the entire list). Kinda my point. We already have all the

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Sasha Levin
>> Why do we need hash_head/hash_for_each_head()? I haven't stumbled on a place >> yet >> that needed direct access to the bucket itself. > > Because whole hash table walking is much less common and we can avoid > another full set of iterators. I don't agree. Out of 32 places which now use a has

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Tejun Heo
Hello, On Fri, Aug 24, 2012 at 10:53:45PM +0200, Sasha Levin wrote: > Yup, but we could be using the same API for dynamic non-resizable and static > if > we go with the DECLARE/hash_init. We could switch between them (and other > implementations) without having to change the code. I think it's b

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Sasha Levin
On 08/24/2012 10:33 PM, Tejun Heo wrote: > Hello, Sasha. > > On Fri, Aug 24, 2012 at 10:11:55PM +0200, Sasha Levin wrote: >>> If this implementation is about the common trivial case, why not just >>> have the usual DECLARE/DEFINE_HASHTABLE() combination? >> >> When we add the dynamic non-resizable

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Tejun Heo
Hello, Sasha. On Fri, Aug 24, 2012 at 10:11:55PM +0200, Sasha Levin wrote: > > If this implementation is about the common trivial case, why not just > > have the usual DECLARE/DEFINE_HASHTABLE() combination? > > When we add the dynamic non-resizable support, how would DEFINE_HASHTABLE() > look?

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Sasha Levin
On 08/24/2012 09:59 PM, Tejun Heo wrote: > Hello, Sasha. > > On Fri, Aug 24, 2012 at 09:47:19PM +0200, Sasha Levin wrote: >>> I think this is problematic. It looks exactly like other existing >>> DEFINE macros yet what its semantics is different. I don't think >>> that's a good idea. >> >> I can

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Tejun Heo
Hello, Sasha. On Fri, Aug 24, 2012 at 09:47:19PM +0200, Sasha Levin wrote: > > I think this is problematic. It looks exactly like other existing > > DEFINE macros yet what its semantics is different. I don't think > > that's a good idea. > > I can switch that to be DECLARE_HASHTABLE() if the is

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-24 Thread Sasha Levin
On 08/23/2012 10:04 PM, Tejun Heo wrote: > Hello, Sasha. > > On Thu, Aug 23, 2012 at 02:24:32AM +0200, Sasha Levin wrote: >>> I think the almost trivial nature of hlist hashtables makes this a bit >>> tricky and I'm not very sure but having this combinatory explosion is >>> a bit dazzling when the

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-23 Thread Tejun Heo
Hello, Sasha. On Thu, Aug 23, 2012 at 02:24:32AM +0200, Sasha Levin wrote: > > I think the almost trivial nature of hlist hashtables makes this a bit > > tricky and I'm not very sure but having this combinatory explosion is > > a bit dazzling when the same functionality can be achieved by simply >

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-22 Thread Sasha Levin
Hi Tejun, On 08/22/2012 08:01 PM, Tejun Heo wrote: > Hello, Sasha. > > On Wed, Aug 22, 2012 at 04:26:56AM +0200, Sasha Levin wrote: >> +#define DEFINE_HASHTABLE(name, bits) >> \ >> +struct hlist_head name[HASH_SIZE(bits)]; > > Shouldn't this be somethi

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-22 Thread Ryan Mallon
On 23/08/12 04:01, Tejun Heo wrote: > Hello, Sasha. > > On Wed, Aug 22, 2012 at 04:26:56AM +0200, Sasha Levin wrote: >> +#define DEFINE_HASHTABLE(name, bits) >> \ >> +struct hlist_head name[HASH_SIZE(bits)]; > > Shouldn't this be something like the foll

Re: [PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-22 Thread Tejun Heo
Hello, Sasha. On Wed, Aug 22, 2012 at 04:26:56AM +0200, Sasha Levin wrote: > +#define DEFINE_HASHTABLE(name, bits) \ > + struct hlist_head name[HASH_SIZE(bits)]; Shouldn't this be something like the following? #define DEFINE_HASHTABLE(name, bits)

[PATCH v3 01/17] hashtable: introduce a small and naive hashtable

2012-08-21 Thread Sasha Levin
This hashtable implementation is using hlist buckets to provide a simple hashtable to prevent it from getting reimplemented all over the kernel. Signed-off-by: Sasha Levin --- include/linux/hashtable.h | 291 + 1 files changed, 291 insertions(+), 0 de