]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net/socket.c: switch to CLASS(fd)
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 26 May 2024 03:32:20 +0000 (23:32 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 3 Nov 2024 06:27:11 +0000 (01:27 -0500)
commit53c0a58beb60b76e105a61aae518fd780eec03d9
tree0d3e4e7f5eba0b23077c78269a98c9cf5a31c4a5
parent8cf0b93919e13d1e8d4466eb4080a4c4d9d66d7b
net/socket.c: switch to CLASS(fd)

The important part in sockfd_lookup_light() is avoiding needless
file refcount operations, not the marginal reduction of the register
pressure from not keeping a struct file pointer in the caller.

Switch to use fdget()/fdpu(); with sane use of CLASS(fd) we can
get a better code generation...

Would be nice if somebody tested it on networking test suites
(including benchmarks)...

sockfd_lookup_light() does fdget(), uses sock_from_file() to
get the associated socket and returns the struct socket reference to
the caller, along with "do we need to fput()" flag.  No matching fdput(),
the caller does its equivalent manually, using the fact that sock->file
points to the struct file the socket has come from.

Get rid of that - have the callers do fdget()/fdput() and
use sock_from_file() directly.  That kills sockfd_lookup_light()
and fput_light() (no users left).

What's more, we can get rid of explicit fdget()/fdput() by
switching to CLASS(fd, ...) - code generation does not suffer, since
now fdput() inserted on "descriptor is not opened" failure exit
is recognized to be a no-op by compiler.

[folded a fix for braino in do_recvmmsg() caught by Simon Horman]

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
include/linux/file.h
net/socket.c