Skip to content

UCT/TCP: Query netif capabilities once per iface - #12201

Merged
tvegas1 merged 1 commit into
openucx:masterfrom
bwestheimer:bwestheimer/tcp-caps-once
Nov 3, 2026
Merged

tvegas1 merged 1 commit into
openucx:masterfrom
bwestheimer:bwestheimer/tcp-caps-once

Conversation

@bwestheimer

Copy link
Copy Markdown
Contributor

What?

Compute the tcp iface netif capabilities (latency, bandwidth, priority) once in the iface constructor and return the stored values from uct_tcp_iface_query().

Why?

uct_tcp_iface_query() ran uct_tcp_netif_caps() (SIOCETHTOOL, SIOCGIFHWADDR, SIOCGIFMTU, one socket each), a sysfs walk for the PCI bandwidth and a /proc/net/route scan on every call, and UCP queries an iface far more often than once: uct_iface_set_am_handler() and uct_base_iface_estimate_perf() both call uct_iface_query(). Per tcp iface per ucp_worker_create that is 15 queries (1 open, 1 port_speed, 13 AM handler ids) plus 13 at ucp_worker_destroy, and about 66 more estimate_perf calls on the first send. SIOCETHTOOL takes rtnl_lock and on IPoIB reaches the HCA port query, so with many netdevs and many processes or threads per node worker creation serializes node-wide.

Measured:

  • test/apps/test_init_mt with 72 OpenMP threads on a GH200 node with 12 netdevs (4 IPoIB, one USB NIC): 12.1 s per iteration -> 2.35 s (UCX_TLS=^tcp control: 2.0 s). SIOCETHTOOL per run 12960 -> 432. (Internal CI hit the 1 min per-iteration timeout on this test.)
  • MPI_Init at 72 ranks per node with UCX_TLS=all on the same node: 7.3 s -> 1.7 s.
  • ucx_info -u t -w on a host with 2 tcp devices: 56 -> 2 SIOCETHTOOL.

How?

New uct_tcp_iface_init_netif_caps() runs after the netdev address lookup succeeded, stores the three values in iface->config, and replaces the stored prefer_default and max_bw (the explicit MAX_BW cap is applied once at init). This follows the IB transport, whose iface_query reads port attributes cached at device open. tcp iface attributes are therefore static after open: link speed or default route changes after open are not reflected, and the UCP handler for the IB port speed change event keeps the open-time bandwidth for a tcp iface that shares the device with the IB port.

Why not cache in uct_iface_set_am_handler(): the expensive work is tcp-specific and is reached from three base-layer callers (set_am_handler, estimate_perf, port_speed), so a cache at one caller would be both broader (all transports) and incomplete.

Tests: no unprivileged gtest can observe the change (two consecutive queries return equal values before and after), so coverage is the existing tcp/test_uct_tcp.* and UCP-over-tcp gtests (all pass, also under valgrind and with UCX_TCP_PREFER_DEFAULT=y / UCX_TCP_MAX_BW set), and ucx_info -d -t tcp is byte-identical before and after. On a GH200 node with IB and real netdevs the *tcp* gtests pass except tcp/test_ucp_loopback.envelope/28 <tcp/put_bw>, which times out identically on master.

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

@bwestheimer

Copy link
Copy Markdown
Contributor Author

@yosefe @tvegas1 @gleon99 could you take a look? Fixes the multi-threaded / high-ppn worker create slowdown reported internally on Grace and x86 nodes with many netdevs (Leonid has the ticket). Small change, tcp only.

@svc-ucx

svc-ucx commented Oct 29, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Codestyle AUTHORS file update check) · commit 204b6e27

TL;DR: This isn't a code bug — the "AUTHORS file update check" failed because PR #12201's author (Bryce Westheimer) is a new contributor who is not listed in the AUTHORS file; running ./contrib/authors_update.sh and committing the resulting one-line AUTHORS change fixes it.

Full analysis

Summary: The AUTHORS file check bash step in Azure build 141685 exited with code 1 because git diff --exit-code found an uncommitted modification to AUTHORS after contrib/authors_update.sh ran.

Root cause: The pipeline step computes the PR commit range (62182080...204b6e27) and runs ./contrib/authors_update.sh, which scans commit author names/emails and appends any that are missing from AUTHORS. The script reported ++ Bryce Westheimer <bwestheimer@nvidia.com> (log line "Names:" followed by ++ ...), i.e. neither that email nor name matched an existing AUTHORS entry (contrib/authors_update.sh:36). It then rewrote the file, and the subsequent git diff --exit-code detected the pending diff adding Bryce Westheimer <bwestheimer@nvidia.com> between Brad Benton (AUTHORS:23) and Changcheng Liu (AUTHORS:24), so the gate failed. This is the check's intended behavior for a first-time contributor, not a regression from the TCP caps change in this PR.

