Skip to content

[libcpu/aarch64]atomic实现修改#9364

Merged
mysterywolf merged 3 commits intoRT-Thread:masterfrom
messigogogo:test_0827_smp_bug
Sep 3, 2024
Merged

[libcpu/aarch64]atomic实现修改#9364
mysterywolf merged 3 commits intoRT-Thread:masterfrom
messigogogo:test_0827_smp_bug

Conversation

@messigogogo
Copy link
Copy Markdown
Contributor

@messigogogo messigogogo commented Aug 29, 2024

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

[

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

e9b683d 的提交中规范了atomic的实现方式,原本phytium bsp的默认配置同时打开了RT_USING_STDC_ATOMIC/RT_USING_HW_ATOMIC, 关闭后RT_USING_STDC_ATOMIC发现内核不能正常启动,查明原因是libcpu\aarch64\common\atomic_aarch64.c 中rt_hw_atomic_compare_exchange_strong函数逻辑有误,请仔细检查

你的解决方案是什么 (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

@github-actions github-actions Bot added BSP Arch: ARM/AArch64 BSP related with arm libcpu BSP: Phytium BSP related with Phytium labels Aug 29, 2024
@messigogogo
Copy link
Copy Markdown
Contributor Author

在rt_soft_atomic_compare_exchange_strong(ptr, v, des)的实现逻辑中,比较了ptr与v是否相同,若相同则将des赋值给ptr,并返回1;若不同则将ptr赋值给v,并返回0
b3edad256a75f9c2e7dcd85a6a2aead

但是在原本的rt_hw_atomic_compare_exchange_strong(ptr, v, des)中,并没有做不同则将ptr赋值给v,并返回0的操作,导致在IPC模块调用该原子操作时有误
5dd00975e11afe1914518048fa83b26

新增了str %0, [%5] ->mov %w1, #0来实现该逻辑
d02d2a170d9dc4ab3ba8885ad1df8e6

@messigogogo
Copy link
Copy Markdown
Contributor Author

@polarvid

@polarvid
Copy link
Copy Markdown
Contributor

@polarvid

这个挺早好像就有反馈说有问题了。不过 arm64 hw_atomic 不是我这维护的,平时也不用,所以没关注。

关于 PR 修复,建议是使能 HW_ATOMIC 关闭 STDC,然后通过 unittest case 验证一下。这部分的用例是有的。

@polarvid
Copy link
Copy Markdown
Contributor

配置的修改能拆出来吗?在这个 PR 下好像无关,有点乱了。

@messigogogo
Copy link
Copy Markdown
Contributor Author

配置的修改能拆出来吗?在这个 PR 下好像无关,有点乱了。

关掉了,只保留了atomic_aarch64的修改

Copy link
Copy Markdown
Contributor

@polarvid polarvid left a comment

Choose a reason for hiding this comment

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

image

格式检查也请处理一下呢

@messigogogo
Copy link
Copy Markdown
Contributor Author

image

格式检查也请处理一下呢

修改了

@polarvid polarvid added the +1 Agree +1 label Sep 3, 2024
@mysterywolf mysterywolf merged commit a4882e1 into RT-Thread:master Sep 3, 2024
@messigogogo messigogogo mentioned this pull request Sep 5, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: ARM/AArch64 BSP related with arm BSP: Phytium BSP related with Phytium BSP libcpu +1 Agree +1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants