lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <506310AA.2050700@gmail.com>
Date:	Wed, 26 Sep 2012 16:26:50 +0200
From:	Sasha Levin <levinsasha928@...il.com>
To:	Steven Rostedt <rostedt@...dmis.org>
CC:	David Laight <David.Laight@...LAB.COM>,
	torvalds@...ux-foundation.org, tj@...nel.org,
	akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
	ebiederm@...ssion.com, mathieu.desnoyers@...icios.com,
	neilb@...e.de, bfields@...ldses.org, ejt@...hat.com,
	snitzer@...hat.com, edumazet@...gle.com, josh@...htriplett.org,
	rmallon@...il.com, palves@...hat.com
Subject: Re: [PATCH v6] hashtable: introduce a small and naive hashtable

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 during preprocessing.
>>> + */
>>> +#define hash_empty(hashtable)							\
>>> +({										\
>>> +	int __i;								\
>>> +	bool __ret = true;							\
>>> +										\
>>> +	for (__i = 0; __i < HASH_SIZE(hashtable); __i++)			\
>>> +		if (!hlist_empty(&hashtable[__i]))				\
>>> +			__ret = false;						\
>>> +										\
>>> +	__ret;									\
>>> +})
>>
>> Actually you could have a #define that calls a function
>> passing in the address and size.
> 
> Probably would be cleaner to do so.

I think it's worth it if it was more complex than a simple loop. We were doing a similar thing with the _size() functions (see
version 4 of this patch), but decided to remove it since it was becoming too complex.
> 
> 
>> Also, should the loop have a 'break' in it?
> 
> Yeah it should, and could do:
> 
> 	for (i = 0; i < HASH_SIZE(hashtable); i++)
> 		if (!hlist_empty(&hashtable[i]))
> 			break;
> 
> 	return i < HASH_SIZE(hashtable);

Right.


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