Re: [PATCH] Kmod optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 13 Apr 2006 20:03:45 +0200 [email protected] 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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux