public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Jackson <pj@sgi.com>
To: Paul Jackson <pj@sgi.com>
Cc: colpatch@us.ibm.com, wli@holomorphy.com, rusty@rustcorp.com.au,
	linux-kernel@vger.kernel.org
Subject: [Patch 6 of 17] cpumask v4 - Uninline find_next_bit on ia64
Date: Thu, 22 Apr 2004 00:07:09 -0700	[thread overview]
Message-ID: <20040422000709.0dfd1fab.pj@sgi.com> (raw)
In-Reply-To: <20040421232247.22ffe1f2.pj@sgi.com>

mask6-unline-find-next-bit-ia64 - Uninline find_next_bit on ia64

	Move the page of code (~700 bytes of instructions)
	for find_next_bit and find_next_zero_bit from inline
	in include/asm-ia64/bitops.h to a real function in
	arch/ia64/lib/bitops.c, leaving a declaration and
	macro wrapper behind.

	The other arch's with almost this same code might want to
	also uninline it: alpha, parisc, ppc, sh, sparc, sparc64.

	These are too big to inline.

Index: 2.6.5.bitmap/include/asm-ia64/bitops.h
===================================================================
--- 2.6.5.bitmap.orig/include/asm-ia64/bitops.h	2004-04-08 03:02:48.000000000 -0700
+++ 2.6.5.bitmap/include/asm-ia64/bitops.h	2004-04-08 03:03:28.000000000 -0700
@@ -11,7 +11,7 @@
 
 #include <linux/compiler.h>
 #include <linux/types.h>
-
+#include <asm/bitops.h>
 #include <asm/intrinsics.h>
 
 /**
@@ -236,7 +236,7 @@
 }
 
 /**
- * test_and_change_bit - Change a bit and return its new value
+ * test_and_change_bit - Change a bit and return its old value
  * @nr: Bit to set
  * @addr: Address to count from
  *
@@ -359,93 +359,21 @@
 
 #endif /* __KERNEL__ */
 
-/*
- * Find next zero bit in a bitmap reasonably efficiently..
- */
-static inline int
-find_next_zero_bit (void *addr, unsigned long size, unsigned long offset)
-{
-	unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
-	unsigned long result = offset & ~63UL;
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset &= 63UL;
-	if (offset) {
-		tmp = *(p++);
-		tmp |= ~0UL >> (64-offset);
-		if (size < 64)
-			goto found_first;
-		if (~tmp)
-			goto found_middle;
-		size -= 64;
-		result += 64;
-	}
-	while (size & ~63UL) {
-		if (~(tmp = *(p++)))
-			goto found_middle;
-		result += 64;
-		size -= 64;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-found_first:
-	tmp |= ~0UL << size;
-	if (tmp == ~0UL)		/* any bits zero? */
-		return result + size;	/* nope */
-found_middle:
-	return result + ffz(tmp);
-}
+extern int __find_next_zero_bit (void *addr, unsigned long size, \
+			unsigned long offset);
+extern int __find_next_bit(const void *addr, unsigned long size, \
+			unsigned long offset);
+
+#define find_next_zero_bit(addr, size, offset) \
+			__find_next_zero_bit((addr), (size), (offset))
+#define find_next_bit(addr, size, offset) \
+			__find_next_bit((addr), (size), (offset))
 
 /*
  * The optimizer actually does good code for this case..
  */
 #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
 
-/*
- * Find next bit in a bitmap reasonably efficiently..
- */
-static inline int
-find_next_bit(const void *addr, unsigned long size, unsigned long offset)
-{
-	unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
-	unsigned long result = offset & ~63UL;
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset &= 63UL;
-	if (offset) {
-		tmp = *(p++);
-		tmp &= ~0UL << offset;
-		if (size < 64)
-			goto found_first;
-		if (tmp)
-			goto found_middle;
-		size -= 64;
-		result += 64;
-	}
-	while (size & ~63UL) {
-		if ((tmp = *(p++)))
-			goto found_middle;
-		result += 64;
-		size -= 64;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-  found_first:
-	tmp &= ~0UL >> (64-size);
-	if (tmp == 0UL)		/* Are any bits set? */
-		return result + size; /* Nope. */
-  found_middle:
-	return result + __ffs(tmp);
-}
-
 #define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
 
 #ifdef __KERNEL__
Index: 2.6.5.bitmap/include/asm-cris/bitops.h
===================================================================
--- 2.6.5.bitmap.orig/include/asm-cris/bitops.h	2004-04-08 03:02:48.000000000 -0700
+++ 2.6.5.bitmap/include/asm-cris/bitops.h	2004-04-08 03:03:28.000000000 -0700
@@ -169,7 +169,7 @@
 	return retval;
 }
 /**
- * test_and_change_bit - Change a bit and return its new value
+ * test_and_change_bit - Change a bit and return its old value
  * @nr: Bit to change
  * @addr: Address to count from
  *
Index: 2.6.5.bitmap/include/asm-i386/bitops.h
===================================================================
--- 2.6.5.bitmap.orig/include/asm-i386/bitops.h	2004-04-08 03:02:48.000000000 -0700
+++ 2.6.5.bitmap/include/asm-i386/bitops.h	2004-04-08 03:03:28.000000000 -0700
@@ -212,7 +212,7 @@
 }
 
 /**
- * test_and_change_bit - Change a bit and return its new value
+ * test_and_change_bit - Change a bit and return its old value
  * @nr: Bit to change
  * @addr: Address to count from
  *
Index: 2.6.5.bitmap/include/asm-mips/bitops.h
===================================================================
--- 2.6.5.bitmap.orig/include/asm-mips/bitops.h	2004-04-08 03:02:48.000000000 -0700
+++ 2.6.5.bitmap/include/asm-mips/bitops.h	2004-04-08 03:03:28.000000000 -0700
@@ -296,7 +296,7 @@
 }
 
 /*
- * test_and_change_bit - Change a bit and return its new value
+ * test_and_change_bit - Change a bit and return its old value
  * @nr: Bit to change
  * @addr: Address to count from
  *
@@ -567,7 +567,7 @@
 }
 
 /*
- * test_and_change_bit - Change a bit and return its new value
+ * test_and_change_bit - Change a bit and return its old value
  * @nr: Bit to change
  * @addr: Address to count from
  *
Index: 2.6.5.bitmap/include/asm-x86_64/bitops.h
===================================================================
--- 2.6.5.bitmap.orig/include/asm-x86_64/bitops.h	2004-04-08 03:02:48.000000000 -0700
+++ 2.6.5.bitmap/include/asm-x86_64/bitops.h	2004-04-08 03:03:28.000000000 -0700
@@ -204,7 +204,7 @@
 }
 
 /**
- * test_and_change_bit - Change a bit and return its new value
+ * test_and_change_bit - Change a bit and return its old value
  * @nr: Bit to change
  * @addr: Address to count from
  *
Index: 2.6.5.bitmap/arch/ia64/lib/bitop.c
===================================================================
--- 2.6.5.bitmap.orig/arch/ia64/lib/bitop.c	2004-04-08 03:03:18.000000000 -0700
+++ 2.6.5.bitmap/arch/ia64/lib/bitop.c	2004-04-08 03:03:28.000000000 -0700
@@ -0,0 +1,88 @@
+#include <linux/compiler.h>
+#include <linux/types.h>
+#include <asm/intrinsics.h>
+#include <linux/module.h>
+#include <asm/bitops.h>
+
+/*
+ * Find next zero bit in a bitmap reasonably efficiently..
+ */
+
+int __find_next_zero_bit (void *addr, unsigned long size, unsigned long offset)
+{
+	unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
+	unsigned long result = offset & ~63UL;
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	size -= result;
+	offset &= 63UL;
+	if (offset) {
+		tmp = *(p++);
+		tmp |= ~0UL >> (64-offset);
+		if (size < 64)
+			goto found_first;
+		if (~tmp)
+			goto found_middle;
+		size -= 64;
+		result += 64;
+	}
+	while (size & ~63UL) {
+		if (~(tmp = *(p++)))
+			goto found_middle;
+		result += 64;
+		size -= 64;
+	}
+	if (!size)
+		return result;
+	tmp = *p;
+found_first:
+	tmp |= ~0UL << size;
+	if (tmp == ~0UL)		/* any bits zero? */
+		return result + size;	/* nope */
+found_middle:
+	return result + ffz(tmp);
+}
+EXPORT_SYMBOL(__find_next_zero_bit);
+
+/*
+ * Find next bit in a bitmap reasonably efficiently..
+ */
+int __find_next_bit(const void *addr, unsigned long size, unsigned long offset)
+{
+	unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
+	unsigned long result = offset & ~63UL;
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	size -= result;
+	offset &= 63UL;
+	if (offset) {
+		tmp = *(p++);
+		tmp &= ~0UL << offset;
+		if (size < 64)
+			goto found_first;
+		if (tmp)
+			goto found_middle;
+		size -= 64;
+		result += 64;
+	}
+	while (size & ~63UL) {
+		if ((tmp = *(p++)))
+			goto found_middle;
+		result += 64;
+		size -= 64;
+	}
+	if (!size)
+		return result;
+	tmp = *p;
+  found_first:
+	tmp &= ~0UL >> (64-size);
+	if (tmp == 0UL)		/* Are any bits set? */
+		return result + size; /* Nope. */
+  found_middle:
+	return result + __ffs(tmp);
+}
+EXPORT_SYMBOL(__find_next_bit);
Index: 2.6.5.bitmap/arch/ia64/lib/Makefile
===================================================================
--- 2.6.5.bitmap.orig/arch/ia64/lib/Makefile	2004-04-08 03:01:12.000000000 -0700
+++ 2.6.5.bitmap/arch/ia64/lib/Makefile	2004-04-08 03:03:28.000000000 -0700
@@ -6,7 +6,7 @@
 
 lib-y := __divsi3.o __udivsi3.o __modsi3.o __umodsi3.o			\
 	__divdi3.o __udivdi3.o __moddi3.o __umoddi3.o			\
-	checksum.o clear_page.o csum_partial_copy.o copy_page.o		\
+	bitop.o checksum.o clear_page.o csum_partial_copy.o copy_page.o	\
 	clear_user.o strncpy_from_user.o strlen_user.o strnlen_user.o	\
 	flush.o ip_fast_csum.o do_csum.o				\
 	memset.o strlen.o swiotlb.o


-- 
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <pj@sgi.com> 1.650.933.1373

  parent reply	other threads:[~2004-04-22  7:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-22  6:22 [Patch 0 of 17] cpumask v4 - bitmap and cpumask cleanup Paul Jackson
2004-04-22  7:05 ` [Patch 1 of 17] cpumask v4 - Document bitmap.c bit model Paul Jackson
2004-04-22  7:06 ` [Patch 2 of 17] cpumask v4 - Dont generate nonzero unused bits in bitmap Paul Jackson
2004-04-22  7:07 ` [Patch 3 of 17] cpumask v4 - New bitmap operators and two op complement Paul Jackson
2004-04-22  7:07 ` [Patch 4 of 17] cpumask v4 - two missing 'const' qualifiers in bitops/bitmap Paul Jackson
2004-04-22  7:07 ` [Patch 5 of 17] cpumask v4 - Optimize and extend bitmap Paul Jackson
2004-04-22  7:07 ` Paul Jackson [this message]
2004-04-22  7:07 ` [Patch 7 of 17] cpumask v4 - Rewrite cpumask.h to use bitmap directly Paul Jackson
2004-04-22  7:07 ` [Patch 8 of 17] cpumask v4 - Remove 26 no longer used cpumask headers Paul Jackson
2004-04-22  7:07 ` [Patch 9 of 17] cpumask v4 - Recode obsolete cpumask macros - arch i386 Paul Jackson
2004-04-22  7:07 ` [Patch 10 of 17] cpumask v4 - Recode obsolete cpumask macros - arch ppc64 Paul Jackson
2004-04-22  7:07 ` [Patch 11 of 17] cpumask v4 - Recode obsolete cpumask macros - arch x86_64 Paul Jackson
2004-04-22  7:07 ` [Patch 12 of 17] cpumask v4 - Remove obsolete emulation from cpumask.h Paul Jackson
2004-04-22  7:07 ` [Patch 13 of 17] cpumask v4 - Simplify some sparc64 cpumask loop code Paul Jackson
2004-04-22  7:07 ` [Patch 14 of 17] cpumask v4 - Optimize i386 cpumask macro usage Paul Jackson
2004-04-22  7:07 ` [Patch 15 of 17] cpumask v4 - Convert physids_complement() to use both args Paul Jackson
2004-04-22  7:07 ` [Patch 16 of 17] cpumask v4 - Remove cpumask hack from asm-x86_64/topology.h Paul Jackson
2004-04-22  7:07 ` [Patch 17 of 17] cpumask v4 - Cpumask code clarification in kernel/sched.c Paul Jackson
2004-04-22 16:25 ` [Patch 0 of 17] cpumask v4 - bitmap and cpumask cleanup Joe Korty
2004-04-22 17:00   ` Paul Jackson

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=20040422000709.0dfd1fab.pj@sgi.com \
    --to=pj@sgi.com \
    --cc=colpatch@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=wli@holomorphy.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