Skip to content

Conversation

@Tm-C-mT
Copy link
Contributor

@Tm-C-mT Tm-C-mT commented Nov 20, 2025

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

Add comment description for SMP Threads Auto Assign to Idle Cores Test

你的解决方案是什么 (what is your solution)

请提供验证的bsp和config (provide the config and bsp)

  • BSP:
  • .config:
  • action:

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

Add comments for smp_affinity_pri1

Signed-off-by: Mengchen Teng <teng_mengchen@163.com>
Add comments for smp_affinity_pri2

Signed-off-by: Mengchen Teng <teng_mengchen@163.com>
@github-actions
Copy link

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:AddDescription-SMP2
  • 设置PR number为 \ Set the PR number to:10965
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 AddDescription-SMP2 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the AddDescription-SMP2 branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@github-actions github-actions bot added the Kernel PR has src relate code label Nov 20, 2025
@github-actions
Copy link

github-actions bot commented Nov 20, 2025

📌 Code Review Assignment

🏷️ Tag: kernel

Reviewers: GorrayLi ReviewSun hamburger-os lianux-mm wdfk-prog xu18838022837

Changed Files (Click to expand)
  • src/utest/smp/smp_affinity_pri1_tc.c
  • src/utest/smp/smp_affinity_pri2_tc.c
  • src/utest/smp/smp_bind_affinity_tc.c

📊 Current Review Status (Last Updated: 2025-11-25 10:02 CST)

  • GorrayLi Pending Review
  • ReviewSun Pending Review
  • hamburger-os Pending Review
  • lianux-mm Pending Review
  • wdfk-prog Pending Review
  • xu18838022837 Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@Tm-C-mT
Copy link
Contributor Author

Tm-C-mT commented Nov 24, 2025

@Rbb666 麻烦review一下呢🌹

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds detailed comment descriptions for three SMP (Symmetric Multi-Processing) test cases in the RT-Thread utest framework. The additions follow a consistent documentation template that includes test objectives, scenarios, verification metrics, dependencies, and expected results.

Key Changes:

  • Enhanced documentation for smp_bind_affinity_tc.c test covering thread core affinity binding
  • Enhanced documentation for smp_affinity_pri1_tc.c test covering low-priority thread behavior with bound cores
  • Enhanced documentation for smp_affinity_pri2_tc.c test covering priority-based thread preemption scenarios

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/utest/smp/smp_bind_affinity_tc.c Added structured test documentation describing thread core binding verification test with detailed scenarios and expected results
src/utest/smp/smp_affinity_pri1_tc.c Added structured test documentation describing low-priority bound thread behavior and high-priority unbound thread preemption scenarios
src/utest/smp/smp_affinity_pri2_tc.c Added structured test documentation describing medium-priority unbound thread behavior with low-priority bound thread creation scenarios

Comment on lines 28 to 29
* - RT_CPUS_NR threads (T0~T(RT_CPUS_NR-1)) are created, with each thread bound to its respective core. Among them,
* - the thread on core 0 has a medium priority (THIGH_PRIORITY), while the other threads have the highest priority (THREAD_PRIORITY).
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

[Documentation/文档]: Inconsistent description of T0 binding / T0 绑定状态描述不一致

English: Line 17 in the original @note states "thread 0 is not bound to core 0", but the new documentation at line 28 states "with each thread bound to its respective core". Examining the code (lines 108-114), T0 is created but is NOT explicitly bound to any core - there's no RT_THREAD_CTRL_BIND_CPU call for T0. Only threads T1~T(RT_CPUS_NR-1) are bound to their respective cores (lines 117-127). The new documentation is incorrect.

中文: 原始 @note 的第 17 行说明"thread 0 is not bound to core 0"(线程 0 未绑定到核心 0),但新文档第 28 行声称"with each thread bound to its respective core"(每个线程都绑定到各自的核心)。检查代码(第 108-114 行),T0 被创建但并未显式绑定到任何核心 - 没有对 T0 调用 RT_THREAD_CTRL_BIND_CPU。只有线程 T1~T(RT_CPUS_NR-1) 被绑定到各自的核心(第 117-127 行)。新文档不正确。

Suggested Fix / 建议修复:

 * Test Scenarios:
 * - RT_CPUS_NR threads (T0~T(RT_CPUS_NR-1)) are created. T0 is unbound with medium priority (THIGH_PRIORITY), 
 * - while threads T1~T(RT_CPUS_NR-1) are each bound to their respective cores with the highest priority (THREAD_PRIORITY).
Suggested change
* - RT_CPUS_NR threads (T0~T(RT_CPUS_NR-1)) are created, with each thread bound to its respective core. Among them,
* - the thread on core 0 has a medium priority (THIGH_PRIORITY), while the other threads have the highest priority (THREAD_PRIORITY).
* - RT_CPUS_NR threads (T0~T(RT_CPUS_NR-1)) are created. T0 is unbound with medium priority (THIGH_PRIORITY),
* - while threads T1~T(RT_CPUS_NR-1) are each bound to their respective cores with the highest priority (THREAD_PRIORITY).

Copilot uses AI. Check for mistakes.
* - If thread_inc[x] is equal to thread_tic[x], it indicates that thread Tx is correctly bound to core x.
*
* Verification Metrics:
* - Output message: [I/utest] [ PASSED ] [ result ] testcase (core.smp_bind_affinity)
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

[Spelling/拼写]: Extra spacing in output message format / 输出消息格式中存在多余空格

