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: <20070306194255.GA5524@martell.zuzino.mipt.ru>
Date:	Tue, 6 Mar 2007 22:42:56 +0300
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	David Howells <dhowells@...hat.com>
Cc:	torvalds@...l.org, akpm@...l.org, benh@...nel.crashing.org,
	linux-kernel@...r.kernel.org, hpa@...or.com,
	johannes@...solutions.net
Subject: Re: [PATCH] Fix get_order() [try #2]

On Tue, Mar 06, 2007 at 06:34:26PM +0000, David Howells wrote:
> Provide an ilog2_up() that rounds its result up (ilog2() rounds down).
>
> Fix get_order() to use ilog2_up() not ilog2() to get the correct rounding.
>
> Adjust the documentation surrounding ilog2() and co. to indicate what rounding
> they perform.
>
> Fix roundup_pow_of_two(1) to give 1, not 0.

> --- a/include/asm-generic/page.h
> +++ b/include/asm-generic/page.h
> @@ -17,11 +17,15 @@ static inline __attribute__((const))
>  int __get_order(unsigned long size, int page_shift)
>  {
>  #if BITS_PER_LONG == 32 && defined(ARCH_HAS_ILOG2_U32)

There is no such thing except on FRV, where it's redundant.

				      CONFIG_ARCH_HAS_ILOG2_U32
				      ^^^^^^

> -	int order = __ilog2_u32(size) - page_shift;
> -	return order >= 0 ? order : 0;
> +	if (size <= (1UL << page_shift))
> +		return 0;
> +	else
> +		return __ilog2_u32(size - 1) + 1 - page_shift;
>  #elif BITS_PER_LONG == 64 && defined(ARCH_HAS_ILOG2_U64)

ditto

> -	int order = __ilog2_u64(size) - page_shift;
> -	return order >= 0 ? order : 0;
> +	if (size <= (1UL << page_shift))
> +		return 0;
> +	else
> +		return __ilog2_u64(size - 1) + 1 - page_shift;
>  #else
>  	int order;

-
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