Implicated commit: [REDACTED:Hex High Entropy String] (Bryce Westheimer) — the PR head commit; no implicated commit in CI infrastructure.

File: AUTHORS:23-24 (insertion point); check logic at contrib/authors_update.sh:36-46

Suggested fix: In the PR branch bwestheimer/tcp-caps-once, add the author entry to AUTHORS and amend/commit it:

./contrib/authors_update.sh origin/master..HEAD
git add AUTHORS && git commit -m "AUTHORS: add Bryce Westheimer"

Equivalently, manually insert Bryce Westheimer <bwestheimer@nvidia.com> after Brad Benton <bradford.benton@gmail.com> (keeping LC_COLLATE=C sort order). Also verify the commit's author email matches exactly, so the grep -iqw "$email" check in contrib/authors_update.sh passes on re-run. No pipeline or timeout changes are needed.

Related: PR #12201 (openucx/ucx) — no existing issue found for this failure signature.

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id cb42b4dc-ddce-4ee8-b3b7-5760f81655cc in the triage console for the audit trail.

Comment thread src/uct/tcp/tcp.h Outdated
ucs_time_t user_timeout; /* TCP_USER_TIMEOUT */
double max_bw; /* Upper bound to TCP iface bandwidth */
double latency; /* Netdev latency */
double bandwidth; /* Netdev bandwidth */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: the comment is inaccurate — the cached value is not just the netdev bandwidth, it is the min of netdev BW, PCI BW and UCX_TCP_MAX_BW.

Suggested change
double bandwidth; /* Netdev bandwidth */
double bandwidth; /* Netdev BW, bounded by PCI BW and MAX_BW */

@bwestheimer bwestheimer Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/uct/tcp/tcp_iface.c Outdated
goto err_cleanup_rx_mpool;
}

status = uct_tcp_iface_init_netif_caps(self, config);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placement of the new call: maybe we can call this next to the other self->config assignments (before the mpool init)? It only needs if_name and config, and then the failure path does not have to unwind the mpools.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: moved before the mpool init, failure path is now a plain goto err.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual gap: device latency/bandwidth and default-route priority are now sampled once at iface open instead of on every query, so a link-speed or default-route change after open is no longer picked up. UCP queries iface attrs once per iface, so the practical impact looks negligible — worth confirming the PR description mentions this behavior change.

@bwestheimer
bwestheimer force-pushed the bwestheimer/tcp-caps-once branch from 204b6e2 to 319aeba Compare October 29, 2026 23:07
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

@bwestheimer

Copy link
Copy Markdown
Contributor Author

Re the residual gap: yes, intended and described in the How section (attributes static after open; the one runtime consumer is the UCP IB port-speed-change handler, which now keeps the open-time bandwidth for a tcp iface sharing the device). This follows the IB iface_query, which also reads port attributes cached at device open.

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Review complete — no issues found.

@svc-ucx

svc-ucx commented Oct 30, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Tests new on worker 3) · commit 319aeba3

TL;DR: The gtest step failed with a single non-fatal failure — tcp/test_ucp_rma.put_nonblocking/2 <tcp,cuda_copy,rocm_copy/user_memh> — i.e. a PUT data-validation mismatch in the 2-RMA-lane TCP path, not a crash, hang or timeout; the PR itself only caches TCP netif attributes (latency/bandwidth/priority), so the first action is to prove those attributes are byte-identical to pre-PR values (ucx_info -d -t tcp) and re-run, since otherwise this is a pre-existing multi-lane put/user-memh bug from master.

Full analysis

Summary: Azure job "new on worker 3" → step Run ./contrib/test_jenkins.sh → make test in build-test/test/gtest returned Error 1: 8851 tests ran, 8850 passed, [ FAILED ] tcp/test_ucp_rma.put_nonblocking/2, where GetParam() = tcp,cuda_copy,rocm_copy/user_memh.

Root cause: From the log, the failure is a non-fatal gtest failure (the run continued to completion through all remaining suites and the tear-down, no SIGSEGV/abort, no timeout, no large timestamp gaps — the longest waits in the log are legitimate stress_connect*/recv_align tests at 30–54 s). The only non-fatal failure path in that test is ADD_FAILURE() << "data validation failed" in test/gtest/ucp/test_ucp_memheap.cc:115, reached after flush_worker()/flush_ep() — i.e. the target buffer contents did not match the sent pattern for a host→host ucp_put_nbx with a user-supplied memh (UCP_OP_ATTR_FIELD_MEMH, variant user_memh), with MAX_RMA_LANES=2 (test/gtest/ucp/test_ucp_rma.cc:39) so the put is split across two TCP lanes. The exact per-size assertion line is not recoverable: the Azure log is served truncated to the last ~500 lines and the failure occurred earlier in this ~51-minute gtest run.
The PR under test (319aeba3) does not touch any send/receive path — it only moves uct_tcp_netif_caps(), the PCI-BW/MAX_BW clamp and the default-netif priority computation out of uct_tcp_iface_query() into the new uct_tcp_iface_init_netif_caps() run once at iface construction. The only way it can influence this test is indirectly, via the latency/bandwidth.shared/priority values that drive UCP device and RMA-lane selection for the 2-lane split. So either (a) the cached values differ from the previously per-query computed ones and a different lane pair/split is now chosen, or (b) the failure is pre-existing on master — the prime candidate being 4af0b6b5 "UCP: Split an SGL put between the lanes by bytes (#11947)", merged 2026-10-29T16:38, i.e. included in the refs/pull/12201/merge commit this build tested.

Implicated commit: 319aeba3 (Bryce Westheimer, "UCT/TCP: Query netif capabilities once per iface") is the change under test; master candidate for the actual put regression is 4af0b6b5 (Michal Shalev, #11947).

File: src/uct/tcp/tcp_iface.c:665-711 (new uct_tcp_iface_init_netif_caps, called at src/uct/tcp/tcp_iface.c:820); failing assertion in test/gtest/ucp/test_ucp_memheap.cc:115 via test/gtest/ucp/test_ucp_rma.cc:283.

Suggested fix:

  1. Prove attribute equivalence: run ucx_info -d -t tcp (and UCX_LOG_LEVEL=debug ucx_info -e -u r) on the branch and on its merge-base and diff latency, bandwidth, priority for every netif. The cached path must reproduce exactly what uct_tcp_iface_query() returned before, including the ucs_min(pci_bw, network_bw) and MAX_BW clamp order at tcp_iface.c:688-695. Any difference changes RMA lane selection and must be corrected in the PR.
  2. Tighten the new helper while you are there: uct_tcp_iface_init_netif_caps() returns the stale status from ucs_string_alloc_path_buffer() when prefer_default=n (tcp_iface.c:697-710) — set status = UCS_OK explicitly before out_free_path_buffer so the success path is not accidental.
  3. Reproduce the test failure directly to decide attribution, e.g. ./gtest --gtest_filter='tcp/test_ucp_rma.put_nonblocking/2' --gtest_repeat=20 with UCX_MAX_RMA_LANES=2 UCX_TLS=tcp on the branch and on plain master. If it fails on master too, re-target the bug to the multi-lane put byte-split (UCP: Split an SGL put between the lanes by bytes #11947) / user-memh handling and just re-run this PR's CI.
  4. For future triage: have the CI publish the gtest output as an artifact (or --gtest_output=xml), since the Azure console log is truncated and the actual failure text for a mid-run failure is unrecoverable.

Related: PR #12201 (this change); #11947 / commit 4af0b6b5 "UCP: Split an SGL put between the lanes by bytes"; #12191 "UCP/RMA: Add SGL support to ucp_get_nbx" (same area, open).

@bwestheimer

Copy link
Copy Markdown
Contributor Author

Re the red leg (Tests new on worker 3: tcp/test_ucp_rma.put_nonblocking/2, "data validation failed" then tcp_ep recv failed: Input/output error): pre-existing on master. The same test and signature failed on #12162 (build 141265, 2026-10-28, variant /2) and #12180 (build 140878, 2026-10-27, variant /0); neither touches tcp.

On the triage points: ucx_info -d tcp output is byte-identical between this branch and its base (0 diff lines on a 6-netif Grace node and locally), so lane selection is unchanged. tcp/test_ucp_rma.put_nonblocking/2 <user_memh> passes on this branch on that node (full *tcp* gtest run, 4656/4656) and 20 repeats with UCX_TLS=tcp UCX_MAX_RMA_LANES=2 pass locally. Re-running.

/azp run UCX PR

@bwestheimer
bwestheimer force-pushed the bwestheimer/tcp-caps-once branch from 319aeba to e964bb8 Compare October 30, 2026 14:57
@bwestheimer

Copy link
Copy Markdown
Contributor Author

Pushed e964bb8: rebased on master and set status = UCS_OK explicitly on the PREFER_DEFAULT=n path (triage point 2). Same return value as before; no behavior change. CI re-triggered by the push.

@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/uct/tcp/tcp_iface.c Outdated

iface->config.priority = is_default ? 0 : 1;
} else {
iface->config.priority = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: status is already UCS_OK here.

Suggested change
iface->config.priority = 0;
iface->config.priority = 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it is already UCS_OK; the explicit assignment was added for the CI triage comment above (point 2), so the success return of this branch does not depend on the earlier path-buffer call. Either form is fine with me; I will follow the reviewers' preference.

@svc-ucx

svc-ucx commented Oct 30, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Tests new on worker 0) · commit e964bb87

TL;DR: The gtest binary aborted on a debug assertion in uct_rc_mlx5_common_post_send() (!(txwq->flags & UCT_IB_MLX5_TXWQ_FLAG_FAILED)) during dcx/test_ucp_fault_tolerance.initiator_failure/11 <dc_x/PUT|AM|FLUSH> — UCP declared the injected-failure DC lane "recovered" while the underlying shared DCI txwq was still flagged FAILED, so the post-recovery AM zcopy posted a non-NOP WQE on a failed work queue. This is a UCP failover/DC bug unrelated to this TCP-only PR; the fix is to clear/reset (or release and re-acquire) the DCI txwq FAILED state when a DC lane is recovered.

Full analysis

Summary: Tests new on worker 0 (Azure build 141763) failed with make: *** [Makefile:4971: test] Aborted (core dumped) after an assertion failure in dcx/test_ucp_fault_tolerance.initiator_failure/11 <dc_x/PUT|AM|FLUSH>.

Root cause: Log sequence (15:57:43–15:57:44) shows the test invalidate lane 0/2 of the DC endpoint (uct_ep_invalidate), the post-failure PUT|AM|FLUSH operation succeeding ("Success"), then test_recovery() waiting until ucp_ep_get_failed_lanes() == 0 ("Checking recovery status..."). Immediately after recovery was declared, do_am_send_and_wait() → ucp_am_send_nbx → ucp_am_eager_multi_zcopy_psn_send_func → uct_dc_mlx5_ep_am_zcopy → uct_dc_mlx5_iface_zcopy_post → uct_rc_mlx5_common_post_send tripped:

rc_mlx5.inl:615  Assertion `!(txwq->flags & UCT_IB_MLX5_TXWQ_FLAG_FAILED)' failed

src/uct/ib/mlx5/rc/rc_mlx5.inl:612-616 only permits MLX5_OPCODE_NOP (flush) WQEs on a txwq marked UCT_IB_MLX5_TXWQ_FLAG_FAILED. So the UCP-level failover bookkeeping cleared UCP_LANE_TYPE_FAILED / failed-lane mask and rebuilt the lane, but the DC endpoint ended up sending on a DCI whose txwq still carried the FAILED flag — i.e. the UCT-level failed state of the shared DCI is not reset (or the DCI not released/re-allocated) as part of DC lane recovery. The debug build turns this state mismatch into an abort.

This is in the UCP fault-tolerance/DC path only. The PR under test (#12201, branch bwestheimer/tcp-caps-once, TCP capability query) touches no IB/DC or failover code, so the failure is not caused by the PR — it is a (likely intermittent) bug in the recently landed failover work.

Implicated commit: unknown for the exact regression; most plausible candidates in the failover/DC-recovery area are 40d8c4a6 "UCP/FT: Purge an unaware lane before rebuilding its address (#12048)" (Evgeny Leksikov), d513f98f "UCP/FLUSH: Add topology-safe selective endpoint flush (#11923)" (nbellalou — added the PUT|AM|FLUSH variant exercised here), and [REDACTED:Hex High Entropy String] "UCP/PROTO: Repost GET and zcopy on the selected lane. (#12091)" (Evgeny Leksikov). Not the PR commit e964bb8.

File: src/uct/ib/mlx5/rc/rc_mlx5.inl:615 (assert site); real defect in DC lane recovery — src/uct/ib/mlx5/dc/dc_mlx5_ep.c:101 (uct_dc_mlx5_iface_zcopy_post) posting on a FAILED DCI; test driver test/gtest/ucp/test_ucp_fault_tolerance.cc:603 (test_recovery, AM send after recovery).

Suggested fix:

  1. In the DC recovery path, when a failed lane/DCI is rebuilt, clear UCT_IB_MLX5_TXWQ_FLAG_FAILED as part of the txwq reset (or free the failed DCI back to the pool only after a full reset so it cannot be handed to a recovered endpoint). A recovered uct_dc_mlx5_ep_t must never be bound to a DCI whose txwq is still flagged FAILED.
  2. Until that is fixed, make recovery completion conditional on the UCT ep/DCI actually being usable — ucp_ep_get_failed_lanes() == 0 is currently not sufficient evidence that the UCT resource was reset.
  3. Short term for CI unblocking: re-run the PR (this is unrelated to UCT/TCP: Query netif capabilities once per iface #12201) and consider gating/skipping dcx/test_ucp_fault_tolerance.initiator_failure for the PUT|AM|FLUSH variant on dc_x until the DCI reset is in place — the test file already carries a dc_x limitation comment at test_ucp_fault_tolerance.cc:486.

Related: PR #12201 (the PR being tested, unrelated to the failure); failover work: #12048, #11923, #12091, #12005, #12160 ("UCP/CORE/FT: add recovery enable", open); purge-outstanding work that introduced the NOP-only-on-FAILED rule: #11836, #12062.

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 7d9cbd99-fb81-4bc3-8ae2-6aceb800b63a in the triage console for the audit trail.

Comment thread src/uct/tcp/tcp.h Outdated
* It cannot exceed 255. */
ucs_time_t user_timeout; /* TCP_USER_TIMEOUT */
double max_bw; /* Upper bound to TCP iface bandwidth */
double latency; /* Netdev latency */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep config for the user's settings and cache only what the netdev reports? prefer_default and max_bw would stay in config and iface_query keeps applying them, so the cache holds no configuration (and float.h/DBL_MAX stay as is):

    struct {
        double                    latency;           /* Netdev latency */
        double                    bandwidth;         /* Min of netdev and PCI BW */
        int                       is_default;        /* Netdev has the default route */
    } netif_caps;
    attr->latency.c        = iface->netif_caps.latency;
    /* Bandwidth is bounded by TCP stack computation time */
    attr->bandwidth.shared = ucs_min(iface->netif_caps.bandwidth,
                                     iface->config.max_bw);
    ...
    attr->priority         = (iface->config.prefer_default &&
                              !iface->netif_caps.is_default) ? 1 : 0;

uct_tcp_iface_init_netif_caps() then only needs iface, and can free the path buffer right after ucs_topo_get_pci_bw(), which drops the out_free_path_buffer label.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 833ef05: config keeps prefer_default/max_bw (and float.h/DBL_MAX), new netif_caps {latency, bandwidth, is_default} holds only what the netdev reports, iface_query applies MAX_BW and PREFER_DEFAULT as before, and the helper takes only iface and frees the path buffer right after ucs_topo_get_pci_bw(). ucx_info -d tcp output unchanged; tcp gtests pass with PREFER_DEFAULT=n/y and MAX_BW set.

@bwestheimer
bwestheimer force-pushed the bwestheimer/tcp-caps-once branch from e964bb8 to 833ef05 Compare October 30, 2026 17:00
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/uct/tcp/tcp_iface.c

iface->netif_caps.bandwidth = ucs_min(pci_bw, network_bw);

return uct_tcp_netif_is_default(iface->if_name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uct_tcp_netif_is_default() is now called unconditionally, where before it was only called under if (iface->config.prefer_default). Two consequences: every TCP iface open scans /proc/net/route even when the result is discarded, and if /proc/net/route is unreadable the iface open now fails, whereas previously UCX_TCP_PREFER_DEFAULT=n kept TCP usable. Narrow environment, but it is an avoidable behavior change.

Suggestion:

Suggested change
return uct_tcp_netif_is_default(iface->if_name,
if (!iface->config.prefer_default) {
iface->netif_caps.is_default = 0;
return UCS_OK;
}
return uct_tcp_netif_is_default(iface->if_name,
&iface->netif_caps.is_default);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5570242: with PREFER_DEFAULT=n the route check is skipped and is_default is set to 0, so iface open no longer depends on /proc/net/route in that case.

@bwestheimer
bwestheimer force-pushed the bwestheimer/tcp-caps-once branch from 833ef05 to 5570242 Compare October 30, 2026 17:20
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

Comment thread src/uct/tcp/tcp_iface.c
attr->bandwidth.dedicated = 0;
attr->latency.m = 0;
attr->overhead = 50e-6; /* 50 usec */
attr->priority = (iface->config.prefer_default &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: maybe store the resolved priority in netif_caps instead of is_default? Then query is a plain assignment and prefer_default is not checked in two places — right now is_default == 0 means both "not the default route" and "not checked".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the reviewer's shape: netif_caps holds only what the netdev reports (is_default is the fact, PREFER_DEFAULT is policy applied in the query, as MAX_BW is for bandwidth). With PREFER_DEFAULT=n the flag is never read, so the two meanings of 0 do not reach a consumer.

Comment thread src/uct/tcp/tcp_iface.c Outdated
.ep_outstanding_purge = (uct_ep_outstanding_purge_func_t)ucs_empty_function_return_unsupported
};

static ucs_status_t uct_tcp_iface_init_netif_caps(uct_tcp_iface_t *iface)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: pls rename uct_tcp_iface_init_netif_caps to uct_tcp_iface_netif_caps_init to match the <object>_<verb> naming of the neighboring uct_tcp_iface_listener_init/uct_tcp_iface_server_init.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point on naming. Leaving the head as approved; happy to rename in a follow-up or now if a maintainer prefers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to uct_tcp_iface_netif_caps_init in 803672b.

@svc-nvidia-pr-review

Copy link
Copy Markdown

Residual gap (not blocking): no focused test asserting TCP attr->priority/bandwidth.shared; the values are still produced by the same helpers and exercised by existing test/gtest/uct query/reachability paths, so no new test is deemed necessary — that gap predates this PR.

Behavior change worth making explicit in the PR description (raised in an earlier round): link-speed or default-route changes after iface open are no longer picked up by later queries.

tvegas1
tvegas1 previously approved these changes Oct 30, 2026
@svc-ucx

svc-ucx commented Oct 30, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Tests new on worker 3) · commit 5570242c

TL;DR: The gtest binary aborted on a UCS registration-cache assertion (rcache.c:396 !(region->flags & UCS_RCACHE_REGION_FLAG_PGTABLE)) while ucp_mem_unmap() released the parent rcache region in tcp/test_ucp_rma.put_nonblocking/2 <tcp,cuda_copy,rocm_copy/user_memh> — a UCP memh refcount imbalance (parent region dropped to refcount 0 while still in the page table), which has nothing to do with this PR's TCP netif-caps change; re-run the job and open a bug against UCP/MM rcache refcounting.

Full analysis

Summary: make test (gtest, "Tests new on worker 3") aborted with a core dump on an rcache consistency assertion during tcp/test_ucp_rma.put_nonblocking/2 <tcp,cuda_copy,rocm_copy/user_memh>; Bash exited with code 2.

Root cause: From the log:

[swx-rdmz-ucx-new-01:2299415] rcache.c:396 Assertion `!(region->flags & UCS_RCACHE_REGION_FLAG_PGTABLE)' failed
ucs_mem_region_destroy_internal()  src/ucs/memory/rcache.c:396
ucs_rcache_region_put_unsafe()     src/ucs/memory/rcache.inl:128
ucp_memh_put_rcache()              src/ucp/core/ucp_mm.c:441
ucp_memh_cleanup() / ucp_mem_unmap() src/ucp/core/ucp_mm.c:470,1291
test_ucp_memheap::test_xfer()      test/gtest/ucp/test_ucp_memheap.cc:120

ucp_mem_unmap() of the receiver's memheap handle released its parent rcache region (ucp_memh_put_rcache → ucs_rcache_region_put_unsafe), and the region's refcount reached 0 while the region was still inserted in the rcache page table. A region in the page table is created with refcount = 2 (page-table + user ref, rcache.c:1028), so hitting 0 means the region received one more put than get, or the page-table reference was dropped without clearing UCS_RCACHE_REGION_FLAG_PGTABLE — i.e. a reference-count imbalance in the UCP user-memh/parent-region bookkeeping (ucp_memh_init_uct_reg / ucp_memh_init_from_parent / ucp_memh_cleanup), not a timeout or environment problem. This is a real (likely intermittent) memory-handle refcount bug, and the subsequent 50-second gaps in the log are just the UCX fault handler printing the source context and backtrace, not a hang.

Note on attribution: the backtrace contains no TCP code at all — the PR under test (#12201, UCT/TCP: Query netif capabilities once per iface, commit 5570242, touching only src/uct/tcp/tcp_iface.c) only affects UCT TCP iface capability/bandwidth querying and cannot change UCP rcache refcounts. The tcp/ prefix in the test name is just the transport variant, so this failure is almost certainly pre-existing/flaky rather than caused by the PR.

Implicated commit: Not the PR commit. The most recent change to the implicated file is f3d37492 — "UCP/MM: Apply MAX_HCA_PER_GPU policy to GPU memory types (#12150)", Ankith Averineni, merged 2026-10-29 (one day before this run), which restructured ucp_memh_init_uct_reg() (parent acquisition via ucp_memh_get() and the err_put_rcache path) — a plausible but unconfirmed candidate. PR commit 5570242 (Bryce Westheimer) is not implicated.

File: src/ucs/memory/rcache.c:396 (assertion) / src/ucp/core/ucp_mm.c:441 (ucp_memh_put_rcache), with the acquire side at src/ucp/core/ucp_mm.c:918-973 (ucp_memh_init_uct_reg, ucp_memh_init_from_parent)

Suggested fix:

  1. Re-run the "Tests new on worker 3" job on this PR to confirm it is not reproducible — the change under test cannot affect rcache refcounting.
  2. Open a UCX issue for the real bug and audit the parent-region reference balance in ucp_memh_init_uct_reg(): every successful ucp_memh_get(..., &memh->parent) must be matched by exactly one ucp_memh_put_rcache(parent) in ucp_memh_cleanup(). Two concrete things to check:
    • ucp_memh_init_from_parent() (ucp_mm.c:873) does memh->flags = memh->parent->flags; (assignment, not |=), clobbering the child's flags with the parent's — this can make ucp_memh_cleanup() take the wrong branch (UCP_MEMH_FLAG_IMPORTED / parent handling) and mis-release the region.
    • ucp_memh_get() (ucp_mm.inl:47) returns the shared dummy handle for zero length without taking a reference, while ucp_memh_cleanup() unconditionally calls ucp_memh_put_rcache(memh->parent) when parent != memh — add an explicit guard/assert there.
  3. Strengthen diagnostics: make the rcache.c:396 check an ucs_assertv printing region, start..end, flags, refcount and rcache->name so the next occurrence identifies the offending region immediately.

Related: PR under test: #12201 · most recent change to the implicated file: #12150 · possibly relevant rcache work: #11958 (no existing issue found for this assertion)

@bwestheimer

Copy link
Copy Markdown
Contributor Author

Re the red leg on 5570242 (Tests new on worker 3, rcache assertion !(region->flags & UCS_RCACHE_REGION_FLAG_PGTABLE) in ucp_mem_unmap during tcp/test_ucp_rma.put_nonblocking/2): agreed with the triage above, no tcp code in the backtrace. Same assertion in the same test on three other PR builds since 2026-10-29: #12111 (build 141668), #12180 (141709), #12107 (141739); none of them touch tcp. Pre-existing on master.

uct_tcp_iface_query() ran uct_tcp_netif_caps() (SIOCETHTOOL,
SIOCGIFHWADDR, SIOCGIFMTU, one socket each), a sysfs walk for the PCI
bandwidth and a /proc/net/route scan on every call. UCP queries an
iface far more often than once per open: uct_iface_set_am_handler()
and uct_base_iface_estimate_perf() both call uct_iface_query().

Calls per tcp iface per ucp_worker_create, counted with gdb breakpoints
on uct_tcp_netif_caps (ucx_info -u t -p -w, UCX_TLS=tcp,sm,self):
- ucp_worker_iface_open: 1 (wiface->attr)
- ucp_worker_iface_port_speed -> estimate_perf: 1
- ucp_worker_iface_init -> deactivate -> set_am_handlers: 13 (one per
  UCP AM id)
That is 15 per iface per worker, plus 13 more in ucp_worker_destroy
(remove_am_handlers). Protocol selection and wireup on the first send
add about 66 estimate_perf calls, and each iface activation another 13.
ucx_info -w on a host with 2 tcp devices issued 56 SIOCETHTOOL ioctls;
with this change it issues 2.

SIOCETHTOOL runs under rtnl_lock and, on IPoIB, queries the HCA port,
so with many netdevs and many processes or threads per node these
repeated queries serialize worker creation: 72 threads creating and
destroying one worker each (test/apps/test_init_mt) take 12-68 s
instead of 1-3 s, and MPI_Init at 72 ranks per node on a host with
six tcp netdevs drops from 7.3 s to 1.7 s with this change.

Query the netdev once in the iface constructor, before the memory pools
are created, and keep its latency, bandwidth and default-route flag in
the iface; iface_query applies MAX_BW and PREFER_DEFAULT to the stored
values as before. This follows the IB transport, whose iface_query reads
the port attributes cached at device open. tcp iface attributes are
therefore static after open for every consumer: link speed or default
route changes after open are not reflected, and the one consumer that
re-estimates bandwidth at runtime, the UCP handler for the IB port speed
change event, keeps the open-time bandwidth for a tcp iface that shares
the device with the IB port. ucx_info -d output is unchanged.
@svc-nvidia-pr-review

Copy link
Copy Markdown

🤖 Starting review — findings will be posted here when done.

@svc-nvidia-pr-review

Copy link
Copy Markdown

src/uct/tcp/tcp_iface.c

minor: can we cache the resulting priority instead of is_default? with PREFER_DEFAULT=n we store is_default=0 even when the netdev does have the default route, which contradicts the /* Netdev has the default route */ comment in tcp.h, and then query has to re-combine it with prefer_default.

@svc-ucx

svc-ucx commented Oct 30, 2026

Copy link
Copy Markdown

🤖 CI Triage Agent — UCX PR (Tests roce on worker 2) · commit 803672b9

TL;DR: The roce on worker 2 gtest run failed on a single test, ib/test_md.alloc/0 (mlx5_0), which exercises the IB MD's only allocatable memory type — on-NIC device memory (ibv_alloc_dm) — a tiny, device-wide shared resource; the failure is unrelated to PR #12201 (TCP-only change) and is almost certainly resource contention on the shared HCA, so re-run the job and harden the test's NO_MEMORY tolerance rather than changing TCP code.

Full analysis

Summary: 8965/8966 gtests passed; ib/test_md.alloc/0, where GetParam() = mlx5_0 failed, making make test exit 1 (make: *** [Makefile:4971: test] Error 1, Bash exited with code '2').

Root cause: The fetched log tail only contains the gtest summary ([ FAILED ] ib/test_md.alloc/0); the per-assertion text is earlier in the ~3109s run and outside the retrievable window. From the source, test_md.alloc is only instantiated for the ib component when UCT_MD_FLAG_ALLOC is set, and for the mlx5/DEVX MD that flag is set only if on-NIC device memory (DM) works (uct_ib_mlx5dv_check_dm_ksm_reg, ib_mlx5dv_md.c:2311), with md_attr->alloc_mem_types = UCS_BIT(UCS_MEMORY_TYPE_RDMA) and max_alloc = max_dm_size (ib_mlx5dv_md.c:3190-3193). The test therefore does 300 ibv_alloc_dm()/free cycles of random sizes up to max_dm_size/8 against a device-global pool of only a few hundred KB. Every failure path there returns UCS_ERR_NO_MEMORY (ib_mlx5dv_md.c:2167, 2184, 2194) and the test only tolerates <50% such failures before asserting "Too many OUT_OF_RESOURCE failures" (test_md.cc:559). On a shared RoCE worker where several gtest workers hit the same mlx5_0 concurrently, DM exhaustion/fragmentation easily pushes that ratio over the threshold. No commit in the DM alloc path is recent (last: a956862 Aug 2026, [REDACTED:Hex High Entropy String] Jul 2026), and the PR under test (UCT/TCP: Query netif capabilities once per iface) touches no IB/MD code — note every other IB, RC, DC, UD and TCP test in the same run passed.

Implicated commit: none — not a regression from [REDACTED:Hex High Entropy String] / PR #12201 (TCP-only). Test-side fragility originates in test_md.cc (alloc test, EXPECT_LT(... , 0.5) tolerance).

File: test/gtest/uct/test_md.cc:479-561 (test body and failure-tolerance check); src/uct/ib/mlx5/dv/ib_mlx5dv_md.c:2134-2236 (DM allocation returning UCS_ERR_NO_MEMORY)

Suggested fix:

  1. Re-run the roce on worker 2 job to confirm flakiness — do not block PR UCT/TCP: Query netif capabilities once per iface #12201 on it.
  2. Harden the test so a shared, exhaustible resource cannot fail the suite:
    • For UCS_MEMORY_TYPE_RDMA, treat persistent UCS_ERR_NO_MEMORY as a skip (UCS_TEST_SKIP_R("device memory is exhausted")) instead of a hard failure, since DM is device-global and other processes can hold it.
    • Reset num_alloc_failures = 0 at the top of the ucs_for_each_bit(mem_type, ...) loop — today it accumulates across memory types while the ratio is checked per type (test_md.cc:484, 516, 559), biasing later types toward failure.
    • Optionally cap the requested size further for DM (e.g. max_alloc/32) to reduce cross-worker contention.

Related: PR #12201 (UCT/TCP: Query netif capabilities once per iface) — the PR under test, unrelated to the failing test. No existing issue found tracking ib/test_md.alloc flakiness; worth opening one.

🛡️ This comment had 1 potential secret(s) redacted (Hex High Entropy String). See request_id 78802ac4-aa88-4b08-9dc0-c7beb1859c37 in the triage console for the audit trail.

@bwestheimer

Copy link
Copy Markdown
Contributor Author

Re the roce red leg on 803672b (ib/test_md.alloc/0, on-NIC device memory): agreed with the triage, unrelated to tcp. The same test flaked the same way on #11682 and #11683 in September (shared ibv_alloc_dm pool on the roce workers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants