Skip to content

🎈 perf: perf rt_hw_interrupt_disable/enable #8042

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

Merged
merged 9 commits into from
Oct 25, 2023

Conversation

xqyjlj
Copy link
Contributor

@xqyjlj xqyjlj commented Sep 15, 2023

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

[

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

优化调度器,优化大量大锁代码, RT_USING_SIGNALS 由于环境原因,目前暂未优化

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

在什么测试环境下测试通过 (what is the test environment)

arm64

arm
]

当前拉取/合并请求的状态 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

@xqyjlj xqyjlj marked this pull request as draft September 15, 2023 08:40
@mysterywolf
Copy link
Member

需要rebase一下代码 有冲突

@Guozhanxin Guozhanxin added the v5.1.0 version 5.1.0 (planned to be released by the end of 2023) label Sep 17, 2023
@xqyjlj xqyjlj marked this pull request as ready for review September 21, 2023 09:51
@xqyjlj xqyjlj force-pushed the perf-dev branch 5 times, most recently from a9c783f to 84f98ca Compare September 25, 2023 03:45
@xqyjlj
Copy link
Contributor Author

xqyjlj commented Sep 28, 2023

要合并这个的话得先把shell那几个lwp的先合并了,这个得最后合并, 已经可以合并了

@BernardXiong
Copy link
Member

要合并这个的话得先把shell那几个lwp的先合并了,这个得最后合并

一个是需要解决代码冲突,另外前向需要合并的关联PR也列出来吧

@xqyjlj xqyjlj force-pushed the perf-dev branch 2 times, most recently from 22c2402 to fe2be07 Compare October 18, 2023 08:42
@xqyjlj
Copy link
Contributor Author

xqyjlj commented Oct 18, 2023

要合并这个的话得先把shell那几个lwp的先合并了,这个得最后合并

一个是需要解决代码冲突,另外前向需要合并的关联PR也列出来吧

可以合并了

Copy link
Member

@BernardXiong BernardXiong left a comment

Choose a reason for hiding this comment

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

对于一些情况做些说明;对于counter的,希望都过一遍,大多数场合应该是atomic方式的,另外是名称,单独的counter意义比较单薄,是否有更好的名称,例如ref_count。

@xqyjlj
Copy link
Contributor Author

xqyjlj commented Oct 21, 2023

关于c++的原子类型,如果在c++中启用原子类型,那么

#ifdef __cplusplus
#include <atomic> // atomic 要在extern "C" {前面,导致rtdef.h也不能被extern "C"包含
extern "C" {
#endif

typedef std::atomic<size_t> rt_atomic_t;

还有一种是c++的原子操作用硬件原子或者软件模拟原子替换,这样就是和c语言的一样的实现了

@xqyjlj
Copy link
Contributor Author

xqyjlj commented Oct 22, 2023

还有一种c++的原子类型兼容是把c++的原子通过宏重定向到软件原子或者硬件原子,undef 掉RT_USING_STDC_ATOMIC,这样就不会包含stdatomic.h引起编译报错了

@xqyjlj xqyjlj force-pushed the perf-dev branch 3 times, most recently from 7aa38c9 to 7a9f812 Compare October 23, 2023 06:19
@xqyjlj xqyjlj force-pushed the perf-dev branch 3 times, most recently from 21fff9c to 8b6da61 Compare October 25, 2023 09:31
xqyjlj and others added 9 commits October 25, 2023 20:08
Including usages under lwp_pid.c, lwp_tid.c, lwp_signal.c,
lwp_syscall.c, lwp_pmutex.c, lwp.c.
2 API for safety mutex take are provided -
lwp_mutex_take_safe/lwp_mutex_release_safe.
They will restrict and verify the usage of the mutex.

Remove the hw_interrupt API in ipc.c, and switch to spin lock for
synchronization.

Signed-off-by: Shell <[email protected]>
@BernardXiong BernardXiong merged commit 3283f54 into RT-Thread:master Oct 25, 2023
@xqyjlj xqyjlj deleted the perf-dev branch October 31, 2023 09:31
Comment on lines +700 to 702
rt_spin_unlock_irqrestore(&_hard_spinlock, level);
/* call timeout function */
t->timeout_func(t->parameter);
Copy link
Contributor

Choose a reason for hiding this comment

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

个人还是不是很理解 timeout_func 前后恢复中断状态的方案,虽然它确实在理论上对提升实时性有很大帮助。个人理解,在遍历 _timer_list 的前后关中断,不就是为了确保其它线程或者中断环境不会对 _timer_list 做任何修改吗? 而此处开启中断, 但不出现问题,是否意味着其它线程或者中断环境可以在此阶段修改 timer_list, 遍历 _timer_list 的逻辑不会被影响? 那在这个函数中关中断的意义何在?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

如果中断中使用了timer相关的api,是会修改timer_list,而且可能会插到链表前面去,造成漏掉一个时钟节拍。这个确实需要考虑。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
urgent 🏃 urgent v5.1.0 version 5.1.0 (planned to be released by the end of 2023)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants