Re: [PATCH] Kmod optimization

From: Randy.Dunlap
Date: Thu Apr 13 2006 - 14:19:16 EST


On Thu, 13 Apr 2006 20:03:45 +0200 tyler@xxxxxxxx wrote:

> Hi,
>
> the request_mod functions try to load automatically a module by running
> a user mode process helper (modprobe).
>
> The user process is launched even if the module is already loaded. I
> think it would be better to test if the module is already loaded.

Please try not to use attachments: it makes it more difficult
to review and comment on code (so I'll paste it here).


+ /* We don't to load the module if it's already loaded */
+ spin_lock_irqsave(&modlist_lock, flags);
+ if (is_loaded(module_name)) {
+ return -EEXIST;
+ }
+ spin_unlock_irqrestore(&modlist_lock, flags);

Need to do spin_unlock_irqrestore() even if is_loaded() is true.

+/* Test if a module is loaded : must hold module_mutex */
+int is_loaded(const char *module_name);
+{
+ struct module *mod = find_module(module_name);
+
+ if (!mod) {
+ return 1;
+ }

Don't use braces when not needed.
Why not make this function inline and put it into a header file?

---
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/