Re: [PATCH][CFT][experimental] net/socket.c: use straight fdget/fdput (resend)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 25 May 2024 at 22:07, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> IOW, we could do something like the attached. I think it's actually
> almost a cleanup [..]

The reason I say that is this part of the patch:

  -static inline struct fd __to_fd(unsigned long v)
  +static inline struct fd __to_fd(struct rawfd raw)
   {
  -       return (struct fd){(struct file *)(v & ~3),v & 3};
  +       return (struct fd){fdfile(raw),fdflags(raw)};
   }

which I think actually improves on our current situation.

No, my fdfile/fdflags functions aren't pretty, but they have more type
safety than the bare "unsigned long", and in that "__to_fd()" case I
think it actually makes that unpacking operation much more obvious.

It might be good to have the reverse "packing" helper inline function
too, so that __fdget() wouldn't do this:

                return (struct rawfd) { FDPUT_FPUT | (unsigned long)file };

but instead have some kind of "mkrawfd()" helper that does the above,
and we'd have

                return mkrawfd(file, FDPUT_FPUT);

instead. That would obviate my EMPTY_RAWFD macro, and we'd just use
"mkrawfd(NULL, 0)"?

Maybe this is bikeshedding. But I'd rather have this kind of explicit
one-word interface with a wrapped tagged pointer than have something
as subtle as your fd_empty() that magically generates better code in
certain very specific circumstances.

                     Linus




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux