Benjamin LaHaise a écrit :

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 <[EMAIL PROTECTED]>
diff -purN 00_v2.6.13-rc6/net/socket.c 01_net_file/net/socket.c
--- 00_v2.6.13-rc6/net/socket.c 2005-08-04 15:56:11.000000000 -0400
+++ 01_net_file/net/socket.c    2005-08-10 11:13:18.000000000 -0400
@@ -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);
        }
@@ -436,6 +437,9 @@ struct socket *sockfd_lookup(int fd, int
                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;

Hi

I really like this patch. Thank you Benjamin

David, do you think we could place file->private_data in the same cache line than file->f_count and file->f_op, so that sockfd_lookup() can access all the needed information (f_count, f_op, private_data) using one L1_CACHE_LINE only ?

Signed-off-by: Eric Dumazet <[EMAIL PROTECTED]>

--- linux-2.6.13-rc6-orig/include/linux/fs.h    2005-08-17 21:29:48.000000000 
+0200
+++ linux-2.6.13-rc6/include/linux/fs.h 2005-08-17 21:34:26.000000000 +0200
@@ -586,6 +586,8 @@
        struct dentry           *f_dentry;
        struct vfsmount         *f_vfsmnt;
        struct file_operations  *f_op;
+       /* needed for tty driver, sockets, epoll, and maybe others */
+       void                    *private_data;
        atomic_t                f_count;
        unsigned int            f_flags;
        mode_t                  f_mode;
@@ -598,8 +600,6 @@
        unsigned long           f_version;
        void                    *f_security;
 
-       /* needed for tty driver, and maybe others */
-       void                    *private_data;
 
 #ifdef CONFIG_EPOLL
        /* Used by fs/eventpoll.c to link all the hooks to this file */

Reply via email to