English: Line 33 shows extra spaces in the output message format: [ PASSED ] and [ result ]. This should match the standard utest output format which uses single spaces.

中文: 第 33 行显示的输出消息格式中存在多余空格:[ PASSED ][ result ]。这应该与使用单个空格的标准 utest 输出格式保持一致。

Suggested Fix / 建议修复:

 * - Output message: [I/utest] [ PASSED ] [ result ] testcase (core.smp_bind_affinity)
Suggested change
* - Output message: [I/utest] [ PASSED ] [ result ] testcase (core.smp_bind_affinity)
* - Output message: [I/utest] [ PASSED ] [ result ] testcase (core.smp_bind_affinity)

Copilot uses AI. Check for mistakes.
* - RT_CPUS_NR threads (T0~T(RT_CPUS_NR-1)) are created, with only T0 bound to core 0. When thread Tx is running,
* - thread_tic[x] increments by 1; if x is equal to the core ID, thread_inc[x] also increments by 1. After the
* - program runs for a period of time, observe the value relationship between the thread_inc and thread_tic arrays.
* - If thread_inc[x] is equal to thread_tic[x], it indicates that thread Tx is correctly bound to core x.
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

[Documentation/文档]: Inaccurate test scenario description / 测试场景描述不准确

English: The description in lines 27-30 states "If thread_inc[x] is equal to thread_tic[x], it indicates that thread Tx is correctly bound to core x." However, examining the code (lines 70-73), only T0 is bound to core 0. Other threads (T1 to T(RT_CPUS_NR-1)) are NOT bound to any core. The assertion at line 73 verifies thread_inc[para] != thread_tic[para] for threads other than T0, which means they should NOT always run on their corresponding core numbers.

中文: 第 27-30 行的描述声称"如果 thread_inc[x] 等于 thread_tic[x],则表明线程 Tx 正确绑定到核心 x"。然而,检查代码(第 70-73 行)可知,只有 T0 绑定到核心 0。其他线程(T1 到 T(RT_CPUS_NR-1))并未绑定到任何核心。第 73 行的断言验证了对于非 T0 线程 thread_inc[para] != thread_tic[para],这意味着它们不应该总是在其对应的核心编号上运行。

Suggested Fix / 建议修复:
The description should be corrected to clarify that only T0 is bound to core 0, and other threads are unbound and will migrate across cores:

 * Test Scenarios:
 * - RT_CPUS_NR threads (T0~T(RT_CPUS_NR-1)) are created, with only T0 bound to core 0. When thread Tx is running,
 * - thread_tic[x] increments by 1; if x is equal to the core ID, thread_inc[x] also increments by 1. After the
 * - program runs for a period of time, observe the value relationship between the thread_inc and thread_tic arrays.
 * - If thread_inc[0] equals thread_tic[0], it indicates T0 is correctly bound to core 0. For other threads (T1~T(RT_CPUS_NR-1)),
 * - thread_inc[x] will NOT equal thread_tic[x] as they are unbound and will migrate across different cores.
Suggested change
* - If thread_inc[x] is equal to thread_tic[x], it indicates that thread Tx is correctly bound to core x.
* - If thread_inc[0] equals thread_tic[0], it indicates T0 is correctly bound to core 0. For other threads (T1~T(RT_CPUS_NR-1)),
* thread_inc[x] will NOT equal thread_tic[x] as they are unbound and will migrate across different cores.

Copilot uses AI. Check for mistakes.
* Test Case Name: [smp_affinity_pri2]
*
* Test Objectives:
* - Verify that threads with low-priority unbound cores do not preempt high-priority threads.
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

[Documentation/文档]: Incorrect test objective description / 测试目标描述错误

English: Line 25 states "Verify that threads with low-priority unbound cores do not preempt high-priority threads." However, examining the code (line 82), thread Tn is bound to core 0 using rt_thread_control(temp_thread, RT_THREAD_CTRL_BIND_CPU, (void *)0). The thread Tn is NOT unbound. The test verifies that a low-priority thread bound to the same core does not preempt a higher-priority thread on that core.

中文: 第 25 行声称"验证低优先级未绑定核心的线程不会抢占高优先级线程"。然而,检查代码(第 82 行)可知,线程 Tn 通过 rt_thread_control(temp_thread, RT_THREAD_CTRL_BIND_CPU, (void *)0) 被绑定到核心 0。线程 Tn 并非未绑定。该测试验证的是绑定到同一核心的低优先级线程不会抢占该核心上的高优先级线程。

Suggested Fix / 建议修复:

 * Test Objectives:
 * - Verify that a low-priority thread bound to a core does not preempt a higher-priority thread running on the same core.
Suggested change
* - Verify that threads with low-priority unbound cores do not preempt high-priority threads.
* - Verify that a low-priority thread bound to a core does not preempt a higher-priority thread running on the same core.

Copilot uses AI. Check for mistakes.
Add comments for smp_bind_affinity, And fixed some comment issues in smp_affinity_pri2_tc.

Signed-off-by: Mengchen Teng <teng_mengchen@163.com>
@Tm-C-mT Tm-C-mT force-pushed the AddDescription-SMP2 branch from 566995f to 6bb7094 Compare November 25, 2025 02:01
@Tm-C-mT
Copy link
Contributor Author

Tm-C-mT commented Nov 25, 2025

已修改

@Rbb666 Rbb666 merged commit 9c2279a into RT-Thread:master Nov 26, 2025
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Kernel PR has src relate code

Projects

Development

Successfully merging this pull request may close these issues.

2 participants