another driver core patch for .35
Subsystems (7)
PATCH 1/1 another driver core patch for .35
Here's one more driver core patch for the .35 merge window.
It provides the ability for module-init-tools to know which modules to load when a user asks for a device node that is not present in the system yet by exporting the information in the modules.
It also moves some misc devices from a dynamic number to a static one as they are getting popular on a lot of systems.
Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-core-2.6.git/
This patch has been in the linux-next and mm trees.
The patch will be sent as a follow-on to this message to lkml for people to see, but it's already been sent there a number of times, so it's nothing new.
thanks,
greg k-h
------------
Documentation/devices.txt | 2 ++ arch/x86/kernel/microcode_core.c | 1 + drivers/net/ppp_generic.c | 4 ++-- drivers/net/tun.c | 1 + fs/autofs4/dev-ioctl.c | 5 ++++- fs/btrfs/super.c | 5 ++++- fs/fuse/dev.c | 1 + include/linux/miscdevice.h | 2 ++ 8 files changed, 17 insertions(+), 4 deletions(-)
---------------
Kay Sievers (1):
driver core: add devname module aliases to allow module on-demand auto-loading
PATCH 1/1 driver core: add devname module aliases to allow module on-demand auto-loading
From: Kay Sievers <[email protected]>
This adds:
alias: devname:<name>
to some common kernel modules, which will allow the on-demand loading of the kernel module when the device node is accessed.
Ideally all these modules would be compiled-in, but distros seems too much in love with their modularization that we need to cover the common cases with this new facility. It will allow us to remove a bunch of pretty useless init scripts and modprobes from init scripts.
The static device node aliases will be carried in the module itself. The program depmod will extract this information to a file in the module directory:
$ cat /lib/modules/2.6.34-00650-g537b60d-dirty/modules.devname # Device nodes to trigger on-demand module loading. microcode cpu/microcode c10:184 fuse fuse c10:229 ppp_generic ppp c108:0 tun net/tun c10:200 dm_mod mapper/control c10:235
Udev will pick up the depmod created file on startup and create all the static device nodes which the kernel modules specify, so that these modules get automatically loaded when the device node is accessed:
$ /sbin/udevd --debug ... static_dev_create_from_modules: mknod '/dev/cpu/microcode' c10:184 static_dev_create_from_modules: mknod '/dev/fuse' c10:229 static_dev_create_from_modules: mknod '/dev/ppp' c108:0 static_dev_create_from_modules: mknod '/dev/net/tun' c10:200 static_dev_create_from_modules: mknod '/dev/mapper/control' c10:235 udev_rules_apply_static_dev_perms: chmod '/dev/net/tun' 0666 udev_rules_apply_static_dev_perms: chmod '/dev/fuse' 0666
A few device nodes are switched to statically allocated numbers, to allow the static nodes to work. This might also useful for systems which still run a plain static /dev, which is completely unsafe to use with any dynamic minor numbers.
Note:
The devname aliases must be limited to the *common* and *single*instance* device nodes, like the misc devices, and never be used for conceptually limited systems like the loop devices, which should rather get fixed properly and get a control node for losetup to talk to, instead of creating a random number of device nodes in advance, regardless if they are ever used.
This facility is to hide the mess distros are creating with too modualized kernels, and just to hide that these modules are not compiled-in, and not to paper-over broken concepts. Thanks! :)
--- Documentation/devices.txt | 2 ++ arch/x86/kernel/microcode_core.c | 1 + drivers/net/ppp_generic.c | 4 ++-- drivers/net/tun.c | 1 + fs/autofs4/dev-ioctl.c | 5 ++++- fs/btrfs/super.c | 5 ++++- fs/fuse/dev.c | 1 + include/linux/miscdevice.h | 2 ++ 8 files changed, 17 insertions(+), 4 deletions(-)
Documentation/devices.txt +2 -0
@@ -443,6 +443,8 @@ Your cooperation is appreciated. 231 = /dev/snapshot System memory snapshot device 232 = /dev/kvm Kernel-based virtual machine (hardware virtualization extensions) 233 = /dev/kmview View-OS A process with a view + 234 = /dev/btrfs-control Btrfs control device + 235 = /dev/autofs Autofs control device 240-254 Reserved for local use 255 Reserved for MISC_DYNAMIC_MINOR
arch/x86/kernel/microcode_core.c +1 -0
@@ -260,6 +260,7 @@ static void microcode_dev_exit(void) }MODULE_ALIAS_MISCDEV (MICROCODE_MINOR ); +MODULE_ALIAS ("devname:cpu/microcode" );#else #define microcode_dev_init () 0#define microcode_dev_exit () do { } while (0)
drivers/net/ppp_generic.c +2 -2
@@ -2926,5 +2926,5 @@ EXPORT_SYMBOL(ppp_output_wakeup);EXPORT_SYMBOL (ppp_register_compressor);EXPORT_SYMBOL (ppp_unregister_compressor);MODULE_LICENSE ("GPL" ); -MODULE_ALIAS_CHARDEV_MAJOR (PPP_MAJOR ); -MODULE_ALIAS ("/dev/ppp" ); +MODULE_ALIAS_CHARDEV (PPP_MAJOR ,0 ); +MODULE_ALIAS ("devname:ppp" );
drivers/net/tun.c +1 -0
@@ -1649,3 +1649,4 @@ MODULE_DESCRIPTION(DRV_DESCRIPTION);MODULE_AUTHOR (DRV_COPYRIGHT );MODULE_LICENSE ("GPL" );MODULE_ALIAS_MISCDEV (TUN_MINOR ); +MODULE_ALIAS ("devname:net/tun" );
fs/autofs4/dev-ioctl.c +4 -1
@@ -736,11 +736,14 @@ static const struct file_operations _dev_ioctl_fops = { };static struct miscdevice _autofs_dev_ioctl_misc = { - .minor =MISC_DYNAMIC_MINOR , + .minor =AUTOFS_MINOR , .name =AUTOFS_DEVICE_NAME , .fops = &_dev_ioctl_fops }; +MODULE_ALIAS_MISCDEV (AUTOFS_MINOR ); +MODULE_ALIAS ("devname:autofs" ); +/* Register/deregister misc character device */ int autofs_dev_ioctl_init (void ) {
fs/btrfs/super.c +4 -1
@@ -832,11 +832,14 @@ static const struct file_operations btrfs_ctl_fops = { };static struct miscdevice btrfs_misc = { - .minor =MISC_DYNAMIC_MINOR , + .minor =BTRFS_MINOR , .name ="btrfs-control" , .fops = &btrfs_ctl_fops }; +MODULE_ALIAS_MISCDEV (BTRFS_MINOR ); +MODULE_ALIAS ("devname:btrfs-control" ); +static int btrfs_interface_init (void ) {return misc_register (&btrfs_misc);
fs/fuse/dev.c +1 -0
@@ -18,6 +18,7 @@#include <linux/slab.h> MODULE_ALIAS_MISCDEV (FUSE_MINOR ); +MODULE_ALIAS ("devname:fuse" );static struct kmem_cache *fuse_req_cachep;
include/linux/miscdevice.h +2 -0
@@ -31,6 +31,8 @@#define FUSE_MINOR 229#define KVM_MINOR 232#define VHOST_NET_MINOR 233 +#define BTRFS_MINOR 234 +#define AUTOFS_MINOR 235#define MISC_DYNAMIC_MINOR 255struct device ;
Signature · 1 line
1.7.0.3
Re: [PATCH 1/1] driver core: add devname module aliases to allow module on-demand auto-loading
Quoted 11 lines · On Tue, 25 May 2010 15:16:38 -0700 Greg Kroah-Hartman wrote:
From: Kay Sievers <[email protected]>
This adds:
alias: devname:<name>
to some common kernel modules, which will allow the on-demand loading of the kernel module when the device node is accessed.Ideally all these modules would be compiled-in, but distros seems too much in love with their modularization that we need to cover the common cases with this new facility. It will allow us to remove a bunch of pretty useless init scripts and modprobes from init scripts.
[snip]
I have no objection to this patch or to it being merged.
I just note that this patch was posted to lkml on 2010-May-20.
If it causes any problems, it can easily be reverted.
I think that some (other, non-gregkh and non-davem) maintainers take far too long to merge some patches. Maybe it's just a merge window thing.
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***