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: <564D8E67.6030706@gmail.com>
Date:	Thu, 19 Nov 2015 16:55:03 +0800
From:	hejianet <hejianet@...il.com>
To:	xinhui <xinhui@...ux.vnet.ibm.com>, linux-kernel@...r.kernel.org,
	linux-arch@...r.kernel.org
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Denys Vlasenko <dvlasenk@...hat.com>,
	Kyungmin Park <kyungmin.park@...sung.com>,
	Michal Nazarewicz <mina86@...a86.com>,
	Yury Norov <yury.norov@...il.com>, Tejun Heo <tj@...nel.org>,
	Martin Kepplinger <martink@...teo.de>,
	George Spelvin <linux@...izon.com>,
	Ingo Molnar <mingo@...nel.org>, Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v2 2/3] lib: Introduce 2 bit ops api:
 all_is_bit_{one,zero}

Thanks, I will add it in next verison
B.R.
Justin

在 11/19/15 4:40 PM, xinhui 写道:
> hi, jia
>     Nice patch. But I have one minor question. see inline comments.
>
> On 2015/11/19 14:48, Jia He wrote:
>> This patch introduces 2 lightweight bit api.
>> all_bit_is_zero return 1 if the bit string is all zero.
>> The addr is the start address, the size is the bit size of the bit 
>> string.
>> all_bit_is_one is the opposite.
>>
>> Signed-off-by: Jia He <hejianet@...il.com>
>> ---
>>   lib/find_bit.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 50 insertions(+)
>>
>> diff --git a/lib/find_bit.c b/lib/find_bit.c
>> index 18072ea..1d56d8d 100644
>> --- a/lib/find_bit.c
>> +++ b/lib/find_bit.c
>> @@ -131,6 +131,56 @@ unsigned long find_last_bit(const unsigned long 
>> *addr, unsigned long size)
>>   EXPORT_SYMBOL(find_last_bit);
>>   #endif
>>
>> +#ifndef all_bit_is_zero
>> +/*
>> + * return val: 1 means all bit is zero
>> + */
>> +unsigned int all_bit_is_zero(const unsigned long *addr, unsigned size)
>> +{
>  Seems better that size should be type of "unsigned long". Otherwise 
> I'm afraid when we compare idx * BITS_PER_LONG with size, there might 
> be overflow issue.
>
>> +    unsigned long idx;
>> +    unsigned long mask = size;
>> +
>> +    if (unlikely(size == 0))
>> +        return 1;
>> +
>> +    if (size > BITS_PER_LONG) {
>> +        for (idx = 0; idx * BITS_PER_LONG < size; idx++)
>> +            if (addr[idx])
>> +                return 0;
>> +
>> +        mask = size - (idx - 1) * BITS_PER_LONG;
>> +    }
>> +
>> +    return !(*addr & BITMAP_LAST_WORD_MASK(mask));
>> +}
>> +EXPORT_SYMBOL(all_bit_is_zero);
>> +#endif
>> +
>> +#ifndef all_bit_is_one
>> +/*
>> + * return val: 1 means all bit is one
>> + */
>> +unsigned int all_bit_is_one(const unsigned long *addr, unsigned size)
>> +{
> this argc of size should be type of "unsigned long", too.
>
> thanks
> xinhui
>
>> +    unsigned long idx;
>> +    unsigned long mask = size;
>> +
>> +    if (unlikely(size == 0))
>> +        return 1;
>> +
>> +    if (size > BITS_PER_LONG) {
>> +        for (idx = 0; idx * BITS_PER_LONG < size; idx++)
>> +            if (~addr[idx])
>> +                return 0;
>> +
>> +        mask = size - (idx - 1) * BITS_PER_LONG;
>> +    }
>> +
>> +    return !(~(*addr) & BITMAP_LAST_WORD_MASK(mask));
>> +}
>> +EXPORT_SYMBOL(all_bit_is_one);
>> +#endif
>> +
>>   #ifdef __BIG_ENDIAN
>>
>>   /* include/linux/byteorder does not support "unsigned long" type */
>>
>
> -- 
> 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/
>

--
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