On Tue, Feb 4, 2025 at 2:01 AM Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx> wrote: > > On Tue, Feb 04, 2025 at 10:46:35AM +0100, Christian Brauner wrote: > > On Thu, 30 Jan 2025 20:40:25 +0000, Lorenzo Stoakes wrote: > > > If you wish to utilise a pidfd interface to refer to the current process or > > > thread it is rather cumbersome, requiring something like: > > > > > > int pidfd = pidfd_open(getpid(), 0 or PIDFD_THREAD); > > > > > > ... > > > > > > [...] > > > > Updated merge message. I've slightly rearranged pidfd_send_signal() so > > we don't have to call CLASS(fd, f)(pidfd) unconditionally anymore. > > Sounds good and thank you! Glad to get this in :) Sorry, a bit late to the party... We were discussing MADV_GUARD_INSTALL use with Android Bionic team and the possibility of caching pidfd_open() result for reuse when installing multiple guards, however doing that in libraries would pose issues as we can't predict the user behavior, which can fork() in between such calls. That would be an additional reason why having these sentinels is beneficial. > > > > > --- > > > > Applied to the vfs-6.15.pidfs branch of the vfs/vfs.git tree. > > Patches in the vfs-6.15.pidfs branch should appear in linux-next soon. > > > > Please report any outstanding bugs that were missed during review in a > > new review to the original patch series allowing us to drop it. > > > > It's encouraged to provide Acked-bys and Reviewed-bys even though the > > patch has now been applied. If possible patch trailers will be updated. > > > > Note that commit hashes shown below are subject to change due to rebase, > > trailer updates or similar. If in doubt, please check the listed branch. > > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git > > branch: vfs-6.15.pidfs > > > > [1/6] pidfd: add PIDFD_SELF* sentinels to refer to own thread/process > > https://git.kernel.org/vfs/vfs/c/e6e4ed42f8d8 > > [2/6] selftests/pidfd: add missing system header imcludes to pidfd tests > > https://git.kernel.org/vfs/vfs/c/c9f04f4a251d > > [3/6] tools: testing: separate out wait_for_pid() into helper header > > https://git.kernel.org/vfs/vfs/c/fb67fe44116e > > [4/6] selftests: pidfd: add pidfd.h UAPI wrapper > > https://git.kernel.org/vfs/vfs/c/ac331e56724d > > [5/6] selftests: pidfd: add tests for PIDFD_SELF_* > > https://git.kernel.org/vfs/vfs/c/881a3515c191 > > [6/6] selftests/mm: use PIDFD_SELF in guard pages test > > https://git.kernel.org/vfs/vfs/c/b4703f056f42