Skip to contentSkip to conversation

Slow loading big kernel module in 2.6 on PPC platform

DISCUSSION Samuel Masham 2 participants 4 messages Sep 29, 2005 – Sep 30, 2005 Module support

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines
Quoted 3 lines · Wilson Li

Hi,

I am trying to port several third party kernel modules from

Quoted 9 lines

kernel

Quoted 1 line

2.4 to 2.6 on a ppc (MPC824x) platform. For small size of

modules, it

Quoted 1 line

works perfectly in 2.6. But there's one huge kernel module which

size

Quoted 2 lines

is about 2.7M bytes (size reported by lsmod after insmod), and it takes about 90 seconds to load this module before init_module

starts.

Quoted 1 line

I did not notice there's such obvious delay in 2.4 kernel.

I assume you are on a slow ppc32 platform.

The time taken is a function of the number of symbols, you can work around it as shown in the patch below. Obviously this is just an example patch and is NOT signed off for anything but reading :)

I would really like do some work on a pre-link for modules but don't really know where to start.

Any hints?

Samuel

ps Not subscribed, just so please cc me

include/linux/moduleparam.h +5 -0
diff -ru src.orig/include/linux/moduleparam.h src/include/linux/moduleparam.h
@@ -85,6 +85,11 @@
 		      unsigned num,
 		      int (*unknown)(char *param, char *val));
 
+
+struct module;
+
+extern int parse_args_reloc(char ** args, struct module * me, int * core_size, int * init_size);
+
 /* All the helper functions */
 /* The macros to do compile-time type checking stolen from Jakub
    Jelinek, who IIRC came up with this idea for the 2.4 module init code. */
kernel/module.c +24 -3
diff -ru src.orig/kernel/module.c src/kernel/module.c
@@ -1429,6 +1429,8 @@
 }
 #endif /* CONFIG_KALLSYMS */
 
+
+
 /* Allocate and load the module: note that size of section 0 is always
    zero, and we rely on this for optional sections. */
 static struct module *load_module(void __user *umod,
@@ -1446,7 +1448,9 @@
 	long err = 0;
 	void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
 	struct exception_table_entry *extable;
-
+	int no_frob_arch_sections = 0;
+	int core_size=0, init_size=0;
+ 
 	DEBUGP("load_module: umod=%p, len=%lu, uargs=%p¥n",
 	       umod, len, uargs);
 	if (len < sizeof(*hdr))
@@ -1579,8 +1583,25 @@
 
 	mod->state = MODULE_STATE_COMING;
 
-	/* Allow arches to frob section contents and sizes.  */
-	err = module_frob_arch_sections(hdr, sechdrs, secstrings, mod);
+	if(strncmp("elf_plt_info=",args, strlen("elf_plt_info="))==0){
+		if(parse_args_reloc(&args, mod, &core_size, &init_size)) {
+			/* Allow passing hard coded relocation sizes. */
+			sechdrs[mod->arch.core_plt_section].sh_size = core_size;
+			sechdrs[mod->arch.init_plt_section].sh_size = init_size;
+			no_frob_arch_sections = 1;
+		} 	
+	}
+	
+	if(!no_frob_arch_sections) 
+	{
+		/* Allow arches to frob section contents and sizes.  */
+		err = module_frob_arch_sections(hdr, sechdrs, secstrings, mod);
+		printk("init_module: consider ¥"insmod %s elf_plt_info=%d,%d,%d,%d %s¥"¥n", mod->name,
+			mod->arch.core_plt_section, mod->arch.init_plt_section,
+			sechdrs[mod->arch.core_plt_section].sh_size, sechdrs[mod->arch.init_plt_section].sh_size, args);
+	}
+
+
 	if (err < 0)
 		goto free_mod;
 
kernel/params.c +11 -0
diff -ru src.orig/kernel/params.c src/kernel/params.c
@@ -164,6 +164,17 @@
 	return 0;
 }
 
+
+int parse_args_reloc(char ** args, struct module *me, int* core_size, int* init_size){
+	char *param, *val;
+	int ret=0;
+	*args = next_arg(*args, &param, &val);//args pointing to next of elf_plt_info=x,y.z,v
+	ret = sscanf(val, "%d,%d,%d,%d",	
+		&me->arch.core_plt_section, &me->arch.init_plt_section, core_size, init_size);
+	if(ret!=4) return 0;  /* fail */
+        return 1;             /* success */
+}
+
 /* Lazy bastard, eh? */
 #define STANDARD_PARAM_DEF(name, type, format, tmptype, strtolfn)      	¥
 	int param_set_##name(const char *val, struct kernel_param *kp)	¥
