Skip to contentSkip to conversation

percpu_counter_mod not getting into SMP kernel image when ext2/3 compiled as modules

DISCUSSION Jeff Bowden 2 participants 2 messages Nov 10, 2003 – Nov 11, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

In 2.6.9-test9 (also tried with bk15) I have ext2 and ext3 both configured as modules. When I do "modprobe ext3" it says:

FATAL: Error inserting ext3
(/lib/modules/2.6.0-test9-bug-t1/kernel/fs/ext3/ext3.ko): Unknown symbol in module, or unknown parameter (see dmesg)

and dmesg says:

ext3: Unknown symbol percpu_counter_mod

I found one message in the archive (http://www.ussg.iu.edu/hypermail/linux/kernel/0310.2/0311.html) which mentions this problem and includes a proposed fix. The lines from the this proposal made it into lib/percpu_counter.c but somehow it seems that they are not causing the symbol to end up in the main kernel image. In fact the string "percpu_counter_mod" does not occur in vmlinux or in any of the modules other than ext2.ko and ext3.ko.

The kernel in question was compiled with gcc 3.3.1 on an up-to-date debian/unstable. A copy of the exact .config I used can be had from http://jlb.changelog.com/config-2.6.0-test9-bug-t1

I am not subscribed to this mailing list.

#1 lore raw
Quoted 11 lines · Jeff Bowden

In 2.6.9-test9 (also tried with bk15) I have ext2 and ext3 both
configured as modules. When I do "modprobe ext3" it says:

FATAL: Error inserting ext3
(/lib/modules/2.6.0-test9-bug-t1/kernel/fs/ext3/ext3.ko): Unknown symbol in module, or unknown parameter (see dmesg)

and dmesg says:

ext3: Unknown symbol percpu_counter_mod

You'll be needing this:

lib/percpu_counter.c deleted +0 -21
diff -puN -L lib/percpu_counter.c lib/percpu_counter.c~percpu-counter-linkage-fix /dev/null
@@ -1,21 +0,0 @@
-#include <linux/module.h>
-#include <linux/percpu_counter.h>
-#include <linux/sched.h>
-
-void percpu_counter_mod(struct percpu_counter *fbc, long amount)
-{
-	int cpu = get_cpu();
-	long count = fbc->counters[cpu].count;
-
-	count += amount;
-	if (count >= FBC_BATCH || count <= -FBC_BATCH) {
-		spin_lock(&fbc->lock);
-		fbc->count += count;
-		spin_unlock(&fbc->lock);
-		count = 0;
-	}
-	fbc->counters[cpu].count = count;
-	put_cpu();
-}
-
-EXPORT_SYMBOL(percpu_counter_mod);
lib/Makefile renamed from lib/Makefile~percpu-counter-linkage-fix +0 -1
diff -puN lib/Makefile~percpu-counter-linkage-fix lib/Makefile
@@ -9,7 +9,6 @@ lib-y := errno.o ctype.o string.o vsprin
 
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
-lib-$(CONFIG_SMP) += percpu_counter.o
 
 ifneq ($(CONFIG_HAVE_DEC_LOCK),y) 
   lib-y += dec_and_lock.o
mm/swap.c renamed from mm/swap.c~percpu-counter-linkage-fix +21 -0
diff -puN mm/swap.c~percpu-counter-linkage-fix mm/swap.c
@@ -14,6 +14,7 @@
  */
 
 #include <linux/mm.h>
+#include <linux/sched.h>
 #include <linux/kernel_stat.h>
 #include <linux/swap.h>
 #include <linux/mman.h>
@@ -23,6 +24,8 @@
 #include <linux/module.h>
 #include <linux/mm_inline.h>
 #include <linux/buffer_head.h>	/* for try_to_release_page() */
+#include <linux/module.h>
+#include <linux/percpu_counter.h>
 #include <linux/percpu.h>
 
 /* How many pages do we try to swap or page in/out together? */
@@ -380,6 +383,24 @@ void vm_acct_memory(long pages)
 EXPORT_SYMBOL(vm_acct_memory);
 #endif
 
+#ifdef CONFIG_SMP
+void percpu_counter_mod(struct percpu_counter *fbc, long amount)
+{
+	int cpu = get_cpu();
+	long count = fbc->counters[cpu].count;
+
+	count += amount;
+	if (count >= FBC_BATCH || count <= -FBC_BATCH) {
+		spin_lock(&fbc->lock);
+		fbc->count += count;
+		spin_unlock(&fbc->lock);
+		count = 0;
+	}
+	fbc->counters[cpu].count = count;
+	put_cpu();
+}
+EXPORT_SYMBOL(percpu_counter_mod);
+#endif
 
 /*
  * Perform any setup for the swap system

_