public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] x86 cleanup: convert round_up() to roundup()
@ 2008-07-25 14:48 Joerg Roedel
  2008-07-25 14:48 ` [PATCH 1/5] x86: convert pci-dma.c from round_up to roundup Joerg Roedel
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Joerg Roedel @ 2008-07-25 14:48 UTC (permalink / raw)
  To: mingo, tglx; +Cc: linux-kernel

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.

diffstat:

 arch/x86/kernel/pci-dma.c  |    2 +-
 arch/x86/mm/discontig_32.c |    2 +-
 arch/x86/mm/init_64.c      |    8 ++++----
 arch/x86/mm/numa_64.c      |   10 +++++-----
 arch/x86/mm/pageattr.c     |    2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] x86: convert pci-dma.c from round_up to roundup
  2008-07-25 14:48 [PATCH 0/5] x86 cleanup: convert round_up() to roundup() Joerg Roedel
@ 2008-07-25 14:48 ` Joerg Roedel
  2008-07-25 14:48 ` [PATCH 2/5] x86: convert pageattr.c " Joerg Roedel
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Joerg Roedel @ 2008-07-25 14:48 UTC (permalink / raw)
  To: mingo, tglx; +Cc: linux-kernel, Joerg Roedel

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kernel/pci-dma.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index d5b9e11..8f4dbd7 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -82,7 +82,7 @@ void __init dma32_reserve_bootmem(void)
 	 * using 512M as goal
 	 */
 	align = 64ULL<<20;
-	size = round_up(dma32_bootmem_size, align);
+	size = roundup(dma32_bootmem_size, align);
 	dma32_bootmem_ptr = __alloc_bootmem_nopanic(size, align,
 				 512ULL<<20);
 	if (dma32_bootmem_ptr)
-- 
1.5.3.7



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] x86: convert pageattr.c from round_up to roundup
  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 ` Joerg Roedel
  2008-07-25 14:48 ` [PATCH 3/5] x86: convert init_64.c " Joerg Roedel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Joerg Roedel @ 2008-07-25 14:48 UTC (permalink / raw)
  To: mingo, tglx; +Cc: linux-kernel, Joerg Roedel

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/mm/pageattr.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index ba24537..6b10a6b 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -78,7 +78,7 @@ static inline unsigned long highmap_start_pfn(void)
 
 static inline unsigned long highmap_end_pfn(void)
 {
-	return __pa(round_up((unsigned long)_end, PMD_SIZE)) >> PAGE_SHIFT;
+	return __pa(roundup((unsigned long)_end, PMD_SIZE)) >> PAGE_SHIFT;
 }
 
 #endif
-- 
1.5.3.7



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] x86: convert init_64.c from round_up to roundup
  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 ` Joerg Roedel
  2008-07-25 14:48 ` [PATCH 4/5] x86: convert numa_64.c " Joerg Roedel
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Joerg Roedel @ 2008-07-25 14:48 UTC (permalink / raw)
  To: mingo, tglx; +Cc: linux-kernel, Joerg Roedel

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/mm/init_64.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index ec37121..e480577 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -258,7 +258,7 @@ void __init init_extra_mapping_uc(unsigned long phys, unsigned long size)
 void __init cleanup_highmap(void)
 {
 	unsigned long vaddr = __START_KERNEL_map;
-	unsigned long end = round_up((unsigned long)_end, PMD_SIZE) - 1;
+	unsigned long end = roundup((unsigned long)_end, PMD_SIZE) - 1;
 	pmd_t *pmd = level2_kernel_pgt;
 	pmd_t *last_pmd = pmd + PTRS_PER_PMD;
 
@@ -474,14 +474,14 @@ static void __init find_early_table_space(unsigned long end)
 	unsigned long puds, pmds, ptes, tables, start;
 
 	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
-	tables = round_up(puds * sizeof(pud_t), PAGE_SIZE);
+	tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
 	if (direct_gbpages) {
 		unsigned long extra;
 		extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT);
 		pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT;
 	} else
 		pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
-	tables += round_up(pmds * sizeof(pmd_t), PAGE_SIZE);
+	tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
 
 	if (cpu_has_pse) {
 		unsigned long extra;
@@ -489,7 +489,7 @@ static void __init find_early_table_space(unsigned long end)
 		ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	} else
 		ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
-	tables += round_up(ptes * sizeof(pte_t), PAGE_SIZE);
+	tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
 
 	/*
 	 * RED-PEN putting page tables only on node 0 could
-- 
1.5.3.7



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] x86: convert numa_64.c from round_up to roundup
  2008-07-25 14:48 [PATCH 0/5] x86 cleanup: convert round_up() to roundup() Joerg Roedel
                   ` (2 preceding siblings ...)
  2008-07-25 14:48 ` [PATCH 3/5] x86: convert init_64.c " Joerg Roedel
@ 2008-07-25 14:48 ` 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
  5 siblings, 0 replies; 10+ messages in thread
From: Joerg Roedel @ 2008-07-25 14:48 UTC (permalink / raw)
  To: mingo, tglx; +Cc: linux-kernel, Joerg Roedel

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/mm/numa_64.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index 9782f42..e8e2aed 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -81,7 +81,7 @@ static int __init allocate_cachealigned_memnodemap(void)
 		return 0;
 
 	addr = 0x8000;
