From: Al Viro <viro@zeniv.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [GIT PULL] pidfd updates
Date: Tue, 25 Apr 2023 18:19:13 +0100 [thread overview]
Message-ID: <20230425171913.GT3390869@ZenIV> (raw)
In-Reply-To: <CAHk-=wjpBq2D97ih_AA0D7+KJ8ihT6WW_cn1BQc43wVgUioH2w@mail.gmail.com>
On Tue, Apr 25, 2023 at 09:28:54AM -0700, Linus Torvalds wrote:
> Now, since they are inline functions, the code generation doesn't
> really change (compilers are smart enough to not actually generate any
> pointer stuff), but I prefer to make things like that expliict, and
> have source code that matches the code generation.
>
> (Which is also why I do *not* endorse passing bigger structs by value,
> because then the compiler will just pass it as a "pointer to a copy"
> instead, again violating the whole concept of "source matches what
> happens in reality")
>
> I think the above helper could be improved further with Al's
> suggestion to make 'fd_publish()' return an error code, and allow the
> file pointer (and maybe even the fd index) to be an error pointer (and
> error number), so that you could often unify the error/success paths.
>
> IOW, I like this, and I think it's superior to my stupid original suggestion.
We'd better collect the data on the current callers first. There are
several patterns; I'm going through the old (fairly sparse) notes and
the grep over the current tree right now, will post when I get through
that.
That's one area where we had a *lot* of recurring bugs - mostly of
leak/double put variety. So we'd better have the calling conventions
right wrt how easy it is to fuck up in failure exits. And we need
to document the patterns/rules for each/reasons for choosing one over
another.
Note that there's also "set the file up, then get descriptor and either
fd_install or fput, depending on get_unused_fd_flags() success";
sometimes it's the only approach (SCM_RIGHTS, for example), sometimes
it's better than "get descriptor, set the file up, then either install
or release descriptor", sometimes it's definitely worse (e.g. for
O_CREAT it's a non-starter). It should be a deliberate choice.
next prev parent reply other threads:[~2023-04-25 17:19 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 13:41 [GIT PULL] pidfd updates Christian Brauner
2023-04-24 20:24 ` Linus Torvalds
2023-04-24 20:35 ` Linus Torvalds
2023-04-25 12:08 ` Christian Brauner
2023-04-25 6:04 ` Al Viro
2023-04-25 12:34 ` Christian Brauner
2023-04-25 13:54 ` Al Viro
2023-04-25 14:36 ` Christian Brauner
2023-04-25 15:48 ` Al Viro
2023-04-25 16:28 ` Linus Torvalds
2023-04-25 17:19 ` Al Viro [this message]
2023-04-28 8:40 ` David Laight
2023-04-28 18:26 ` Linus Torvalds
2023-04-27 1:07 ` Al Viro
2023-04-27 7:39 ` Al Viro
2023-04-27 8:33 ` Christian Brauner
2023-04-27 8:59 ` Al Viro
2023-04-27 9:40 ` Christian Brauner
2023-04-27 15:21 ` Linus Torvalds
2023-04-27 17:02 ` Al Viro
2023-05-02 7:11 ` Christian Brauner
2023-04-27 8:11 ` Christian Brauner
2023-04-24 21:45 ` pr-tracker-bot
-- strict thread matches above, loose matches on Subject: below --
2021-11-10 14:52 Christian Brauner
2021-11-11 0:25 ` pr-tracker-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230425171913.GT3390869@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.