lkml.org 
[lkml]   [2003]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] Migrating net/sched to new module interface
Il Tue, Jan 14, 2003 at 01:32:56AM +0300, Alexey N. Kuznetsov ha scritto: 
> Which does not matter at all, because the hole
>
> void cleanup_module(void)
> {
> <an instance is cloned here>
> unregister_qdisc(&cbq_qdisc_ops);
> }
>
> remained in any case, be it under some preemptive, nonprepemtive lock or
> not under a lock at all.

Hmm, this can't happen now. The try_module_get() will fail if the module
is going away and so qdisc_create won't create a new qdisc.

> BTW, Rusty, a question... I do not understand, what is purpose of this
> "new" module stuff at all?

The idea is to use try_module_get() before using any interface
registered by the module. Every module has a state associated to it: if
the module has been loaded but it is still in its init section its
state will be MODULE_STATE_COMING (and try_module_get() will fail);
if the module is in process of being unloaded its state will be
MODULE_STATE_LIVE (and try_module_get() will fail); otherwise the state
will be MODULE_STATE_LIVE (and try_module_get() will success).

If we use try_module_get() before using the module and module_put() when
we are done everything will work:

int create_foo(foo **new) {
if (try_module_get(foo->owner) == 0)
/* Module is being unloaded, it's not safe to use it */
return -ENOSYS;

*new = foo->new_foo();
}

void destroy_foo(foo *foo) {
foo->finalize();

module_put(foo->owner);
}


This is what I've done for the packet scheduler: try_module_get() is
called *before* cloning the qdisc and if it fails the qdisc won't be
cloned. module_put() is called in qdisc_destroy(), after ->destroy(),
when we are sure that nobody will ever use a reference to the qdisc.

Luca
--
Reply-To: kronos@kronoz.cjb.net
Home: http://kronoz.cjb.net
Non capisco tutta questa eccitazione per il Multitasking:
io sono anni che leggo in bagno.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:32    [W:0.143 / U:0.844 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site