RE: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-27 Thread David Laight
> Moreover, if your thinking is that we do not need a static inline > function replicated at every caller, maybe we should introduce a > lib/hashtable.c that implements those 2 functions. That was my thought... Given their nature, I'd guess they aren't critical path. Probably not worth adding an e

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-27 Thread Steven Rostedt
On Thu, 2012-09-27 at 09:11 -0400, Mathieu Desnoyers wrote: > AFAIK, gcc nowadays use "inline" only as a hint Only if CONFIG_OPTIMIZE_INLINING is set. >From include/linux/compiler-gcc.h: #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-27 Thread Mathieu Desnoyers
* Sasha Levin (levinsasha...@gmail.com) wrote: > On 09/27/2012 10:25 AM, David Laight wrote: > And even then, if we would do: > > for (i = 0; i < HASH_SIZE(hashtable); i++) > if (!hlist_empty(&hashtable[i])) > break; >

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-27 Thread Mathieu Desnoyers
* David Laight (david.lai...@aculab.com) wrote: > > > > And even then, if we would do: > > > > > > > > for (i = 0; i < HASH_SIZE(hashtable); i++) > > > > if (!hlist_empty(&hashtable[i])) > > > > break; > > > > > > > > return i >= HASH_SIZE(has

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-27 Thread Steven Rostedt
On Thu, 2012-09-27 at 10:33 +0200, Sasha Levin wrote: > Right, the flag thing in the macro was there just to make it work properly as > a macro. > > >> Agreed that the flags should be removed. Moving to define + static > >> inline is still important though. > > > > Not sure I'd bother making th

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-27 Thread Sasha Levin
On 09/27/2012 10:25 AM, David Laight wrote: And even then, if we would do: for (i = 0; i < HASH_SIZE(hashtable); i++) if (!hlist_empty(&hashtable[i])) break; return i >= HASH_SIZE(hashtable); What happens if the last e

RE: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-27 Thread David Laight
> > > And even then, if we would do: > > > > > > for (i = 0; i < HASH_SIZE(hashtable); i++) > > > if (!hlist_empty(&hashtable[i])) > > > break; > > > > > > return i >= HASH_SIZE(hashtable); > > > > > > What happens if the last entry of the table is non-empty ? > > >

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-26 Thread Mathieu Desnoyers
* Steven Rostedt (rost...@goodmis.org) wrote: > On Wed, 2012-09-26 at 10:39 -0400, Mathieu Desnoyers wrote: > > * Sasha Levin (levinsasha...@gmail.com) wrote: > > > On 09/26/2012 03:59 PM, Steven Rostedt wrote: > > > > On Wed, 2012-09-26 at 14:45 +0100, David Laight wrote: > > > >> Amazing how some

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-26 Thread Steven Rostedt
On Wed, 2012-09-26 at 10:39 -0400, Mathieu Desnoyers wrote: > * Sasha Levin (levinsasha...@gmail.com) wrote: > > On 09/26/2012 03:59 PM, Steven Rostedt wrote: > > > On Wed, 2012-09-26 at 14:45 +0100, David Laight wrote: > > >> Amazing how something simple gets lots of comments and versions :-) > >

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-26 Thread Mathieu Desnoyers
* Sasha Levin (levinsasha...@gmail.com) wrote: > On 09/26/2012 03:59 PM, Steven Rostedt wrote: > > On Wed, 2012-09-26 at 14:45 +0100, David Laight wrote: > >> Amazing how something simple gets lots of comments and versions :-) > >> > >>> ... > >>> + * This has to be a macro since HASH_BITS() will n

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-26 Thread Mathieu Desnoyers
* David Laight (david.lai...@aculab.com) wrote: > Amazing how something simple gets lots of comments and versions :-) > > > ... > > + * This has to be a macro since HASH_BITS() will not work on pointers since > > + * it calculates the size during preprocessing. > > + */ > > +#define hash_empty(has

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-26 Thread Sasha Levin
On 09/26/2012 03:59 PM, Steven Rostedt wrote: > On Wed, 2012-09-26 at 14:45 +0100, David Laight wrote: >> Amazing how something simple gets lots of comments and versions :-) >> >>> ... >>> + * This has to be a macro since HASH_BITS() will not work on pointers since >>> + * it calculates the size du

Re: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-26 Thread Steven Rostedt
On Wed, 2012-09-26 at 14:45 +0100, David Laight wrote: > Amazing how something simple gets lots of comments and versions :-) > > > ... > > + * This has to be a macro since HASH_BITS() will not work on pointers since > > + * it calculates the size during preprocessing. > > + */ > > +#define hash_em

RE: [PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-26 Thread David Laight
Amazing how something simple gets lots of comments and versions :-) > ... > + * This has to be a macro since HASH_BITS() will not work on pointers since > + * it calculates the size during preprocessing. > + */ > +#define hash_empty(hashtable) >

[PATCH v6] hashtable: introduce a small and naive hashtable

2012-09-26 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 --- Changes since v5: - Fix hash_init. - Clarify this implementation deals with statically allocated hashtables only. i