* [PATCH] MM: Use is_power_of_2() macro where appropriate.
@ 2007-11-06 14:57 Robert P. J. Day
0 siblings, 0 replies; only message in thread
From: Robert P. J. Day @ 2007-11-06 14:57 UTC (permalink / raw)
To: linux-mm
Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
---
mm/bootmem.c | 3 ++-
mm/slab.c | 3 ++-
mm/slub.c | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 00a9697..47f9b59 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -12,6 +12,7 @@
#include <linux/pfn.h>
#include <linux/bootmem.h>
#include <linux/module.h>
+#include <linux/log2.h>
#include <asm/bug.h>
#include <asm/io.h>
@@ -189,7 +190,7 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
printk("__alloc_bootmem_core(): zero-sized request\n");
BUG();
}
- BUG_ON(align & (align-1));
+ BUG_ON(!is_power_of_2(align));
if (limit && bdata->node_boot_start >= limit)
return NULL;
diff --git a/mm/slab.c b/mm/slab.c
index cfa6be4..f13d46d 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -110,6 +110,7 @@
#include <linux/fault-inject.h>
#include <linux/rtmutex.h>
#include <linux/reciprocal_div.h>
+#include <linux/log2.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
@@ -1782,7 +1783,7 @@ static void dump_line(char *data, int offset, int limit)
if (bad_count == 1) {
error ^= POISON_FREE;
- if (!(error & (error - 1))) {
+ if (is_power_of_2(error)) {
printk(KERN_ERR "Single bit error detected. Probably "
"bad RAM.\n");
#ifdef CONFIG_X86
diff --git a/mm/slub.c b/mm/slub.c
index 84f59fd..413cdc6 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -21,6 +21,7 @@
#include <linux/ctype.h>
#include <linux/kallsyms.h>
#include <linux/memory.h>
+#include <linux/log2.h>
/*
* Lock order:
@@ -2851,7 +2852,7 @@ void __init kmem_cache_init(void)
* around with ARCH_KMALLOC_MINALIGN
*/
BUILD_BUG_ON(KMALLOC_MIN_SIZE > 256 ||
- (KMALLOC_MIN_SIZE & (KMALLOC_MIN_SIZE - 1)));
+ !is_power_of_2(KMALLOC_MIN_SIZE));
for (i = 8; i < KMALLOC_MIN_SIZE; i += 8)
size_index[(i - 1) / 8] = KMALLOC_SHIFT_LOW;
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://crashcourse.ca
========================================================================
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-11-06 14:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-06 14:57 [PATCH] MM: Use is_power_of_2() macro where appropriate Robert P. J. Day
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox