Re: [PATCH] module: add modinfo support for all built-in modules

2008-01-18 Thread Dave Young
On Jan 18, 2008 5:54 PM, rae l <[EMAIL PROTECTED]> wrote:
> On Jan 16, 2008 8:25 PM, Rusty Russell <[EMAIL PROTECTED]> wrote:
> > I'd love to see patches.  module_parm showed it's possible, if messy.
> >
> > Thanks!
> > Rusty.
>
> here's the patch, I added .modinfo section to the vmlinux, to collect
> built-in module information.
>
> I have just define __MODULE_INFO to another meaning while
> CONFIG_MODULES undefined
> (modules compiled built-in), instead of nothing; and so the
> MODULE_LICENSE, MODULE_AUTHOR,
> MODULE_DESCRIPTION's meaning also changed, each macro would define one
> struct kernel_modinfo
> entry in the .modinfo section of vmlinux; and one __initcall converts
> all these information to read-only
> files under /sys/modules//...
>
> but the MODULE_PARM_DESC macro is still different:
> it generates entries with the same tag, that would confuse
> sys_create_group, so I skipped them in the __initcall,
> since the parameters had been in /sys/modules/<>/parameters/(with perm
> non-zero) or didn't appear(with perm 0);
> I think the parameter description might be only useful for external
> module files, not needed in memory(under /sys/module/),
> so a better solution is define MODULE_PARM_DESC to nothing while
> CONFIG_MODULES undefined.
>
> Another possible defect is that it compares two modname with
> (km->modname != modname),
> that depends on a gcc feature: keep same constant string only one copy
> in the image,
> this did work on my test machines, but I'm not sure it's standard or
> not; and if not, I would change it to strcmp.
>
> Apperantly this approach will increase the kernel image size. on a
> moderate system(with 1.8MB bzImage),
> this patch would increase vmlinux 46KB and after compression increase
> bzImage 9.2KB.
> and in the increment of vmlinux, the .modinfo section occupied 5.3KB
> and others are constant strings.
>
> However, the iscsid can now work well when scsi_transport_iscsi module
> built-in without the problem refered in my former email.
>
> please give comments.
>
> From 50831a260b1ad2c8b495854a58408c1fbc75a3fe Mon Sep 17 00:00:00 2001
> From: Denis Cheng <[EMAIL PROTECTED]>
> Date: Fri, 18 Jan 2008 16:37:35 +0800
> Subject: [PATCH] module: add modinfo support for all built-in modules
>
> the current modinfo support is for external modules only, it provided module
> information under /sys/module//, such as verion, ...;
> now some application(such as iscsid of open-iscsi) has been designed to
> use this module information; but built-in modules don't have modinfo support,
> so these apps would break if modules they depend on are compiled built-in.
>
> this patch add modinfo support for all built-in modules, so now no matter
> whether modules they depends on are built-in or external, modules' information
> could always be accessed from /sys/module//version, apps won't break.
>
> Signed-off-by: Denis Cheng <[EMAIL PROTECTED]>
> ---
>  include/asm-generic/vmlinux.lds.h |7 ++
>  include/linux/moduleparam.h   |   18 -
>  kernel/module.c   |  147 
> +
>  3 files changed, 170 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/vmlinux.lds.h
> b/include/asm-generic/vmlinux.lds.h
> index 9f584cc..896f0fe 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -137,6 +137,13 @@
> VMLINUX_SYMBOL(__start___param) = .;\
> *(__param)  \
> VMLINUX_SYMBOL(__stop___param) = .; \
> +   }   \
> +   \
> +   /* Built-in module information. */  \
> +   .modinfo : AT(ADDR(.modinfo) - LOAD_OFFSET) {   \
> +   VMLINUX_SYMBOL(__start___modinfo) = .;  \
> +   *(.modinfo) \
> +   VMLINUX_SYMBOL(__stop___modinfo) = .;   \
> VMLINUX_SYMBOL(__end_rodata) = .;   \
> }   \
> \
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index 13410b2..86ddbd4 100644
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -13,16 +13,30 @@
>  #define MODULE_PARAM_PREFIX KBUILD_MODNAME "

[PATCH] module: add modinfo support for all built-in modules

2008-01-18 Thread rae l
On Jan 16, 2008 8:25 PM, Rusty Russell <[EMAIL PROTECTED]> wrote:
> I'd love to see patches.  module_parm showed it's possible, if messy.
>
> Thanks!
> Rusty.

here's the patch, I added .modinfo section to the vmlinux, to collect
built-in module information.

I have just define __MODULE_INFO to another meaning while
CONFIG_MODULES undefined
(modules compiled built-in), instead of nothing; and so the
MODULE_LICENSE, MODULE_AUTHOR,
MODULE_DESCRIPTION's meaning also changed, each macro would define one
struct kernel_modinfo
entry in the .modinfo section of vmlinux; and one __initcall converts
all these information to read-only
files under /sys/modules//...

but the MODULE_PARM_DESC macro is still different:
it generates entries with the same tag, that would confuse
sys_create_group, so I skipped them in the __initcall,
since the parameters had been in /sys/modules/<>/parameters/(with perm
non-zero) or didn't appear(with perm 0);
I think the parameter description might be only useful for external
module files, not needed in memory(under /sys/module/),
so a better solution is define MODULE_PARM_DESC to nothing while
CONFIG_MODULES undefined.

Another possible defect is that it compares two modname with
(km->modname != modname),
that depends on a gcc feature: keep same constant string only one copy
in the image,
this did work on my test machines, but I'm not sure it's standard or
not; and if not, I would change it to strcmp.

Apperantly this approach will increase the kernel image size. on a
moderate system(with 1.8MB bzImage),
this patch would increase vmlinux 46KB and after compression increase
bzImage 9.2KB.
and in the increment of vmlinux, the .modinfo section occupied 5.3KB
and others are constant strings.

However, the iscsid can now work well when scsi_transport_iscsi module
built-in without the problem refered in my former email.

please give comments.

>From 50831a260b1ad2c8b495854a58408c1fbc75a3fe Mon Sep 17 00:00:00 2001
From: Denis Cheng <[EMAIL PROTECTED]>
Date: Fri, 18 Jan 2008 16:37:35 +0800
Subject: [PATCH] module: add modinfo support for all built-in modules

the current modinfo support is for external modules only, it provided module
information under /sys/module//, such as verion, ...;
now some application(such as iscsid of open-iscsi) has been designed to
use this module information; but built-in modules don't have modinfo support,
so these apps would break if modules they depend on are compiled built-in.

this patch add modinfo support for all built-in modules, so now no matter
whether modules they depends on are built-in or external, modules' information
could always be accessed from /sys/module//version, apps won't break.

Signed-off-by: Denis Cheng <[EMAIL PROTECTED]>
---
 include/asm-generic/vmlinux.lds.h |7 ++
 include/linux/moduleparam.h   |   18 -
 kernel/module.c   |  147 +
 3 files changed, 170 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h
b/include/asm-generic/vmlinux.lds.h
index 9f584cc..896f0fe 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -137,6 +137,13 @@
VMLINUX_SYMBOL(__start___param) = .;\
*(__param)  \
VMLINUX_SYMBOL(__stop___param) = .; \
+   }   \
+   \
+   /* Built-in module information. */  \
+   .modinfo : AT(ADDR(.modinfo) - LOAD_OFFSET) {   \
+   VMLINUX_SYMBOL(__start___modinfo) = .;  \
+   *(.modinfo) \
+   VMLINUX_SYMBOL(__stop___modinfo) = .;   \
VMLINUX_SYMBOL(__end_rodata) = .;   \
}   \
\
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 13410b2..86ddbd4 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -13,16 +13,30 @@
 #define MODULE_PARAM_PREFIX KBUILD_MODNAME "."
 #endif

-#ifdef MODULE
 #define ___module_cat(a,b) __mod_ ## a ## b
 #define __module_cat(a,b) ___module_cat(a,b)
+
+#ifdef MODULE
 #define __MODULE_INFO(tag, name, info)   \
 static const char __module_cat(name,__LINE__)[]
  \
   __attribute_used__ \
   __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
 #else  /* !MODULE */
