public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joerg.roedel@amd.com>
To: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	mingo@redhat.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 0/5] x86 cleanup: convert round_up() to roundup()
Date: Tue, 29 Jul 2008 10:02:51 +0200	[thread overview]
Message-ID: <20080729080251.GB11548@amd.com> (raw)
In-Reply-To: <86802c440807282341g65c90f10gbdcf72beecdd0852@mail.gmail.com>

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@elte.hu> wrote:
> >
> > * Joerg Roedel <joerg.roedel@amd.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


      parent reply	other threads:[~2008-07-29  8:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-25 14:48 [PATCH 0/5] x86 cleanup: convert round_up() to roundup() Joerg Roedel
2008-07-25 14:48 ` [PATCH 1/5] x86: convert pci-dma.c from round_up to roundup Joerg Roedel
2008-07-25 14:48 ` [PATCH 2/5] x86: convert pageattr.c " Joerg Roedel
2008-07-25 14:48 ` [PATCH 3/5] x86: convert init_64.c " Joerg Roedel
2008-07-25 14:48 ` [PATCH 4/5] x86: convert numa_64.c " Joerg Roedel
2008-07-25 14:48 ` [PATCH 5/5] x86: convert discontig_32.c " Joerg Roedel
2008-07-26 13:39 ` [PATCH 0/5] x86 cleanup: convert round_up() to roundup() Ingo Molnar
2008-07-29  6:41   ` Yinghai Lu
2008-07-29  7:16     ` Ingo Molnar
2008-07-29  8:02     ` Joerg Roedel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080729080251.GB11548@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=yhlu.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox