-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kernel: k_work_sync is modified after k_work_flush returns #64530
Comments
Hi @c1728p9! We appreciate you submitting your first issue for our open-source project. 🌟 Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙 |
Assert that k_work_sync is modified after k_work_flush returns. This is because the work queue thread continues to modify the flag in sync even after k_work_flush returns. This commit adds K_WORK_SYNCED_BIT, and with this bit, we can prevent the work queue thread from modifying sync after k_work_flush returns. It is now safe to reuse or free k_work_sync after a call to k_work_flush(), k_work_cancel_sync() and sibling flush and cancel APIs. Fixes zephyrproject-rtos#64530 Signed-off-by: Junfan Song <[email protected]>
After a call to k_work_flush returns the sync variable may still be modified by the workq. This is because the work queue thread continues to modify the flag in sync even after k_work_flush returns. This commit adds K_WORK_FLUSHING_BIT, and with this bit, we moved the logic of waking up the caller from handle_flush to the finalize_flush_locked in workq, so that after waking up the caller, the workqueue will no longer operate on sync. Fixes: zephyrproject-rtos#64530 Signed-off-by: Junfan Song <[email protected]>
After a call to k_work_flush returns the sync variable may still be modified by the workq. This is because the work queue thread continues to modify the flag in sync even after k_work_flush returns. This commit adds K_WORK_FLUSHING_BIT, and with this bit, we moved the logic of waking up the caller from handle_flush to the finalize_flush_locked in workq, so that after waking up the caller, the workqueue will no longer operate on sync. Fixes: zephyrproject-rtos#64530 Signed-off-by: Junfan Song <[email protected]>
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
After a call to k_work_flush returns the sync variable may still be modified by the workq. This is because the work queue thread continues to modify the flag in sync even after k_work_flush returns. This commit adds K_WORK_FLUSHING_BIT, and with this bit, we moved the logic of waking up the caller from handle_flush to the finalize_flush_locked in workq, so that after waking up the caller, the workqueue will no longer operate on sync. Fixes: #64530 Signed-off-by: Junfan Song <[email protected]>
Describe the bug
After a call to k_work_flush returns the k_work_sync struct may still be modified by the workq.
To Reproduce
The problem can be replicated by running the following code:
Expected behavior
The struct k_work_sync is not modified by the workq after k_work_flush returns.
Impact
It is unclear when it is safe to reuse or free k_work_sync after a call to k_work_flush.
Logs and console output
Logs from the above program running on a K64F with Zephyr v3.3.0:
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: