Bug 293867 - net/ucx: fix FreeBSD runtime issues blocking UCX-backed MPI paths
Summary: net/ucx: fix FreeBSD runtime issues blocking UCX-backed MPI paths
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Vladimir Druzenko
URL:
Keywords:
Depends on:
Blocks: 293793
  Show dependency treegraph
 
Reported: 2026-03-17 01:41 UTC by Generic Rikka
Modified: 2026-04-08 23:06 UTC (History)
3 users (show)

See Also:
rikka.goering: maintainer-feedback+
vvd: merge-quarterly+


Attachments
0001 net/ucx: fix FreeBSD runtime portability issues (11.15 KB, patch)
2026-03-17 01:41 UTC, Generic Rikka
rikka.goering: maintainer-approval+
Details | Diff
0002 net/ucx: harden async thread state handling (3.11 KB, patch)
2026-03-17 01:42 UTC, Generic Rikka
rikka.goering: maintainer-approval+
Details | Diff
0003 net/ucx: fix FreeBSD UCM relocation handling (2.58 KB, patch)
2026-03-17 01:43 UTC, Generic Rikka
rikka.goering: maintainer-approval+
Details | Diff
0004 net/ucx: fix mm signal socket binding on FreeBSD (3.93 KB, patch)
2026-03-17 01:44 UTC, Generic Rikka
rikka.goering: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Generic Rikka 2026-03-17 01:41:35 UTC
Created attachment 268870 [details]
0001 net/ucx: fix FreeBSD runtime portability issues

I am attaching a patch series for net/ucx that fixes several FreeBSD-specific
runtime issues found while testing UCX integration with net/openmpi.

The series is split into four logical changes:

1) fix FreeBSD runtime portability issues
   - replace Linux-specific interface discovery and sysfs assumptions
   - avoid Linux-only IPOIB / bridge detection paths
   - add FreeBSD fallbacks for memory remapping and affinity helpers
   - improve pthread_create() error reporting

2) harden async thread state handling
   - avoid dereferencing the global async thread context when startup or
     teardown did not complete successfully

3) fix FreeBSD UCM relocation handling
   - rebase dynamic-section pointers obtained through dl_iterate_phdr()
     by dlpi_addr before dereference on FreeBSD
   - fix PT_LOAD end range calculation when tracking the object address span

4) fix mm signal socket binding on FreeBSD
   - replace Linux autobind assumptions for AF_UNIX sockets in the mm
     signaling path with explicit pathname binding and cleanup

These changes were developed while investigating why OpenMPI built with UCX
support exposed the UCX components correctly but still failed at runtime on
FreeBSD.

Current status after applying the series:

- UCX smoke tests and reduced standalone UCP / worker tests now succeed on FreeBSD
- OpenMPI no longer fails in the earlier UCM relocation path
- the plain OpenMPI path works with:
    PMIX_MCA_gds=hash
    OMPI_MCA_pml=ob1
    OMPI_MCA_osc=sm
    OMPI_MCA_btl=self,tcp

However, the UCX-backed OpenMPI path still does not initialize successfully and
currently fails during PML UCX component initialization after the UCX context
has already been created successfully. So this series improves and unblocks the
UCX runtime substantially, but does not yet make the OpenMPI UCX path fully
usable on FreeBSD.
Comment 1 Generic Rikka 2026-03-17 01:42:10 UTC
Created attachment 268871 [details]
0002 net/ucx: harden async thread state handling
Comment 2 Generic Rikka 2026-03-17 01:43:28 UTC
Created attachment 268872 [details]
0003 net/ucx: fix FreeBSD UCM relocation handling
Comment 3 Generic Rikka 2026-03-17 01:44:06 UTC
Created attachment 268873 [details]
0004 net/ucx: fix mm signal socket binding on FreeBSD
Comment 4 Vladimir Druzenko freebsd_committer freebsd_triage 2026-04-08 21:55:33 UTC
Please report patches to upstream: https://github.com/openucx/ucx/issues
Comment 5 commit-hook freebsd_committer freebsd_triage 2026-04-08 22:43:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=1ef58f980f422e30804818df7dadd3c1da3dace0

commit 1ef58f980f422e30804818df7dadd3c1da3dace0
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2026-04-08 22:13:37 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-04-08 22:42:18 +0000

    net/ucx: Harden async thread state handling

    Avoid dereferencing the global async thread context when startup or
    teardown did not complete successfully by returning UCS_ERR_NO_ELEM for
    operations that require an active thread and by only publishing thread_p
    on successful start.

    This prevents invalid access paths during async thread error handling.

    PR:             293867
    Sponsored by:   UNIS Labs
    MFH:            2026Q2

 net/ucx/files/patch-src_ucs_async_thread.c (new) | 61 ++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
Comment 6 commit-hook freebsd_committer freebsd_triage 2026-04-08 22:43:07 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=db6d744b60348636c7a87c3c7fc181afd9b71994

commit db6d744b60348636c7a87c3c7fc181afd9b71994
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2026-04-08 22:37:32 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-04-08 22:42:19 +0000

    net/ucx: Fix mm signal socket binding on FreeBSD

    Replace Linux-style UNIX domain socket autobind logic in the mm
    signaling path with explicit pathname-based binding on FreeBSD and
    remove the socket path during cleanup.

    This fixes FreeBSD runtime failures in the mm shared-memory signaling
    path.

    PR:             293867
    Sponsored by:   UNIS Labs
    MFH:            2026Q2

    : Update  =>

    Changelog:

    PR:
    Sponsored by:   UNIS Labs

 net/ucx/Makefile                                   |  1 +
 .../patch-src_uct_sm_mm_base_mm__iface.c (new)     | 87 ++++++++++++++++++++++
 2 files changed, 88 insertions(+)
Comment 7 commit-hook freebsd_committer freebsd_triage 2026-04-08 22:43:08 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=94fc6d9ffebbad5014a7f48ba925b9a39df8478f

commit 94fc6d9ffebbad5014a7f48ba925b9a39df8478f
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2026-04-08 22:25:29 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-04-08 22:42:19 +0000

    net/ucx: Fix FreeBSD UCM relocation handling

    On FreeBSD, dynamic-section pointers observed through dl_iterate_phdr()
    for shared objects need to be rebased by dlpi_addr before dereference.

    Also fix the PT_LOAD end range calculation to include the object base
    address when tracking the library address span.

    This fixes runtime failures in UCM relocation patching on FreeBSD.

    PR:             293867
    Sponsored by:   UNIS Labs
    MFH:            2026Q2

 net/ucx/files/patch-src_ucm_util_reloc.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2026-04-08 22:43:09 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=601e614318cdfbb381bcb7a9841353720feb53a9

commit 601e614318cdfbb381bcb7a9841353720feb53a9
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2026-04-08 22:07:05 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-04-08 22:42:18 +0000

    net/ucx: Fix FreeBSD runtime portability issues

    Adjust several Linux-specific runtime assumptions in UCX for FreeBSD:
    - use FreeBSD-specific network interface handling where Linux sysfs logic
      is not available
    - avoid Linux-only IPOIB and bridge detection paths
    - improve pthread_create() error reporting
    - provide FreeBSD fallbacks for memory remapping and affinity helpers

    This fixes multiple runtime failures and device discovery issues on FreeBSD.

    PR:             293867
    Sponsored by:   UNIS Labs
    MFH:            2026Q2

 net/ucx/files/patch-src_ucs_sys_sys.c              |  39 +++--
 net/ucx/files/patch-src_uct_tcp_tcp__iface.c (new) | 173 +++++++++++++++++++++
 2 files changed, 198 insertions(+), 14 deletions(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2026-04-08 23:01:11 UTC
A commit in branch 2026Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=31837ba56b55c5d345fa69e5c0a0adbed7fe3733

commit 31837ba56b55c5d345fa69e5c0a0adbed7fe3733
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2026-04-08 22:25:29 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-04-08 22:58:00 +0000

    net/ucx: Fix FreeBSD UCM relocation handling

    On FreeBSD, dynamic-section pointers observed through dl_iterate_phdr()
    for shared objects need to be rebased by dlpi_addr before dereference.

    Also fix the PT_LOAD end range calculation to include the object base
    address when tracking the library address span.

    This fixes runtime failures in UCM relocation patching on FreeBSD.

    PR:             293867
    Sponsored by:   UNIS Labs
    MFH:            2026Q2

    (cherry picked from commit 94fc6d9ffebbad5014a7f48ba925b9a39df8478f)

 net/ucx/files/patch-src_ucm_util_reloc.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2026-04-08 23:01:13 UTC
A commit in branch 2026Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=98b8e23c53c401419a07c970b09cd2a778b0313f

commit 98b8e23c53c401419a07c970b09cd2a778b0313f
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2026-04-08 22:13:37 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-04-08 22:57:47 +0000

    net/ucx: Harden async thread state handling

    Avoid dereferencing the global async thread context when startup or
    teardown did not complete successfully by returning UCS_ERR_NO_ELEM for
    operations that require an active thread and by only publishing thread_p
    on successful start.

    This prevents invalid access paths during async thread error handling.

    PR:             293867
    Sponsored by:   UNIS Labs
    MFH:            2026Q2

    (cherry picked from commit 1ef58f980f422e30804818df7dadd3c1da3dace0)

 net/ucx/files/patch-src_ucs_async_thread.c (new) | 61 ++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
Comment 11 commit-hook freebsd_committer freebsd_triage 2026-04-08 23:01:14 UTC
A commit in branch 2026Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ee300a7d3d95ed48ef27aae93516eebee75b960d

commit ee300a7d3d95ed48ef27aae93516eebee75b960d
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2026-04-08 22:07:05 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-04-08 22:57:26 +0000

    net/ucx: Fix FreeBSD runtime portability issues

    Adjust several Linux-specific runtime assumptions in UCX for FreeBSD:
    - use FreeBSD-specific network interface handling where Linux sysfs logic
      is not available
    - avoid Linux-only IPOIB and bridge detection paths
    - improve pthread_create() error reporting
    - provide FreeBSD fallbacks for memory remapping and affinity helpers

    This fixes multiple runtime failures and device discovery issues on FreeBSD.

    PR:             293867
    Sponsored by:   UNIS Labs
    MFH:            2026Q2

    (cherry picked from commit 601e614318cdfbb381bcb7a9841353720feb53a9)

 net/ucx/files/patch-src_ucs_sys_sys.c              |  39 +++--
 net/ucx/files/patch-src_uct_tcp_tcp__iface.c (new) | 173 +++++++++++++++++++++
 2 files changed, 198 insertions(+), 14 deletions(-)
Comment 12 commit-hook freebsd_committer freebsd_triage 2026-04-08 23:01:15 UTC
A commit in branch 2026Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d03645e79307c413c6183662d971b5aa9b5991ef

commit d03645e79307c413c6183662d971b5aa9b5991ef
Author:     Generic Rikka <rikka.goering@outlook.de>
AuthorDate: 2026-04-08 22:37:32 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-04-08 23:00:25 +0000

    net/ucx: Fix mm signal socket binding on FreeBSD

    Replace Linux-style UNIX domain socket autobind logic in the mm
    signaling path with explicit pathname-based binding on FreeBSD and
    remove the socket path during cleanup.

    This fixes FreeBSD runtime failures in the mm shared-memory signaling
    path.

    PR:             293867
    Sponsored by:   UNIS Labs
    MFH:            2026Q2

    (cherry picked from commit db6d744b60348636c7a87c3c7fc181afd9b71994)

 net/ucx/Makefile                                   |  1 +
 .../patch-src_uct_sm_mm_base_mm__iface.c (new)     | 87 ++++++++++++++++++++++
 2 files changed, 88 insertions(+)
Comment 13 Vladimir Druzenko freebsd_committer freebsd_triage 2026-04-08 23:06:01 UTC
Thanks.