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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 29 Jul 2008 10:02:51 +0200
From:	Joerg Roedel <joerg.roedel@....com>
To:	Yinghai Lu <yhlu.kernel@...il.com>
CC:	Ingo Molnar <mingo@...e.hu>, mingo@...hat.com, tglx@...utronix.de,
	linux-kernel@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH 0/5] x86 cleanup: convert round_up() to roundup()

On Mon, Jul 28, 2008 at 11:41:27PM -0700, Yinghai Lu wrote:
> On Sat, Jul 26, 2008 at 6:39 AM, Ingo Molnar <mingo@...e.hu> wrote:
> >
> > * Joerg Roedel <joerg.roedel@....com> wrote:
> >
> >> The x86 architecture declares its own round_up macro. But there is a
> >> generic one in <linux/kernel.h> which can also be used. This patchset
> >> replaces the x86 round_up() macro with the generic roundup() one where
> >> possible. The patches have been compile-tested for 32 and 64 bit and
> >> boot-tested for 64 bit. If we can fix the other places too we can get
> >> rid of the x86 specific round_up() in the future.
> >
> > applied to tip/x86/cleanups - thanks Joerg!
> >
> these patches looks like some backward, aka wrong direction.
> 
> #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
> 
> #define round_up(x, y) (((x) + (y) - 1) & ~((y) - 1))
> #define round_down(x, y) ((x) & ~((y) - 1))
> 
> round_up looks more efficient.

It may be more efficient depending on the compiler optimizations. The
other problem with the x86 round_up is that it only works when rounding to
multiples of power of 2. This behavior is not represented in the macro
name and also the generic roundup macro does not have this problem.

Joerg

-- 
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy

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