Hello,
I was looking in to __sock_create() code to get better understanding of the kernel's internal machinery and found that the kernel calls try_module_get() twice; here is a snippet:
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 ?
Thanks.
Mark