diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-23 11:13:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-23 11:13:19 -0400 |
commit | cb618965bc2073267b7f9345066f502515fcfdf5 (patch) | |
tree | 66632a2328272ce75e07f185cdfa8374c6ecfd2a | |
parent | 5e2daeb3c982ea19ecad0c2e720a4052034be14b (diff) | |
parent | 3401a61e16a5b852d4e353c8850c857105a67a9c (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
stop_machine: make stop_machine_run more virtualization friendly
doc: add a chapter about trylock functions [Bug 9011]
modules: proper cleanup of kobject without CONFIG_SYSFS
module loading ELF handling: use SELFMAG instead of numeric constant
-rw-r--r-- | Documentation/DocBook/kernel-locking.tmpl | 25 | ||||
-rw-r--r-- | kernel/module.c | 18 | ||||
-rw-r--r-- | kernel/stop_machine.c | 7 |
3 files changed, 44 insertions, 6 deletions
diff --git a/Documentation/DocBook/kernel-locking.tmpl b/Documentation/DocBook/kernel-locking.tmpl index 77c42f40be5..2510763295d 100644 --- a/Documentation/DocBook/kernel-locking.tmpl +++ b/Documentation/DocBook/kernel-locking.tmpl | |||
@@ -703,6 +703,31 @@ | |||
703 | </sect1> | 703 | </sect1> |
704 | </chapter> | 704 | </chapter> |
705 | 705 | ||
706 | <chapter id="trylock-functions"> | ||
707 | <title>The trylock Functions</title> | ||
708 | <para> | ||
709 | There are functions that try to acquire a lock only once and immediately | ||
710 | return a value telling about success or failure to acquire the lock. | ||
711 | They can be used if you need no access to the data protected with the lock | ||
712 | when some other thread is holding the lock. You should acquire the lock | ||
713 | later if you then need access to the data protected with the lock. | ||
714 | </para> | ||
715 | |||
716 | <para> | ||
717 | <function>spin_trylock()</function> does not spin but returns non-zero if | ||
718 | it acquires the spinlock on the first try or 0 if not. This function can | ||
719 | be used in all contexts like <function>spin_lock</function>: you must have | ||
720 | disabled the contexts that might interrupt you and acquire the spin lock. | ||
721 | </para> | ||
722 | |||
723 | <para> | ||
724 | <function>mutex_trylock()</function> does not suspend your task | ||
725 | but returns non-zero if it could lock the mutex on the first try | ||
726 | or 0 if not. This function cannot be safely used in hardware or software | ||
727 | interrupt contexts despite not sleeping. | ||
728 | </para> | ||
729 | </chapter> | ||
730 | |||
706 | <chapter id="Examples"> | 731 | <chapter id="Examples"> |
707 | <title>Common Examples</title> | 732 | <title>Common Examples</title> |
708 | <para> | 733 | <para> |
diff --git a/kernel/module.c b/kernel/module.c index f5e9491ef7a..5f80478b746 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1337,7 +1337,19 @@ out_unreg: | |||
1337 | kobject_put(&mod->mkobj.kobj); | 1337 | kobject_put(&mod->mkobj.kobj); |
1338 | return err; | 1338 | return err; |
1339 | } | 1339 | } |
1340 | #endif | 1340 | |
1341 | static void mod_sysfs_fini(struct module *mod) | ||
1342 | { | ||
1343 | kobject_put(&mod->mkobj.kobj); | ||
1344 | } | ||
1345 | |||
1346 | #else /* CONFIG_SYSFS */ | ||
1347 | |||
1348 | static void mod_sysfs_fini(struct module *mod) | ||
1349 | { | ||
1350 | } | ||
1351 | |||
1352 | #endif /* CONFIG_SYSFS */ | ||
1341 | 1353 | ||
1342 | static void mod_kobject_remove(struct module *mod) | 1354 | static void mod_kobject_remove(struct module *mod) |
1343 | { | 1355 | { |
@@ -1345,7 +1357,7 @@ static void mod_kobject_remove(struct module *mod) | |||
1345 | module_param_sysfs_remove(mod); | 1357 | module_param_sysfs_remove(mod); |
1346 | kobject_put(mod->mkobj.drivers_dir); | 1358 | kobject_put(mod->mkobj.drivers_dir); |
1347 | kobject_put(mod->holders_dir); | 1359 | kobject_put(mod->holders_dir); |
1348 | kobject_put(&mod->mkobj.kobj); | 1360 | mod_sysfs_fini(mod); |
1349 | } | 1361 | } |
1350 | 1362 | ||
1351 | /* | 1363 | /* |
@@ -1780,7 +1792,7 @@ static struct module *load_module(void __user *umod, | |||
1780 | 1792 | ||
1781 | /* Sanity checks against insmoding binaries or wrong arch, | 1793 | /* Sanity checks against insmoding binaries or wrong arch, |
1782 | weird elf version */ | 1794 | weird elf version */ |
1783 | if (memcmp(hdr->e_ident, ELFMAG, 4) != 0 | 1795 | if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0 |
1784 | || hdr->e_type != ET_REL | 1796 | || hdr->e_type != ET_REL |
1785 | || !elf_check_arch(hdr) | 1797 | || !elf_check_arch(hdr) |
1786 | || hdr->e_shentsize != sizeof(*sechdrs)) { | 1798 | || hdr->e_shentsize != sizeof(*sechdrs)) { |
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 0101aeef7ed..b7350bbfb07 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -62,8 +62,7 @@ static int stopmachine(void *cpu) | |||
62 | * help our sisters onto their CPUs. */ | 62 | * help our sisters onto their CPUs. */ |
63 | if (!prepared && !irqs_disabled) | 63 | if (!prepared && !irqs_disabled) |
64 | yield(); | 64 | yield(); |
65 | else | 65 | cpu_relax(); |
66 | cpu_relax(); | ||
67 | } | 66 | } |
68 | 67 | ||
69 | /* Ack: we are exiting. */ | 68 | /* Ack: we are exiting. */ |
@@ -106,8 +105,10 @@ static int stop_machine(void) | |||
106 | } | 105 | } |
107 | 106 | ||
108 | /* Wait for them all to come to life. */ | 107 | /* Wait for them all to come to life. */ |
109 | while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) | 108 | while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) { |
110 | yield(); | 109 | yield(); |
110 | cpu_relax(); | ||
111 | } | ||
111 | 112 | ||
112 | /* If some failed, kill them all. */ | 113 | /* If some failed, kill them all. */ |
113 | if (ret < 0) { | 114 | if (ret < 0) { |