Skip to content

Commit 8bd4c0b

Browse files
Al Virogregkh
authored andcommitted
net/socket.c: switch to CLASS(fd)
[ Upstream commit 53c0a58 ] 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> Stable-dep-of: 66052a7 ("fanotify: call fanotify_events_supported() before path_permission() and security_path_notify()") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 45b6764 commit 8bd4c0b

2 files changed

Lines changed: 137 additions & 172 deletions

File tree

include/linux/file.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ extern struct file *alloc_file_pseudo_noaccount(struct inode *, struct vfsmount
3030
extern struct file *alloc_file_clone(struct file *, int flags,
3131
const struct file_operations *);
3232

33-
static inline void fput_light(struct file *file, int fput_needed)
34-
{
35-
if (fput_needed)
36-
fput(file);
37-
}
38-
3933
/* either a reference to struct file + flags
4034
* (cloned vs. borrowed, pos locked), with
4135
* flags stored in lower bits of value,

0 commit comments

Comments
 (0)