[Celestica][Ladakh800bcls] Fix PAI concurrency crash by passing in sync callbacks#889
[Celestica][Ladakh800bcls] Fix PAI concurrency crash by passing in sync callbacks#889gang-tao wants to merge 1 commit into
Conversation
|
@Protick666 has imported this pull request. If you are a Meta employee, you can view this in D92066754. |
|
Hello @gang-tao Thanks for this change! There is one issue: introducing a global mutex and passing it down to SAI makes all operations sequential—including switch initialization, firmware downloads, and port programming. Sequential FW downloads are quite slow, which will become even more problematic as we move toward a 75% retimer design. This approach likely won't scale. Could you explore the possibility of using a separate mutex per xphy? From my review of the PAI source code, this might be feasible. Let me know your thoughts! |
fa0aeed to
190e09e
Compare
|
@gang-tao has updated the pull request. You must reimport the pull request before landing. |
Hi @Protick666 |
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runclang-format.............................................................Passed
black................................................(no files to check)Skipped
shellcheck...........................................(no files to check)Skipped
shfmt................................................(no files to check)Skipped
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...........................................(no files to check)Skipped
check json...........................................(no files to check)Skipped
check for merge conflicts................................................Passed
ruff check...........................................(no files to check)Skipped
Summary
The Broadcom PAI implementation is not thread-safe, which can lead to crashes when multiple threads attempt to initialize PHYs concurrently.
Motivation
This change fixes the race condition by providing the PAI layer with a thread-safe locking mechanism from the agent. Two new SAI extension attributes, SyncLock and SyncUnlock, are introduced to pass pointers to lock and unlock functions. These functions wrap a global mutex, allowing the PAI layer to serialize access to its critical sections and prevent crashes.
The change is enabled only when SAI_BRCM_PAI_IMPL is defined, ensuring no impact on other SAI implementations.
Currently, both a global lock and per-XPHY locks have been implemented. The per-XPHY lock is enabled by default to ensure high concurrency. The global lock can be enabled by configuring enable_xphy_global_lock.
Test Plan
In addition to the initial testing, we have run qsfp_hw_test 100 consecutive times with a 100% pass rate. It is currently being used across multiple project testbeds, and no issues have been found.
build
targets fboss_hw_agent-sai_impl, multi_switch_agent_hw_test, sai_agent_hw_test-sai_impl, qsfp_hw_test, qsfp_service build passed. This ensures the definition SAI_BRCM_PAI_IMPL isolates SAI and PAI, preventing them from affecting each other.
note: need brcm_pai_extensions.h in PAI, saved in /var/FBOSS/pai_impl/include/sai/experimental/brcm_pai_extensions.h
run scripts as below
result