-#define __MODULE_INFO(tag, name, info)
+struct kernel_modinfo {
+   char *mo

[PATCH] module: add modinfo support for all built-in modules

2008-01-18 Thread rae l
On Jan 16, 2008 8:25 PM, Rusty Russell [EMAIL PROTECTED] wrote:
 I'd love to see patches.  module_parm showed it's possible, if messy.

 Thanks!
 Rusty.

here's the patch, I added .modinfo section to the vmlinux, to collect
built-in module information.

I have just define __MODULE_INFO to another meaning while
CONFIG_MODULES undefined
(modules compiled built-in), instead of nothing; and so the
MODULE_LICENSE, MODULE_AUTHOR,
MODULE_DESCRIPTION's meaning also changed, each macro would define one
struct kernel_modinfo
entry in the .modinfo section of vmlinux; and one __initcall converts
all these information to read-only
files under /sys/modules/module-name/...

but the MODULE_PARM_DESC macro is still different:
it generates entries with the same tag, that would confuse
sys_create_group, so I skipped them in the __initcall,
since the parameters had been in /sys/modules//parameters/(with perm
non-zero) or didn't appear(with perm 0);
I think the parameter description might be only useful for external
module files, not needed in memory(under /sys/module/),
so a better solution is define MODULE_PARM_DESC to nothing while
CONFIG_MODULES undefined.

Another possible defect is that it compares two modname with
(km-modname != modname),
that depends on a gcc feature: keep same constant string only one copy
in the image,
this did work on my test machines, but I'm not sure it's standard or
not; and if not, I would change it to strcmp.

Apperantly this approach will increase the kernel image size. on a
moderate system(with 1.8MB bzImage),
this patch would increase vmlinux 46KB and after compression increase
bzImage 9.2KB.
and in the increment of vmlinux, the .modinfo section occupied 5.3KB
and others are constant strings.

However, the iscsid can now work well when scsi_transport_iscsi module
built-in without the problem refered in my former email.

please give comments.

From 50831a260b1ad2c8b495854a58408c1fbc75a3fe Mon Sep 17 00:00:00 2001
From: Denis Cheng [EMAIL PROTECTED]
Date: Fri, 18 Jan 2008 16:37:35 +0800
Subject: [PATCH] module: add modinfo support for all built-in modules

the current modinfo support is for external modules only, it provided module
information under /sys/module/XYZ/, such as verion, ...;
now some application(such as iscsid of open-iscsi) has been designed to
use this module information; but built-in modules don't have modinfo support,
so these apps would break if modules they depend on are compiled built-in.

this patch add modinfo support for all built-in modules, so now no matter
whether modules they depends on are built-in or external, modules' information
could always be accessed from /sys/module/XYZ/version, apps won't break.

Signed-off-by: Denis Cheng [EMAIL PROTECTED]
---
 include/asm-generic/vmlinux.lds.h |7 ++
 include/linux/moduleparam.h   |   18 -
 kernel/module.c   |  147 +
 3 files changed, 170 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/vmlinux.lds.h
b/include/asm-generic/vmlinux.lds.h
index 9f584cc..896f0fe 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -137,6 +137,13 @@
VMLINUX_SYMBOL(__start___param) = .;\
*(__param)  \
VMLINUX_SYMBOL(__stop___param) = .; \
+   }   \
+   \
+   /* Built-in module information. */  \
+   .modinfo : AT(ADDR(.modinfo) - LOAD_OFFSET) {   \
+   VMLINUX_SYMBOL(__start___modinfo) = .;  \
+   *(.modinfo) \
+   VMLINUX_SYMBOL(__stop___modinfo) = .;   \
VMLINUX_SYMBOL(__end_rodata) = .;   \
}   \
\
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 13410b2..86ddbd4 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -13,16 +13,30 @@
 #define MODULE_PARAM_PREFIX KBUILD_MODNAME .
 #endif

-#ifdef MODULE
 #define ___module_cat(a,b) __mod_ ## a ## b
 #define __module_cat(a,b) ___module_cat(a,b)
+
+#ifdef MODULE
 #define __MODULE_INFO(tag, name, info)   \
 static const char __module_cat(name,__LINE__)[]
  \
   __attribute_used__ \
   __attribute__((section(.modinfo),unused)) = __stringify(tag) = info
 #else  /* !MODULE */
-#define __MODULE_INFO(tag, name, info)
+struct kernel_modinfo {
+   char *modname;
+   char *tag;
+   char *info;
+};
+#define __MODULE_INFO(tag

Re: [PATCH] module: add modinfo support for all built-in modules

