Skip to content

Commit

Permalink
[NET]: Make use of ->private_data in sockfd_lookup
Browse files Browse the repository at this point in the history
Please consider the patch below which makes use of file->private_data to
store the pointer to the socket, which avoids touching several unused
cachelines in the dentry and inode in sockfd_lookup.

Signed-off-by: Benjamin LaHaise <bcrl@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Benjamin LaHaise authored and David S. Miller committed Aug 29, 2005
1 parent cef07fd commit 07dc3f0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ int sock_map_fd(struct socket *sock)
file->f_mode = FMODE_READ | FMODE_WRITE;
file->f_flags = O_RDWR;
file->f_pos = 0;
file->private_data = sock;
fd_install(fd, file);
}

Expand Down Expand Up @@ -436,6 +437,9 @@ struct socket *sockfd_lookup(int fd, int *err)
return NULL;
}

if (file->f_op == &socket_file_ops)
return file->private_data; /* set in sock_map_fd */

inode = file->f_dentry->d_inode;
if (!S_ISSOCK(inode->i_mode)) {
*err = -ENOTSOCK;
Expand Down

0 comments on commit 07dc3f0

Please sign in to comment.