net/socket.c: use straight fdget/fdput
Subsystems (3)
Al Viro
maintainerPATCH 1/1 net/socket.c: use straight fdget/fdput
Checking the theory that 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.
If that's true, we should get the same benefits from straight fdget()/fdput(). And AFAICS 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)...
Signed-off-by Al Viro <[email protected]>
---
include/linux/file.h +6 -6
@@ -29,12 +29,6 @@ extern struct file *alloc_file_pseudo_noaccount(struct inode *, struct vfsmountextern struct file *alloc_file_clone (struct file *,int flags,const struct file_operations *); -static inline void fput_light (struct file *file,int fput_needed) -{ -if (fput_needed) -fput (file); -} -struct fd {struct file *file;unsigned int flags;
@@ -76,6 +70,12 @@ static inline struct fd fdget_pos(int fd)return __to_fd (__fdget_pos (fd)); } +static inline bool fd_empty (struct fd f) +{ +// better code with gcc that way +return unlikely (!(f.flags | (unsigned long )f.file)); +} +static inline void fdput_pos (struct fd f) {if (f.flags &FDPUT_POS_UNLOCK )
net/socket.c +151 -184
553 lines not on this page · raw message