2008-01-18 Thread Dave Young
On Jan 18, 2008 5:54 PM, rae l [EMAIL PROTECTED] wrote:
 On Jan 16, 2008 8:25 PM, Rusty Russell [EMAIL PROTECTED] wrote:
  I'd love to see patches.  module_parm showed it's possible, if messy.
 
  Thanks!
  Rusty.

 here's the patch, I added .modinfo section to the vmlinux, to collect
 built-in module information.

 I have just define __MODULE_INFO to another meaning while
 CONFIG_MODULES undefined
 (modules compiled built-in), instead of nothing; and so the
 MODULE_LICENSE, MODULE_AUTHOR,
 MODULE_DESCRIPTION's meaning also changed, each macro would define one
 struct kernel_modinfo
 entry in the .modinfo section of vmlinux; and one __initcall converts
 all these information to read-only
 files under /sys/modules/module-name/...

 but the MODULE_PARM_DESC macro is still different:
 it generates entries with the same tag, that would confuse
 sys_create_group, so I skipped them in the __initcall,
 since the parameters had been in /sys/modules//parameters/(with perm
 non-zero) or didn't appear(with perm 0);
 I think the parameter description might be only useful for external
 module files, not needed in memory(under /sys/module/),
 so a better solution is define MODULE_PARM_DESC to nothing while
 CONFIG_MODULES undefined.

 Another possible defect is that it compares two modname with
 (km-modname != modname),
 that depends on a gcc feature: keep same constant string only one copy
 in the image,
 this did work on my test machines, but I'm not sure it's standard or
 not; and if not, I would change it to strcmp.

 Apperantly this approach will increase the kernel image size. on a
 moderate system(with 1.8MB bzImage),
 this patch would increase vmlinux 46KB and after compression increase
 bzImage 9.2KB.
 and in the increment of vmlinux, the .modinfo section occupied 5.3KB
 and others are constant strings.

 However, the iscsid can now work well when scsi_transport_iscsi module
 built-in without the problem refered in my former email.

 please give comments.

 From 50831a260b1ad2c8b495854a58408c1fbc75a3fe Mon Sep 17 00:00:00 2001
 From: Denis Cheng [EMAIL PROTECTED]
 Date: Fri, 18 Jan 2008 16:37:35 +0800
 Subject: [PATCH] module: add modinfo support for all built-in modules

 the current modinfo support is for external modules only, it provided module
 information under /sys/module/XYZ/, such as verion, ...;
 now some application(such as iscsid of open-iscsi) has been designed to
 use this module information; but built-in modules don't have modinfo support,
 so these apps would break if modules they depend on are compiled built-in.

 this patch add modinfo support for all built-in modules, so now no matter
 whether modules they depends on are built-in or external, modules' information
 could always be accessed from /sys/module/XYZ/version, apps won't break.

 Signed-off-by: Denis Cheng [EMAIL PROTECTED]
 ---
  include/asm-generic/vmlinux.lds.h |7 ++
  include/linux/moduleparam.h   |   18 -
  kernel/module.c   |  147 
 +
  3 files changed, 170 insertions(+), 2 deletions(-)

 diff --git a/include/asm-generic/vmlinux.lds.h
 b/include/asm-generic/vmlinux.lds.h
 index 9f584cc..896f0fe 100644
 --- a/include/asm-generic/vmlinux.lds.h
 +++ b/include/asm-generic/vmlinux.lds.h
 @@ -137,6 +137,13 @@
 VMLINUX_SYMBOL(__start___param) = .;\
 *(__param)  \
 VMLINUX_SYMBOL(__stop___param) = .; \
 +   }   \
 +   \
 +   /* Built-in module information. */  \
 +   .modinfo : AT(ADDR(.modinfo) - LOAD_OFFSET) {   \
 +   VMLINUX_SYMBOL(__start___modinfo) = .;  \
 +   *(.modinfo) \
 +   VMLINUX_SYMBOL(__stop___modinfo) = .;   \
 VMLINUX_SYMBOL(__end_rodata) = .;   \
 }   \
 \
 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
 index 13410b2..86ddbd4 100644
 --- a/include/linux/moduleparam.h
 +++ b/include/linux/moduleparam.h
 @@ -13,16 +13,30 @@
  #define MODULE_PARAM_PREFIX KBUILD_MODNAME .
  #endif

 -#ifdef MODULE
  #define ___module_cat(a,b) __mod_ ## a ## b
  #define __module_cat(a,b) ___module_cat(a,b)
 +
 +#ifdef MODULE
  #define __MODULE_INFO(tag, name, info)   \
  static const char __module_cat(name,__LINE__)[]  
 \
__attribute_used__ \
__attribute__((section(.modinfo),unused)) = __stringify(tag) = info
  #else  /* !MODULE