lkml.org 
[lkml]   [2021]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net-next] net: socket: integrate sockfd_lookup() and sockfd_lookup_light()
From
Date


On 9/21/21 11:31 PM, Yajun Deng wrote:
> As commit 6cb153cab92a("[NET]: use fget_light() in net/socket.c") said,
> sockfd_lookup_light() is lower load than sockfd_lookup(). So we can
> remove sockfd_lookup() but keep the name. As the same time, move flags
> to sockfd_put().

???

>
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
> include/linux/net.h | 8 +++-
> net/socket.c | 101 +++++++++++++++++---------------------------
> 2 files changed, 46 insertions(+), 63 deletions(-)
>
> diff --git a/include/linux/net.h b/include/linux/net.h
> index ba736b457a06..63a179d4f760 100644
> --- a/include/linux/net.h
> +++ b/include/linux/net.h
> @@ -238,8 +238,14 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags);
> struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname);
> struct socket *sockfd_lookup(int fd, int *err);
> struct socket *sock_from_file(struct file *file);
> -#define sockfd_put(sock) fput(sock->file)
> int net_ratelimit(void);
> +#define sockfd_put(sock) \
> +do { \
> + struct fd *fd = (struct fd *)&sock->file; \
> + \
> + if (fd->flags & FDPUT_FPUT) \
> + fput(sock->file); \
> +} while (0)
>

Really ?

I wonder how was this tested ?

We can not store FDPUT_FPUT in the sock itself, for obvious reasons.
Each thread needs to keep this information private.

\
 
 \ /
  Last update: 2021-09-23 18:50    [W:0.113 / U:1.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site