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] [day] [month] [year] [list]
Message-ID: <87fx5z2gpv.fsf@basil.nowhere.org>
Date:	Fri, 22 Jan 2010 00:14:36 +0100
From:	Andi Kleen <andi@...stfloor.org>
To:	Christoph Lameter <cl@...ux-foundation.org>
Cc:	Yinghai Lu <yinghai@...nel.org>, Ingo Molnar <mingo@...e.hu>,
	Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Jesse Barnes <jbarnes@...tuousgeek.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org
Subject: Re: [PATCH 22/36] move round_up/down to kernel.h

Christoph Lameter <cl@...ux-foundation.org> writes:

> On Wed, 20 Jan 2010, Yinghai Lu wrote:
>
>> + * This looks more complex than it should be. But we need to
>> + * get the type for the ~ right in round_down (it needs to be
>> + * as wide as the result!), and we want to evaluate the macro
>> + * arguments just once each.
>> + */
>> +#define __round_mask(x,y) ((__typeof__(x))((y)-1))
>> +#define round_up(x,y) ((((x)-1) | __round_mask(x,y))+1)
>> +#define round_down(x,y) ((x) & ~__round_mask(x,y))
>> +
>>  #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
>>  #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
>>  #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
>
> So we are back to the earlier version.
>
> Two functions doing the same thing. round_up and roundup.
>
> If they are different(are they really used that way?) then they should
> have names that emphasize the difference.


round_up() basically only works for power of two, but they
should generate the same code for constants.

The only user right now is e820.c, but it uses the second
argument with non constants, so would generate a slower
true division with roundup() Right now it probably doesn't
make much difference because e820 lists are small, but I saw
a patchkit to let e820 replace bootmem and then they might
not be anymore.

-Andi

-- 
ak@...ux.intel.com -- Speaking for myself only.
--
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