修复时间溢出,内核提速,修复随机丢失任务#10328
Conversation
|
不同类型的PR,提交到不同的分支,然后分别发PR,这样更好些。 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds llvm-arm as a supported CMake platform, refines tuple-to-define string formatting in cmake.py, and replaces many manual rt_schedule() calls with wrap-aware tick deltas and inlined scheduler updates.
- Extend CMake platform checks to include
llvm-armand sanitize tuple defines - Replace multiple
rt_tick_get()uses withrt_tick_get_delta(), handling wrap-around - Refactor scheduler in
scheduler_up.cto inline priority updates and minimize direct list operations
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/cmake.py | Add llvm-arm to platform lists; sanitize tuple CPPDEFINES |
| src/timer.c | Combine flag checks; use wrap-aware timeout comparison |
| src/thread.c | Remove redundant rt_schedule() calls; use rt_tick_get_delta() |
| src/signal.c | Eliminate spuriously re-scheduling in signal delivery |
| src/scheduler_up.c | Inline priority update/get functions; remove duplicated scheduling logic |
| src/mempool.c | Replace simple tick subtraction with rt_tick_get_delta(); remove in-place scheduling |
| src/ipc.c | Remove ad-hoc rt_schedule() invocations across semaphores, mutexes, events, mailboxes, and message queues |
Comments suppressed due to low confidence (4)
tools/cmake.py:189
- [nitpick] Sanitizing tuple strings by brute-force replace can be fragile. Consider explicitly handling tuple or list defines, e.g. join elements with spaces when
iis a sequence, and fallback tostr(i)otherwise.
cm_file.write("\t-D" + str(i).replace("(", "").replace(")","\").replace(",", " ") + "\n")
src/thread.c:135
- Removing the explicit
rt_schedule()in_thread_exitmay prevent the scheduler from switching away from an exited thread. Ensure that context switching still occurs via another mechanism after exit.
rt_schedule();
src/mempool.c:329
- The removed
rt_schedule()after releasing the spinlock may prevent newly awakened threads from running. Verify that a scheduling point is still reached when a block is allocated or freed.
rt_schedule();
src/ipc.c:728
- All explicit
rt_schedule()calls were removed from semaphore release logic, potentially delaying wake-up of waiting threads. Confirm that the scheduler is triggered elsewhere or restore the scheduling call here.
if (need_schedule == RT_TRUE)
|
|
||
| ret = _timer_list_next_timeout(_soft_timer_list, &next_timeout); | ||
| if ((ret == RT_EOK) && (next_timeout <= rt_tick_get())) | ||
| if ((ret == RT_EOK) && ((rt_tick_get() - next_timeout) < RT_TICK_MAX / 2)) |
There was a problem hiding this comment.
[nitpick] Using RT_TICK_MAX / 2 for wrap-around tolerance is a magic constant. Add a brief comment or create a helper function to clarify why half the range is used for timeout comparisons.
| if ((ret == RT_EOK) && ((rt_tick_get() - next_timeout) < RT_TICK_MAX / 2)) | |
| if ((ret == RT_EOK) && ((rt_tick_get() - next_timeout) < rt_timer_wraparound_tolerance())) |
|
|
||
| *tick += inc_tick; | ||
| left_tick = *tick - cur_tick; | ||
| if (left_tick > target_tick) |
There was a problem hiding this comment.
left_tick > target_tick compares leftover ticks to an absolute timeout, which may be incorrect after wrap-around. Revisit this condition to ensure it handles wrap correctly (e.g., compare to half the tick range or use rt_tick_get_delta).
我没想吧kenel的pr,我只是同步到我自己的分支,不知道咋整个都pr了。 |
|
需要多练习下git使用。 因为你本地就直接用的master,发PR最好创建1个新的分支。 你现在这种情况,比较合理的操作是
|
这次不小心pr的这个 ,提升内核性能最低15%,修复丢失任务bug(一个任务 不停关闭新建,就有丢失的问题)。 |
这次不小心pr的这个 ,提升内核性能最低15%,修复丢失任务bug(一个任务 不停关闭新建,就有丢失的问题)。
我已经验证稳定性,你可以拉下这个pr试试就知道了。 |
我测试网络任务,之前 at32f407 100mh最大网速只能达到550kB cpu占用率90%多,打完我的补丁最高达640kB CPU占用%84. |
3 similar comments
我测试网络任务,之前 at32f407 100mh最大网速只能达到550kB cpu占用率90%多,打完我的补丁最高达640kB CPU占用%84. |
我测试网络任务,之前 at32f407 100mh最大网速只能达到550kB cpu占用率90%多,打完我的补丁最高达640kB CPU占用%84. |
我测试网络任务,之前 at32f407 100mh最大网速只能达到550kB cpu占用率90%多,打完我的补丁最高达640kB CPU占用%84. |
|
test.zip |
测试完就帮我把这个pr拉入主线吧。 |
|
还有人管理这项目吗?给kernel提升性能提升稳定性,根本没人理。 |
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up