From cfd466a245573ae929f1dfb106a8741cb8e353a3 Mon Sep 17 00:00:00 2001 From: John Stultz Date: Fri, 19 Mar 2010 12:23:57 -0400 Subject: [PATCH] --- yaml --- r: 198558 b: refs/heads/master c: 9ce34c8f4466608bc67630a42d04f4aaf0443d9b h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/Documentation/devices.txt | 2 - trunk/arch/alpha/Kconfig | 4 -- trunk/arch/alpha/kernel/time.c | 69 ++++++++++++-------------- trunk/arch/x86/kernel/microcode_core.c | 1 - trunk/drivers/net/ppp_generic.c | 4 +- trunk/drivers/net/tun.c | 1 - trunk/fs/autofs4/dev-ioctl.c | 5 +- trunk/fs/btrfs/super.c | 5 +- trunk/fs/fuse/dev.c | 1 - trunk/include/linux/miscdevice.h | 2 - trunk/kernel/module.c | 59 ++++++++++++++-------- 12 files changed, 73 insertions(+), 82 deletions(-) diff --git a/[refs] b/[refs] index 2093ffa0c674..d5e0c80f48a0 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b142ebb61cd36370c6fac5e0b8261a6cd7bba782 +refs/heads/master: 9ce34c8f4466608bc67630a42d04f4aaf0443d9b diff --git a/trunk/Documentation/devices.txt b/trunk/Documentation/devices.txt index 1d83d124056c..53d64d382343 100644 --- a/trunk/Documentation/devices.txt +++ b/trunk/Documentation/devices.txt @@ -443,8 +443,6 @@ 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 diff --git a/trunk/arch/alpha/Kconfig b/trunk/arch/alpha/Kconfig index b7193986cbf9..24efdfe277fc 100644 --- a/trunk/arch/alpha/Kconfig +++ b/trunk/arch/alpha/Kconfig @@ -51,10 +51,6 @@ config GENERIC_TIME bool default y -config ARCH_USES_GETTIMEOFFSET - bool - default y - config GENERIC_CMOS_UPDATE def_bool y diff --git a/trunk/arch/alpha/kernel/time.c b/trunk/arch/alpha/kernel/time.c index 5465e932e568..1efbed82c0fd 100644 --- a/trunk/arch/alpha/kernel/time.c +++ b/trunk/arch/alpha/kernel/time.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "proto.h" #include "irq_impl.h" @@ -332,6 +333,34 @@ rpcc_after_update_in_progress(void) return rpcc(); } +#ifndef CONFIG_SMP +/* Until and unless we figure out how to get cpu cycle counters + in sync and keep them there, we can't use the rpcc. */ +static cycle_t read_rpcc(struct clocksource *cs) +{ + cycle_t ret = (cycle_t)rpcc(); + return ret; +} + +static struct clocksource clocksource_rpcc = { + .name = "rpcc", + .rating = 300, + .read = read_rpcc, + .mask = CLOCKSOURCE_MASK(32), + .flags = CLOCK_SOURCE_IS_CONTINUOUS +}; + +static inline void register_rpcc_clocksource(long cycle_freq) +{ + clocksource_calc_mult_shift(&clocksource_rpcc, cycle_freq, 4); + clocksource_register(&clocksource_rpcc); +} +#else /* !CONFIG_SMP */ +static inline void register_rpcc_clocksource(long cycle_freq) +{ +} +#endif /* !CONFIG_SMP */ + void __init time_init(void) { @@ -385,6 +414,8 @@ time_init(void) __you_loose(); } + register_rpcc_clocksource(cycle_freq); + state.last_time = cc1; state.scaled_ticks_per_cycle = ((unsigned long) HZ << FIX_SHIFT) / cycle_freq; @@ -394,44 +425,6 @@ time_init(void) alpha_mv.init_rtc(); } -/* - * Use the cycle counter to estimate an displacement from the last time - * tick. Unfortunately the Alpha designers made only the low 32-bits of - * the cycle counter active, so we overflow on 8.2 seconds on a 500MHz - * part. So we can't do the "find absolute time in terms of cycles" thing - * that the other ports do. - */ -u32 arch_gettimeoffset(void) -{ -#ifdef CONFIG_SMP - /* Until and unless we figure out how to get cpu cycle counters - in sync and keep them there, we can't use the rpcc tricks. */ - return 0; -#else - unsigned long delta_cycles, delta_usec, partial_tick; - - delta_cycles = rpcc() - state.last_time; - partial_tick = state.partial_tick; - /* - * usec = cycles * ticks_per_cycle * 2**48 * 1e6 / (2**48 * ticks) - * = cycles * (s_t_p_c) * 1e6 / (2**48 * ticks) - * = cycles * (s_t_p_c) * 15625 / (2**42 * ticks) - * - * which, given a 600MHz cycle and a 1024Hz tick, has a - * dynamic range of about 1.7e17, which is less than the - * 1.8e19 in an unsigned long, so we are safe from overflow. - * - * Round, but with .5 up always, since .5 to even is harder - * with no clear gain. - */ - - delta_usec = (delta_cycles * state.scaled_ticks_per_cycle - + partial_tick) * 15625; - delta_usec = ((delta_usec / ((1UL << (FIX_SHIFT-6-1)) * HZ)) + 1) / 2; - return delta_usec * 1000; -#endif -} - /* * In order to set the CMOS clock precisely, set_rtc_mmss has to be * called 500 ms after the second nowtime has started, because when diff --git a/trunk/arch/x86/kernel/microcode_core.c b/trunk/arch/x86/kernel/microcode_core.c index fa6551d36c10..2cd8c544e41a 100644 --- a/trunk/arch/x86/kernel/microcode_core.c +++ b/trunk/arch/x86/kernel/microcode_core.c @@ -260,7 +260,6 @@ 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) diff --git a/trunk/drivers/net/ppp_generic.c b/trunk/drivers/net/ppp_generic.c index c5f8eb102bf7..5441688daba7 100644 --- a/trunk/drivers/net/ppp_generic.c +++ b/trunk/drivers/net/ppp_generic.c @@ -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(PPP_MAJOR, 0); -MODULE_ALIAS("devname:ppp"); +MODULE_ALIAS_CHARDEV_MAJOR(PPP_MAJOR); +MODULE_ALIAS("/dev/ppp"); diff --git a/trunk/drivers/net/tun.c b/trunk/drivers/net/tun.c index 005cad689578..97b25533e5fb 100644 --- a/trunk/drivers/net/tun.c +++ b/trunk/drivers/net/tun.c @@ -1649,4 +1649,3 @@ MODULE_DESCRIPTION(DRV_DESCRIPTION); MODULE_AUTHOR(DRV_COPYRIGHT); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(TUN_MINOR); -MODULE_ALIAS("devname:net/tun"); diff --git a/trunk/fs/autofs4/dev-ioctl.c b/trunk/fs/autofs4/dev-ioctl.c index d832062869f6..d29b7f6df862 100644 --- a/trunk/fs/autofs4/dev-ioctl.c +++ b/trunk/fs/autofs4/dev-ioctl.c @@ -736,14 +736,11 @@ static const struct file_operations _dev_ioctl_fops = { }; static struct miscdevice _autofs_dev_ioctl_misc = { - .minor = AUTOFS_MINOR, + .minor = MISC_DYNAMIC_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) { diff --git a/trunk/fs/btrfs/super.c b/trunk/fs/btrfs/super.c index 2909a03e5230..1866dff0538e 100644 --- a/trunk/fs/btrfs/super.c +++ b/trunk/fs/btrfs/super.c @@ -832,14 +832,11 @@ static const struct file_operations btrfs_ctl_fops = { }; static struct miscdevice btrfs_misc = { - .minor = BTRFS_MINOR, + .minor = MISC_DYNAMIC_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); diff --git a/trunk/fs/fuse/dev.c b/trunk/fs/fuse/dev.c index e53df5ebb2b8..eb7e9423691f 100644 --- a/trunk/fs/fuse/dev.c +++ b/trunk/fs/fuse/dev.c @@ -18,7 +18,6 @@ #include MODULE_ALIAS_MISCDEV(FUSE_MINOR); -MODULE_ALIAS("devname:fuse"); static struct kmem_cache *fuse_req_cachep; diff --git a/trunk/include/linux/miscdevice.h b/trunk/include/linux/miscdevice.h index b631c46cffd9..8b5f7cc0fba6 100644 --- a/trunk/include/linux/miscdevice.h +++ b/trunk/include/linux/miscdevice.h @@ -31,8 +31,6 @@ #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 255 struct device; diff --git a/trunk/kernel/module.c b/trunk/kernel/module.c index 333fbcc96978..625985e70e9d 100644 --- a/trunk/kernel/module.c +++ b/trunk/kernel/module.c @@ -563,33 +563,26 @@ int use_module(struct module *a, struct module *b) struct module_use *use; int no_warn, err; - if (b == NULL || already_uses(a, b)) return 1; - - /* If we're interrupted or time out, we fail. */ - if (wait_event_interruptible_timeout( - module_wq, (err = strong_try_module_get(b)) != -EBUSY, - 30 * HZ) <= 0) { - printk("%s: gave up waiting for init of module %s.\n", - a->name, b->name); + if (b == NULL || already_uses(a, b)) return 0; - } - /* If strong_try_module_get() returned a different error, we fail. */ + /* If we're interrupted or time out, we fail. */ + err = strong_try_module_get(b); if (err) - return 0; + return err; DEBUGP("Allocating new usage for %s.\n", a->name); use = kmalloc(sizeof(*use), GFP_ATOMIC); if (!use) { printk("%s: out of memory loading\n", a->name); module_put(b); - return 0; + return -ENOMEM; } use->module_which_uses = a; list_add(&use->list, &b->modules_which_use_me); no_warn = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name); - return 1; + return 0; } EXPORT_SYMBOL_GPL(use_module); @@ -882,7 +875,7 @@ static inline void module_unload_free(struct module *mod) int use_module(struct module *a, struct module *b) { - return strong_try_module_get(b) == 0; + return strong_try_module_get(b); } EXPORT_SYMBOL_GPL(use_module); @@ -1053,17 +1046,39 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs, struct module *owner; const struct kernel_symbol *sym; const unsigned long *crc; + DEFINE_WAIT(wait); + int err; + long timeleft = 30 * HZ; +again: sym = find_symbol(name, &owner, &crc, !(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true); - /* use_module can fail due to OOM, - or module initialization or unloading */ - if (sym) { - if (!check_version(sechdrs, versindex, name, mod, crc, owner) - || !use_module(mod, owner)) - sym = NULL; - } - return sym; + if (!sym) + return NULL; + + if (!check_version(sechdrs, versindex, name, mod, crc, owner)) + return NULL; + + prepare_to_wait(&module_wq, &wait, TASK_INTERRUPTIBLE); + err = use_module(mod, owner); + if (likely(!err) || err != -EBUSY || signal_pending(current)) { + finish_wait(&module_wq, &wait); + return err ? NULL : sym; + } + + /* Module is still loading. Drop lock and wait. */ + mutex_unlock(&module_mutex); + timeleft = schedule_timeout(timeleft); + mutex_lock(&module_mutex); + finish_wait(&module_wq, &wait); + + /* Module might be gone entirely, or replaced. Re-lookup. */ + if (timeleft) + goto again; + + printk(KERN_WARNING "%s: gave up waiting for init of module %s.\n", + mod->name, owner->name); + return NULL; } /*