-	nodemap_size = round_up(sizeof(s16) * memnodemapsize, L1_CACHE_BYTES);
+	nodemap_size = roundup(sizeof(s16) * memnodemapsize, L1_CACHE_BYTES);
 	nodemap_addr = find_e820_area(addr, max_pfn<<PAGE_SHIFT,
 				      nodemap_size, L1_CACHE_BYTES);
 	if (nodemap_addr == -1UL) {
@@ -178,10 +178,10 @@ void __init setup_node_bootmem(int nodeid, unsigned long start,
 	unsigned long start_pfn, last_pfn, bootmap_pages, bootmap_size;
 	unsigned long bootmap_start, nodedata_phys;
 	void *bootmap;
-	const int pgdat_size = round_up(sizeof(pg_data_t), PAGE_SIZE);
+	const int pgdat_size = roundup(sizeof(pg_data_t), PAGE_SIZE);
 	int nid;
 
-	start = round_up(start, ZONE_ALIGN);
+	start = roundup(start, ZONE_ALIGN);
 
 	printk(KERN_INFO "Bootmem setup node %d %016lx-%016lx\n", nodeid,
 	       start, end);
@@ -212,9 +212,9 @@ void __init setup_node_bootmem(int nodeid, unsigned long start,
 	bootmap_pages = bootmem_bootmap_pages(last_pfn - start_pfn);
 	nid = phys_to_nid(nodedata_phys);
 	if (nid == nodeid)
-		bootmap_start = round_up(nodedata_phys + pgdat_size, PAGE_SIZE);
+		bootmap_start = roundup(nodedata_phys + pgdat_size, PAGE_SIZE);
 	else
-		bootmap_start = round_up(start, PAGE_SIZE);
+		bootmap_start = roundup(start, PAGE_SIZE);
 	/*
 	 * SMP_CACHE_BYTES could be enough, but init_bootmem_node like
 	 * to use that to align to PAGE_SIZE
-- 
1.5.3.7



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] x86: convert discontig_32.c from round_up to roundup
  2008-07-25 14:48 [PATCH 0/5] x86 cleanup: convert round_up() to roundup() Joerg Roedel
                   ` (3 preceding siblings ...)
  2008-07-25 14:48 ` [PATCH 4/5] x86: convert numa_64.c " Joerg Roedel
@ 2008-07-25 14:48 ` Joerg Roedel
  2008-07-26 13:39 ` [PATCH 0/5] x86 cleanup: convert round_up() to roundup() Ingo Molnar
  5 siblings, 0 replies; 10+ messages in thread
From: Joerg Roedel @ 2008-07-25 14:48 UTC (permalink / raw)
  To: mingo, tglx; +Cc: linux-kernel, Joerg Roedel

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/mm/discontig_32.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/discontig_32.c b/arch/x86/mm/discontig_32.c
index 5dfef9f..d28796e 100644
--- a/arch/x86/mm/discontig_32.c
+++ b/arch/x86/mm/discontig_32.c
@@ -329,7 +329,7 @@ void __init initmem_init(unsigned long start_pfn,
 
 	get_memcfg_numa();
 
-	kva_pages = round_up(calculate_numa_remap_pages(), PTRS_PER_PTE);
+	kva_pages = roundup(calculate_numa_remap_pages(), PTRS_PER_PTE);
 
 	kva_target_pfn = round_down(max_low_pfn - kva_pages, PTRS_PER_PTE);
 	do {
-- 
1.5.3.7



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] x86 cleanup: convert round_up() to roundup()
  2008-07-25 14:48 [PATCH 0/5] x86 cleanup: convert round_up() to roundup() Joerg Roedel
                   ` (4 preceding siblings ...)
  2008-07-25 14:48 ` [PATCH 5/5] x86: convert discontig_32.c " Joerg Roedel
@ 2008-07-26 13:39 ` Ingo Molnar
  2008-07-29  6:41   ` Yinghai Lu
  5 siblings, 1 reply; 10+ messages in thread
From: Ingo Molnar @ 2008-07-26 13:39 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: mingo, tglx, linux-kernel, H. Peter Anvin


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

	Ingo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] x86 cleanup: convert round_up() to roundup()
  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
  0 siblings, 2 replies; 10+ messages in thread
From: Yinghai Lu @ 2008-07-29  6:41 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Joerg Roedel, mingo, tglx, linux-kernel, H. Peter Anvin

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.

YH

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] x86 cleanup: convert round_up() to roundup()
  2008-07-29  6:41   ` Yinghai Lu
@ 2008-07-29  7:16     ` Ingo Molnar
  2008-07-29  8:02     ` Joerg Roedel
  1 sibling, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2008-07-29  7:16 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Joerg Roedel, mingo, tglx, linux-kernel, H. Peter Anvin


* Yinghai Lu <yhlu.kernel@gmail.com> 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.

hm, does it ever make a difference to the compiled output?

	Ingo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] x86 cleanup: convert round_up() to roundup()
  2008-07-29  6:41   ` Yinghai Lu
  2008-07-29  7:16     ` Ingo Molnar
@ 2008-07-29  8:02     ` Joerg Roedel
  1 sibling, 0 replies; 10+ messages in thread
From: Joerg Roedel @ 2008-07-29  8:02 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Ingo Molnar, mingo, tglx, linux-kernel, H. Peter Anvin

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-07-29  8:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox