Skip to content

UCT/IB: speed change event bug fix - #11710

Merged
iyastreb merged 6 commits into
openucx:masterfrom
ZhenlongMa:bug-fix/speed_change_event
Aug 11, 2026
Merged

iyastreb merged 6 commits into
openucx:masterfrom
ZhenlongMa:bug-fix/speed_change_event

Conversation

@ZhenlongMa

@ZhenlongMa ZhenlongMa commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

What?

Add support for IBV_EVENT_DEVICE_SPEED_CHANGE, the device-scoped speed change event emitted by rdma-core, and fix assertion failures triggered when the event is handled in SINGLE threading mode and when multiple events arrive quickly.

Why?

In #11056, UCX introduced an event IBV_EVENT_PORT_SPEED_CHANGE to detect link speed changes and adjust bandwidth accordingly. However, rdma-core actually emits IBV_EVENT_DEVICE_SPEED_CHANGE (a device-scoped event with port_num == 0) instead of the port-scoped variant. As a result, #11056 actually can't work.

Besides, in SINGLE threading mode, ucp_worker_progress() does not acquire the worker async lock, but ucp_worker_iface_handle_port_speed_event() asserts the lock is held, causing an assertion failure when the event is triggered.

When multiple events arrive quickly, such as link is down and recovered at once, the callback of the previous event has not been processed but the scheduler asserts the callback should be NULL when the latter event arrives and a failure is reported.

How?

Replace the macro IBV_EVENT_PORT_SPEED_CHANGE with IBV_EVENT_DEVICE_SPEED_CHANGE, and change the event's resource id to 0 instead of port num.

Wrap the ucp_worker_iface_handle_port_speed_event() call in UCS_ASYNC_BLOCK / UCS_ASYNC_UNBLOCK to explicitly hold the worker async context, satisfying the lock assertion regardless of the threading mode.

In the callback scheduler, if the callback is null, just return without assertion.

…e speed_change_event

IBV_EVENT_DEVICE_SPEED_CHANGE event is popped from the UCT worker progress
queue. ucp_worker_progress() does not acquire the worker async lock in
SINGLE mode, while ucp_worker_iface_handle_port_speed_event() checks
the lock to be held, which causes an assertion failure.

This commit explicitly blocks the worker async context.

Signed-off-by: Zhenlong Ma <mazhenlong321@gmail.com>
@ZhenlongMa ZhenlongMa changed the title Bug fix/speed change event UCT/IB: speed change event bug fix Jul 31, 2026
@ZhenlongMa
ZhenlongMa marked this pull request as ready for review July 31, 2026 12:37
UCX receives IBV_EVENT_PORT_SPEED_CHANGE event and adjust the speed accordingly,
but rdma-core actually provides IBV_EVENT_DEVICE_SPEED_CHANGE event carrying port number
zero, which cannot trigger the speed adjust logic of UCX.

This commit adds support for IBV_EVENT_DEVICE_SPEED_CHANGE and keeps compatible
with IBV_EVENT_PORT_SPEED_CHANGE.

Signed-off-by: Zhenlong Ma <mazhenlong321@gmail.com>
@ZhenlongMa
ZhenlongMa force-pushed the bug-fix/speed_change_event branch from 935c294 to d76e886 Compare August 2, 2026 02:46
@gleon99
gleon99 requested a review from iyastreb August 2, 2026 17:57
@gleon99

gleon99 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@iyastreb please review

Comment thread src/uct/ib/base/ib_verbs.h Outdated
# define UCT_IB_SPEED_CHANGE_EVENT_DEVICE_SCOPE 1
# define UCT_IB_SPEED_CHANGE_EVENT_NUM_RESOURCES(_n) 1
# define UCT_IB_SPEED_CHANGE_EVENT_RESOURCE_ID(_port) 0
#elif HAVE_DECL_IBV_EVENT_PORT_SPEED_CHANGE

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.

Does it make sense to still support PORT_SPEED_CHANGE?
IIUC rdma-core implemented support for device, so port speed change is obsolete?
I think this block can be greatly simplified if we keep only device
You can confirm with Or Har-Toov

@ZhenlongMa
ZhenlongMa marked this pull request as draft August 4, 2026 06:43
Signed-off-by: Zhenlong Ma <mazhenlong321@gmail.com>
…progress

queue and don't raise assertion failure in case device change events arrive
frequently.

Signed-off-by: Zhenlong Ma <mazhenlong321@gmail.com>
…nger supported.

Signed-off-by: Zhenlong Ma <mazhenlong321@gmail.com>
@ZhenlongMa
ZhenlongMa marked this pull request as ready for review August 7, 2026 11:06

@iyastreb iyastreb left a comment

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.

LGTM apart from minor comments

Comment thread src/uct/ib/base/ib_verbs.h Resolved
Comment thread src/uct/ib/base/ib_device.c Resolved
Comment thread src/uct/ib/base/ib_device.c Resolved
Comment thread src/uct/ib/base/ib_iface.c Resolved
Comment thread test/gtest/ucp/test_ucp_proto_mock.cc Resolved
Signed-off-by: Zhenlong Ma <mazhenlong321@gmail.com>
@ZhenlongMa
ZhenlongMa force-pushed the bug-fix/speed_change_event branch from 04cf815 to 3e2917c Compare August 7, 2026 13:46
@iyastreb
iyastreb merged commit 39b34ae into openucx:master Aug 11, 2026
161 checks passed
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.

3 participants