mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
coallocate socket_wq with socket itself
socket->wq is assign-once, set when we are initializing both struct socket it's in and struct socket_wq it points to. As the matter of fact, the only reason for separate allocation was the ability to RCU-delay freeing of socket_wq. RCU-delaying the freeing of socket itself gets rid of that need, so we can just fold struct socket_wq into the end of struct socket and simplify the life both for sock_alloc_inode() (one allocation instead of two) and for tun/tap oddballs, where we used to embed struct socket and struct socket_wq into the same structure (now - embedding just the struct socket). Note that reference to struct socket_wq in struct sock does remain a reference - that's unchanged. Signed-off-by: Al Viro <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
6d7855c54e
commit
333f7909a8
7 changed files with 15 additions and 28 deletions
19
net/socket.c
19
net/socket.c
|
|
@ -234,20 +234,13 @@ static struct kmem_cache *sock_inode_cachep __ro_after_init;
|
|||
static struct inode *sock_alloc_inode(struct super_block *sb)
|
||||
{
|
||||
struct socket_alloc *ei;
|
||||
struct socket_wq *wq;
|
||||
|
||||
ei = kmem_cache_alloc(sock_inode_cachep, GFP_KERNEL);
|
||||
if (!ei)
|
||||
return NULL;
|
||||
wq = kmalloc(sizeof(*wq), GFP_KERNEL);
|
||||
if (!wq) {
|
||||
kmem_cache_free(sock_inode_cachep, ei);
|
||||
return NULL;
|
||||
}
|
||||
init_waitqueue_head(&wq->wait);
|
||||
wq->fasync_list = NULL;
|
||||
wq->flags = 0;
|
||||
ei->socket.wq = wq;
|
||||
init_waitqueue_head(&ei->socket.wq.wait);
|
||||
ei->socket.wq.fasync_list = NULL;
|
||||
ei->socket.wq.flags = 0;
|
||||
|
||||
ei->socket.state = SS_UNCONNECTED;
|
||||
ei->socket.flags = 0;
|
||||
|
|
@ -263,7 +256,6 @@ static void sock_free_inode(struct inode *inode)
|
|||
struct socket_alloc *ei;
|
||||
|
||||
ei = container_of(inode, struct socket_alloc, vfs_inode);
|
||||
kfree(ei->socket.wq);
|
||||
kmem_cache_free(sock_inode_cachep, ei);
|
||||
}
|
||||
|
||||
|
|
@ -599,7 +591,7 @@ static void __sock_release(struct socket *sock, struct inode *inode)
|
|||
module_put(owner);
|
||||
}
|
||||
|
||||
if (sock->wq->fasync_list)
|
||||
if (sock->wq.fasync_list)
|
||||
pr_err("%s: fasync list not empty!\n", __func__);
|
||||
|
||||
if (!sock->file) {
|
||||
|
|
@ -1288,13 +1280,12 @@ static int sock_fasync(int fd, struct file *filp, int on)
|
|||
{
|
||||
struct socket *sock = filp->private_data;
|
||||
struct sock *sk = sock->sk;
|
||||
struct socket_wq *wq;
|
||||
struct socket_wq *wq = &sock->wq;
|
||||
|
||||
if (sk == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
lock_sock(sk);
|
||||
wq = sock->wq;
|
||||
fasync_helper(fd, filp, on, &wq->fasync_list);
|
||||
|
||||
if (!wq->fasync_list)
|
||||
|
|
|
|||
Loading…
Reference in a new issue