Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.system > #487
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Rainer Weikusat <rweikusat@mssgmbh.com> |
| Newsgroups | comp.os.linux.development.system, comp.os.linux.embedded |
| Subject | Re: sock_create() in kernel |
| Date | Wed, 19 Dec 2012 16:06:49 +0000 |
| Lines | 56 |
| Message-ID | <878v8uyqjq.fsf@sapphire.mobileactivedefense.com> (permalink) |
| References | <kasls6$jdk$1@speranza.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | individual.net y7VM/YKkk7BZXy4Fv1r2YgXiT/UbcKsNoiRGgiSXaURFbEmWrAONBescWdoXNynAM= |
| Cancel-Lock | sha1:eEBp3FQ+48a0ghXvU7JFNpl3SKM= sha1:LrsmbFMsGJgwenxHtSrgzUwtc90= |
| User-Agent | Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
| Xref | csiph.com comp.os.linux.development.system:487 comp.os.linux.embedded:389 |
Cross-posted to 2 groups.
Show key headers only | View raw
"Mark" <mark_cruzNOTFORSPAM@hotmail.com> writes:
[...]
> static int __sock_create(struct net *net, int family, int type, int
> protocol, struct socket **res, int kern)
> {
> sock = sock_alloc();
> ...
> if (!try_module_get(pf->owner))
> goto out_release;
>
> err = pf->create(net, sock, protocol);
> ...
>
> if (!try_module_get(sock->ops->owner))
> goto out_module_busy
>
> ...
> }
>
> Essentially if socket relevant callbacks are in a module, then whenever
> every socket() from the user space will bump the module's reference count
> twice. What's the rationale for such behaviour ?
Have you considered reading the comments and looking at the
surrounding code?
/*
* We will call the ->create function, that possibly is in a loadable
* module, so we have to bump that loadable module refcnt first.
*/
if (!try_module_get(pf->owner))
goto out_release;
/* Now protected by module ref count */
rcu_read_unlock();
err = pf->create(net, sock, protocol, kern);
if (err < 0)
goto out_module_put;
/*
* Now to bump the refcnt of the [loadable] module that owns this
* socket at sock_release time we decrement its refcnt.
*/
if (!try_module_get(sock->ops->owner))
goto out_module_busy;
/*
* Now that we're done with the ->create function, the [loadable]
* module can have its refcnt decremented
*/
module_put(pf->owner);
[net/socket.c]
Back to comp.os.linux.development.system | Previous | Next — Previous in thread | Find similar
sock_create() in kernel "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2012-12-19 10:18 -0500 Re: sock_create() in kernel Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-12-19 16:06 +0000
csiph-web