rpms/kernel/devel use-per_cpu-module-references.patch, NONE, 1.1 kernel.spec, 1.1217, 1.1218 kzalloc-mod_ref-instead-of-wasting-space.patch, 1.2, NONE
Kyle McMartin
kyle at fedoraproject.org
Thu Jan 15 07:41:35 UTC 2009
Author: kyle
Update of /cvs/pkgs/rpms/kernel/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv19889
Modified Files:
kernel.spec
Added Files:
use-per_cpu-module-references.patch
Removed Files:
kzalloc-mod_ref-instead-of-wasting-space.patch
Log Message:
* Thu Jan 15 2009 Kyle McMartin <kyle at redhat.com>
- New version of module_ref patch, uses per_cpu instead.
- Fix linux-2.6-hdpvr.patch up and re-enable.
Nuke .flush, was useless, convert to v4l2_file_operations, fix ioctl ret
- Fix linux-2.6-debug-taint-vm.patch and re-enable.
use-per_cpu-module-references.patch:
--- NEW FILE use-per_cpu-module-references.patch ---
diff --git a/include/linux/module.h b/include/linux/module.h
index 4f7ea12..61f97a2 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -219,11 +219,6 @@ void *__symbol_get_gpl(const char *symbol);
#endif
-struct module_ref
-{
- local_t count;
-} ____cacheline_aligned;
-
enum module_state
{
MODULE_STATE_LIVE,
@@ -345,7 +340,7 @@ struct module
void (*exit)(void);
/* Reference counts */
- struct module_ref ref[NR_CPUS];
+ local_t *ref; /* percpu */
#endif
};
#ifndef MODULE_ARCH_INIT
@@ -400,8 +395,9 @@ void symbol_put_addr(void *addr);
static inline void __module_get(struct module *module)
{
if (module) {
+ int cpu = get_cpu();
BUG_ON(module_refcount(module) == 0);
- local_inc(&module->ref[get_cpu()].count);
+ local_inc(per_cpu_ptr(module->ref, cpu));
put_cpu();
}
}
@@ -412,9 +408,9 @@ static inline int try_module_get(struct module *module)
if (module) {
unsigned int cpu = get_cpu();
- if (likely(module_is_live(module)))
- local_inc(&module->ref[cpu].count);
- else
+ if (likely(module_is_live(module))) {
+ local_inc(per_cpu_ptr(module->ref, cpu));
+ } else
ret = 0;
put_cpu();
}
diff --git a/kernel/module.c b/kernel/module.c
index c9332c9..e504f49 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -571,17 +571,19 @@ static char last_unloaded_module[MODULE_NAME_LEN+1];
#ifdef CONFIG_MODULE_UNLOAD
/* Init the unload section of the module. */
-static void module_unload_init(struct module *mod)
+static int module_unload_init(struct module *mod)
{
- unsigned int i;
+ mod->ref = percpu_alloc(sizeof(*mod->ref), GFP_KERNEL);
+ if (!mod->ref)
+ return -ENOMEM;
INIT_LIST_HEAD(&mod->modules_which_use_me);
- for (i = 0; i < NR_CPUS; i++)
- local_set(&mod->ref[i].count, 0);
/* Hold reference count during initialization. */
- local_set(&mod->ref[raw_smp_processor_id()].count, 1);
+ local_set(per_cpu_ptr(mod->ref, raw_smp_processor_id()), 1);
/* Backwards compatibility macros put refcount during init. */
mod->waiter = current;
+
+ return 0;
}
/* modules using other modules */
@@ -661,6 +663,8 @@ static void module_unload_free(struct module *mod)
}
}
}
+
+ percpu_free(mod->ref);
}
#ifdef CONFIG_MODULE_FORCE_UNLOAD
@@ -717,10 +721,12 @@ static int try_stop_module(struct module *mod, int flags, int *forced)
unsigned int module_refcount(struct module *mod)
{
- unsigned int i, total = 0;
+ unsigned int cpu, total = 0;
+
+ for_each_possible_cpu(cpu) {
+ total += local_read(per_cpu_ptr(mod->ref, cpu));
+ }
- for (i = 0; i < NR_CPUS; i++)
- total += local_read(&mod->ref[i].count);
return total;
}
EXPORT_SYMBOL(module_refcount);
@@ -894,7 +900,8 @@ void module_put(struct module *module)
{
if (module) {
unsigned int cpu = get_cpu();
- local_dec(&module->ref[cpu].count);
+
+ local_dec(per_cpu_ptr(module->ref, cpu));
/* Maybe they're waiting for us to drop reference? */
if (unlikely(!module_is_live(module)))
wake_up_process(module->waiter);
@@ -919,8 +926,9 @@ static inline int use_module(struct module *a, struct module *b)
return strong_try_module_get(b) == 0;
}
-static inline void module_unload_init(struct module *mod)
+static inline int module_unload_init(struct module *mod)
{
+ return 0;
}
#endif /* CONFIG_MODULE_UNLOAD */
@@ -2071,7 +2079,9 @@ static noinline struct module *load_module(void __user *umod,
mod = (void *)sechdrs[modindex].sh_addr;
/* Now we've moved module, initialize linked lists, etc. */
- module_unload_init(mod);
+ err = module_unload_init(mod);
+ if (err < 0)
+ goto free_unload;
/* add kobject, so we can reference it. */
err = mod_sysfs_init(mod);
Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel.spec,v
retrieving revision 1.1217
retrieving revision 1.1218
diff -u -r1.1217 -r1.1218
--- kernel.spec 15 Jan 2009 02:03:33 -0000 1.1217
+++ kernel.spec 15 Jan 2009 07:41:04 -0000 1.1218
@@ -659,7 +659,7 @@
# silence the ACPI blacklist code
Patch2802: linux-2.6-silence-acpi-blacklist.patch
-Patch9000: kzalloc-mod_ref-instead-of-wasting-space.patch
+Patch9000: use-per_cpu-module-references.patch
Patch9001: revert-fix-modules_install-via-nfs.patch
%endif
@@ -1066,7 +1066,7 @@
# Various low-impact patches to aid debugging.
ApplyPatch linux-2.6-debug-sizeof-structs.patch
ApplyPatch linux-2.6-debug-nmi-timeout.patch
-#ApplyPatch linux-2.6-debug-taint-vm.patch
+ApplyPatch linux-2.6-debug-taint-vm.patch
ApplyPatch linux-2.6-debug-spinlock-taint.patch
ApplyPatch linux-2.6-debug-vm-would-have-oomkilled.patch
ApplyPatch linux-2.6-debug-always-inline-kzalloc.patch
@@ -1131,7 +1131,7 @@
# http://www.lirc.org/
ApplyPatch linux-2.6.27-lirc.patch
# http://hg.jannau.net/hdpvr/
-#ApplyPatch linux-2.6-hdpvr.patch
+ApplyPatch linux-2.6-hdpvr.patch
# Fix the return code CD accesses when the CDROM drive door is closed
# but the drive isn't yet ready.
@@ -1162,7 +1162,7 @@
# revert 8b249b6856f16f09b0e5b79ce5f4d435e439b9d6
ApplyPatch revert-fix-modules_install-via-nfs.patch
-ApplyPatch kzalloc-mod_ref-instead-of-wasting-space.patch
+ApplyPatch use-per_cpu-module-references.patch
# END OF PATCH APPLICATIONS
%endif
@@ -1738,6 +1738,12 @@
%kernel_variant_files -k vmlinux %{with_kdump} kdump
%changelog
+* Thu Jan 15 2009 Kyle McMartin <kyle at redhat.com>
+- New version of module_ref patch, uses per_cpu instead.
+- Fix linux-2.6-hdpvr.patch up and re-enable.
+ Nuke .flush, was useless, convert to v4l2_file_operations, fix ioctl ret
+- Fix linux-2.6-debug-taint-vm.patch and re-enable.
+
* Wed Jan 14 2009 Dave Jones <davej at redhat.com>
- Test RODATA and NX during bootup.
--- kzalloc-mod_ref-instead-of-wasting-space.patch DELETED ---
More information about the fedora-extras-commits
mailing list