All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Dmitry Torokhov <dtor@vmware.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Show version information for built-in modules in sysfs
Date: Wed, 22 Dec 2010 11:32:40 +1030	[thread overview]
Message-ID: <201012221132.41057.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20101215220019.GA6560@dtor-ws.eng.vmware.com>

On Thu, 16 Dec 2010 08:30:19 am Dmitry Torokhov wrote:
> Currently only drivers that are built as modules have their versions
> shown in /sys/module/<module_name>/version, but this information might
> also be useful for built-in drivers as well. This especially important
> for drivers that do not define any parameters - such drivers, if
> built-in, are completely invisible from userspace.
> 
> This patch changes MODULE_VERSION() macro so that in case when we are
> compiling built-in module, version information is stored in a separate
> section. Kernel then uses this data to create 'version' sysfs attribute
> in the same fashion it creates attributes for module parameters.
> 
> Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
> ---
> 
> This change is driven by our desire to detect whether vmw_balloon driver
> is built-in into the kernel when we installing our tool package in the
> guest and avoid installing our own version of the driver.
> 
> Since vmw_balloon does not have any module parameter nor registers any
> driver core devices, without this patch it is completely invisible from
> userspace when built into the kernel.
> 
> Thanks,
> Dmitry
> 
>  include/asm-generic/vmlinux.lds.h |    7 ++++
>  include/linux/module.h            |   27 +++++++++++++++
>  kernel/params.c                   |   65 ++++++++++++++++++++++++++++++------
>  3 files changed, 88 insertions(+), 11 deletions(-)
> 
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index bd69d79..0d83dd1 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -355,6 +355,13 @@
>  		VMLINUX_SYMBOL(__start___param) = .;			\
>  		*(__param)						\
>  		VMLINUX_SYMBOL(__stop___param) = .;			\
> +	}								\
> +									\
> +	/* Built-in module versions. */					\
> +	__modver : AT(ADDR(__modver) - LOAD_OFFSET) {			\
> +		VMLINUX_SYMBOL(__start___modver) = .;			\
> +		*(__modver)						\
> +		VMLINUX_SYMBOL(__stop___modver) = .;			\
>  		. = ALIGN((align));					\
>  		VMLINUX_SYMBOL(__end_rodata) = .;			\
>  	}								\
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 7575bbb..f74ddda 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -58,6 +58,12 @@ struct module_attribute {
>  	void (*free)(struct module *);
>  };
>  
> +struct module_version_attribute {
> +	struct module_attribute mattr;
> +	const char *module_name;
> +	const char *version;
> +};
> +
>  struct module_kobject
>  {
>  	struct kobject kobj;
> @@ -161,7 +167,28 @@ extern struct module __this_module;
>    Using this automatically adds a checksum of the .c files and the
>    local headers in "srcversion".
>  */
> +
> +#ifdef MODULE
>  #define MODULE_VERSION(_version) MODULE_INFO(version, _version)
> +#else
> +#define MODULE_VERSION(_version)					\
> +	extern ssize_t __modver_version_show(struct module_attribute *,	\
> +					     struct module *, char *);	\
> +	static struct module_version_attribute __modver_version_attr	\
> +	__used								\
> +    __attribute__ ((unused,__section__ ("__modver"),aligned(sizeof(void *)))) \

__used and unused seems overkill, and confused.

Removed unused.

Cheers,
Rusty.

  parent reply	other threads:[~2010-12-22  1:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-15 22:00 [PATCH] Show version information for built-in modules in sysfs Dmitry Torokhov
2010-12-15 22:06 ` Alexey Dobriyan
2010-12-15 22:14   ` Dmitry Torokhov
2010-12-15 23:25     ` Alexey Dobriyan
2010-12-15 23:53       ` Dmitry Torokhov
2010-12-16  0:30         ` Dmitry Torokhov
2010-12-16 12:58         ` Alexey Dobriyan
2010-12-22  1:45           ` Rusty Russell
2010-12-22  1:02 ` Rusty Russell [this message]
2010-12-22  1:17   ` Dmitry Torokhov
2010-12-22  1:48     ` Rusty Russell
2010-12-23  0:38       ` Dmitry Torokhov
2010-12-23  2:27         ` Rusty Russell
2011-01-11 19:03   ` Dmitry Torokhov

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=201012221132.41057.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=dtor@vmware.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.