Re: [RFC PATCH 2/3] add statmnt(2) syscall

3 messages, 3 authors, 2023-09-26 · open the first message on its own page

Re: [RFC PATCH 2/3] add statmnt(2) syscall

From: Florian Weimer <hidden>
Date: 2023-09-26 13:49:56

* Miklos Szeredi:
On Mon, Sep 18, 2023 at 3:51 PM Christian Brauner [off-list ref] wrote:
quoted
I really would prefer a properly typed struct and that's what everyone
was happy with in the session as well. So I would not like to change the
main parameters.
I completely  agree.  Just would like to understand this point:

  struct statmnt *statmnt(u64 mntid, u64 mask, unsigned int flags);

What's not properly typed about this interface?

I guess the answer is that it's not a syscall interface, which will
have an added [void *buf, size_t bufsize], while the buffer sizing is
done by a simple libc wrapper.

Do you think that's a problem?  If so, why?
Try-and-resize interfaces can be quite bad for data obtained from the
network.  If the first call provides the minimum buffer size (like
getgroups, but unlike readlink or the glibc *_r interfaces for NSS),
this could at least allow us to avoid allocating too much.  In
userspace, we cannot reduce the size of the heap allocation without
knowing where the pointers are and what they mean.

I also don't quite understand the dislike of variable-sized records.
Don't getdents, inotify, Netlink all use them?  And I think at least for
Netlink, more stuff is added all the time?

Thanks,
Florian

Re: [RFC PATCH 2/3] add statmnt(2) syscall

From: Miklos Szeredi <miklos@szeredi.hu>
Date: 2023-09-26 14:06:25

On Tue, 26 Sept 2023 at 15:49, Florian Weimer [off-list ref] wrote:
* Miklos Szeredi:
quoted
On Mon, Sep 18, 2023 at 3:51 PM Christian Brauner [off-list ref] wrote:
quoted
I really would prefer a properly typed struct and that's what everyone
was happy with in the session as well. So I would not like to change the
main parameters.
I completely  agree.  Just would like to understand this point:

  struct statmnt *statmnt(u64 mntid, u64 mask, unsigned int flags);

What's not properly typed about this interface?

I guess the answer is that it's not a syscall interface, which will
have an added [void *buf, size_t bufsize], while the buffer sizing is
done by a simple libc wrapper.

Do you think that's a problem?  If so, why?
Try-and-resize interfaces can be quite bad for data obtained from the
network.
In this particular case it's all local information.
 If the first call provides the minimum buffer size (like
getgroups, but unlike readlink or the glibc *_r interfaces for NSS),
this could at least allow us to avoid allocating too much.  In
userspace, we cannot reduce the size of the heap allocation without
knowing where the pointers are and what they mean.
Does it matter if the heap allocation is say 32k instead of 589bytes?
 The returned strings are not limited in size, but are quite unlikely
to be over PATH_MAX.

E.g. getdents apparently uses 32k buffers, which is really a tiny
amount of heap these days, but more than enough for the purpose.  Not
sure if this is hard coded into libc or if it's the result of some
heuristic based on available memory, but I don't see why similar
treatment couldn't be applied to the statmount(2) syscall.
I also don't quite understand the dislike of variable-sized records.
Don't getdents, inotify, Netlink all use them?  And I think at least for
Netlink, more stuff is added all the time?
What do you mean by variable sized records?

Thanks,
Miklos

Re: [RFC PATCH 2/3] add statmnt(2) syscall

From: Christian Brauner <brauner@kernel.org>
Date: 2023-09-26 14:14:03

I also don't quite understand the dislike of variable-sized records.
Don't getdents, inotify, Netlink all use them?  And I think at least for
Netlink, more stuff is added all the time?
Netlink is absolutely atrocious to work with because everything is
variable sized and figuring out the correct allocation size is a
complete nightmare even with the "helpful" macros that are provided.

The bigger problem however is the complete untypedness even of the most
basic things. For example, retrieving the mtu of a network interface
through netlink is a complete nightmare. getdents, inotify, fanotify,
open_by_handle_at()'s struct fiel_handle are all fine. But let's
absolutely not take netlink as a model for anything related to mounts.

And no one is against again variable sized records per se. I think we're
coming to a good compromise here.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help