Bug 255947 - linuxulator: Add FUTEX_REQUEUE for musl libc.
Summary: linuxulator: Add FUTEX_REQUEUE for musl libc.
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: Dmitry Chagin
URL:
Keywords:
Depends on:
Blocks: 247219
  Show dependency treegraph
 
Reported: 2021-05-17 15:13 UTC by pitwuu
Modified: 2022-06-17 19:42 UTC (History)
2 users (show)

See Also:


Attachments
futex requeue patch (2.67 KB, patch)
2021-05-17 15:13 UTC, pitwuu
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description pitwuu 2021-05-17 15:13:24 UTC
Created attachment 225031 [details]
futex requeue patch

The comment about FUTEX_REQUEUE is true, however musl libc makes uses of this operation, and so I want to add support for it as there is legitimate use of FUTEX_REQUEUE.

The call itself is per the documentation the same as FUTEX_CMD_REQUEUE except that the val3 is not checked.

Tested on void linux chroot with x64.
With this patch, Qt applications enter and exit cleanly.
Comment 1 pitwuu 2021-05-17 15:14:08 UTC
In my TODO list is to move patches to the Phabricator, including this issue here.
Comment 2 Ed Maste freebsd_committer freebsd_triage 2021-05-17 15:29:31 UTC
Comment on attachment 225031 [details]
futex requeue patch

Moved comment likely requires updating:

+		 * Glibc versions prior to 2.3.3 fall back to FUTEX_WAKE when
+		 * FUTEX_REQUEUE returned EINVAL.

This is true, but not so relevant now as we're not going to return EINVAL?
Comment 3 pitwuu 2021-05-17 16:12:10 UTC
Should I then get rid of all these comments, and the warning flag "LINUX_XDEPR_REQUEUEOP" as well?
Comment 4 Dmitry Chagin freebsd_committer freebsd_triage 2021-05-18 06:23:03 UTC
In my POV this should be fixed in musl instead of using the broken feature,
or, at least, you can add flag to the brandinfo and check it.
Comment 5 pitwuu 2021-05-18 14:15:50 UTC
https://reviews.freebsd.org/D30332
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-07-20 11:41:43 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cf8d74e3fe63da7359d6ca7e0b4b57c5684c2845

commit cf8d74e3fe63da7359d6ca7e0b4b57c5684c2845
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2021-07-20 11:39:20 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2021-07-20 11:39:20 +0000

    linux(4): Allow musl brand to use FUTEX_REQUEUE op.

    Initial patch from submitter was adapted by me to prevent unconditional
    FUTEX_REQUEUE use.

    PR:                     255947
    Submitted by:           Philippe Michaud-Boudreault
    Differential Revision:  https://reviews.freebsd.org/D30332

 sys/amd64/linux/linux_sysvec.c     |  3 ++-
 sys/amd64/linux32/linux32_sysvec.c |  3 ++-
 sys/compat/linux/linux.h           |  5 ++++
 sys/compat/linux/linux_futex.c     | 49 +++++++++++++++++++++++++-------------
 sys/i386/linux/linux_sysvec.c      |  3 ++-
 5 files changed, 43 insertions(+), 20 deletions(-)
Comment 7 Dmitry Chagin freebsd_committer freebsd_triage 2022-03-25 10:19:26 UTC
I don't plan to MFC this
Comment 8 commit-hook freebsd_committer freebsd_triage 2022-06-17 19:42:13 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6698c1a28d09b58fbb0921ec727b9917fd5d2b7a

commit 6698c1a28d09b58fbb0921ec727b9917fd5d2b7a
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2021-07-20 11:39:20 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:33:12 +0000

    linux(4): Allow musl brand to use FUTEX_REQUEUE op.

    Initial patch from submitter was adapted by me to prevent unconditional
    FUTEX_REQUEUE use.

    PR:                     255947
    Submitted by:           Philippe Michaud-Boudreault
    Differential Revision:  https://reviews.freebsd.org/D30332

    (cherry picked from commit cf8d74e3fe63da7359d6ca7e0b4b57c5684c2845)

 sys/amd64/linux/linux_sysvec.c     |  3 ++-
 sys/amd64/linux32/linux32_sysvec.c |  3 ++-
 sys/compat/linux/linux.h           |  5 ++++
 sys/compat/linux/linux_futex.c     | 49 +++++++++++++++++++++++++-------------
 sys/i386/linux/linux_sysvec.c      |  3 ++-
 5 files changed, 43 insertions(+), 20 deletions(-)