#1 lore raw
Quoted 12 lines · --- Samuel Masham

I assume you are on a slow ppc32 platform.

The time taken is a function of the number of symbols, you can work around it
as shown in the patch below. Obviously this is just an example patch and is
NOT signed off for anything but reading :)

I would really like do some work on a pre-link for modules but don't really know
where to start.

Quoted 6 lines

Any hints?

Samuel

ps Not subscribed, just so please cc me

Appreciate your help.
I applied your patch manually since something was wrong during patching. I guess we might not use same version of kernel. Mine is 2.6.8.

But the function parse_args_reloc() still failed even though I have passed a module param like elf_plt_info=1 during insmod. Here's the command to load the module.

#>insmod mrbig.ko elf_plt_info=1

And console output is:
init_module: consider insmod mrbig elf_plt_info=25,27,322144,160

I have no idea what the plt section is and what is going on in module_frob_arch_sections() function. Any hints or documents I can refer to?

Thanks,
Wilson Li

__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

#2 lore raw

I think I got what you are trying to do in your patch. This is really a smart workaround. At least it works for me for now, it just need the module to be loaded first to generate all the infos which takes time. And then use the infos pre-calculated to load the module just like
#>insmod mrbig.ko elf_plt_info=25,27,322144,160

Thanks and really appreciate your help.
Wilson Li

Quoted 49 lines · --- Wilson Li
Quoted 3 lines · --- Samuel Masham

I assume you are on a slow ppc32 platform.

The time taken is a function of the number of symbols, you can

work

Quoted 9 lines

around it
as shown in the patch below. Obviously this is just an example patch and is
NOT signed off for anything but reading :)

I would really like do some work on a pre-link for modules but don't really know
where to start.

Quoted 6 lines

Any hints?

Samuel

ps Not subscribed, just so please cc me

Appreciate your help.
I applied your patch manually since something was wrong during patching. I guess we might not use same version of kernel. Mine is 2.6.8.

But the function parse_args_reloc() still failed even though I have passed a module param like elf_plt_info=1 during insmod. Here's the command to load the module.

#>insmod mrbig.ko elf_plt_info=1

And console output is:
init_module: consider insmod mrbig elf_plt_info=25,27,322144,160

I have no idea what the plt section is and what is going on in module_frob_arch_sections() function. Any hints or documents I can refer to?

Thanks,
Wilson Li

Quoted 10 lines

__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

#3 lore raw
In reply to Samuel Masham
Quoted 28 lines · --- Samuel Masham
Quoted 8 lines
Quoted 3 lines · Wilson Li

Hi,

I am trying to port several third party kernel modules from

kernel

Quoted 1 line

2.4 to 2.6 on a ppc (MPC824x) platform. For small size of

modules, it

Quoted 1 line

works perfectly in 2.6. But there's one huge kernel module

which

Quoted 2 lines

size

Quoted 1 line

is about 2.7M bytes (size reported by lsmod after insmod), and

it

Quoted 3 lines
Quoted 1 line

takes about 90 seconds to load this module before init_module

starts.

Quoted 1 line

I did not notice there's such obvious delay in 2.4 kernel.

I assume you are on a slow ppc32 platform.

The time taken is a function of the number of symbols, you can work around it
as shown in the patch below. Obviously this is just an example patch and is
NOT signed off for anything but reading :)

I would really like do some work on a pre-link for modules but don't really know
where to start.

Quoted 6 lines

Any hints?

Samuel

ps Not subscribed, just so please cc me

Here's my two cents.

1. Add time-consuming get_plt_size() functionality to scripts/mod/modpost.c (per arch), and calculate the size when scripts/mod/modpost is called to generate mymodule.mod.c during making of kernel module.

2. How to pass this info down to sys_init_module() in kernel? Maybe we can add a special section in mymodule.mod.c. So this info will be part of mymodule.ko and parsed by sys_init_module() later.

Then it won't make too much impact on the build process.

Sounds easy;-) Hopefully it'll work.

Wilson Li

______________________________________________________
Yahoo! for Good
Donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/