Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[smart] Optimize the vDSO build process and code #10266

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
Loading
from

Conversation

BernardXiong
Copy link
Member

@BernardXiong BernardXiong commented May 12, 2025

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

[

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

vDSO的构建过程是在kernel scons构建中的一个独立环节,会有一定耦合关系。这里对它进行了优化调整,使得它更简单;同时对riscv-vdso的inline weak函数进行调整,不应该把weak应用于inline函数上。

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

优化vDSO的scons构建过程,同时把riscv-vdso weak inline函数移出,放置到.c文件中。

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

  • BSP: qemu-vexpress-a9/qemu-virt64-aarch64/qemu-virt64-riscv64
  • .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/workflows/bsp_buildings.yml 详细请参考链接BSP自查

… components

- Implemented vDSO functionality for the RISC-V architecture, including the necessary source files and linker scripts.
- Introduced a new `vdso_sys.c` file for RISC-V, containing functions to handle time retrieval using the vDSO mechanism.
- Created architecture-specific linker scripts (`vdso.lds.S`) for both AArch64 and RISC-V.
- Updated the build system to support vDSO compilation for RISC-V, including necessary adjustments in `SConstruct` files.
- Refactored existing vDSO code to improve compatibility and maintainability across architectures.
- Adjusted the maximum number of PTY devices in the terminal configuration from 64 to 32 for better resource management.
- Fixed minor issues in existing code, including correcting the path for the vDSO shared library and ensuring proper function definitions.
@github-actions github-actions bot added RT-Smart RT-Thread Smart related PR or issues component: lwp Component labels May 12, 2025
@BernardXiong BernardXiong requested a review from unicornx May 12, 2025 13:30
Copy link
Contributor

@unicornx unicornx left a comment

Choose a reason for hiding this comment

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

构建后会生成一些输出文件,但输出路径不在 bsp 的 build 下,而是在 components/lwp/vdso 下,scons -c 还无法清理干净。
建议构建的输出尽量都放到 bsp 的 build 下,实在满足不了的,看看 scons -c 能否清理掉。

  • components/lwp/vdso/user/build/libvdso.so
  • components/lwp/vdso/user/arch/risc-v/.sconsign.dblite
  • components/lwp/vdso/user/arch/risc-v/vdso_sys.os
  • components/lwp/vdso/user/arch/risc-v/vdso.lds

另外对于以下文件的文件名我感觉有些疑惑:

  • components/lwp/arch/common/vdso.c
  • components/lwp/arch/risc-v/common/vdso_data.c
  • components/lwp/arch/aarch64/common/vdso_data.c
    为啥有些叫 vdso.c,有些叫 vdso_data.c
    我理解这些文件中的内容都是为了实现 components/lwp/vdso/kernel/vdso.h 中声明的函数,所以全部叫 vdso.c 是不是更好,否则总要让人想一下 data 这里有何区别?

另外提个小建议,[smart] Add vDSO support for RISC-V architecture and refactor related components 这个 commit 修改了太多内容,如果能拆分一下就更好 review 了。

menuconfig RT_USING_VDSO
bool "vDSO"
config RT_USING_VDSO
bool "vDSO (??Virtual Dynamic Shared Object)"
Copy link
Contributor

Choose a reason for hiding this comment

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

两个 “?” 是什么意思?要不要去掉?

env = Environment(tools=['gcc', 'link'],
AS = AS, ASFLAGS = AFLAGS,
CC = CC, CFLAGS = CFLAGS,
CPP = CPP, AR = AR,
Copy link
Contributor

Choose a reason for hiding this comment

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

行尾有空格,请用 https://github.com/mysterywolf/formatting 检查一下所有修改

.rela.dyn : ALIGN(8) { *(.rela .rela*) }

.rodata : {
*(.rodata*)
Copy link
Contributor

Choose a reason for hiding this comment

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

行尾有空格

@BernardXiong
Copy link
Member Author

构建后会生成一些输出文件,但输出路径不在 bsp 的 build 下,而是在 components/lwp/vdso 下,scons -c 还无法清理干净。 建议构建的输出尽量都放到 bsp 的 build 下,实在满足不了的,看看 scons -c 能否清理掉。

  • components/lwp/vdso/user/build/libvdso.so
  • components/lwp/vdso/user/arch/risc-v/.sconsign.dblite
  • components/lwp/vdso/user/arch/risc-v/vdso_sys.os
  • components/lwp/vdso/user/arch/risc-v/vdso.lds

libvdso.so,vdso_sys.os会在scons -c后清理掉。后续加入vdso.lds,.sconsign.dblite的清理。

另外对于以下文件的文件名我感觉有些疑惑:

  • components/lwp/arch/common/vdso.c
  • components/lwp/arch/risc-v/common/vdso_data.c
  • components/lwp/arch/aarch64/common/vdso_data.c
    为啥有些叫 vdso.c,有些叫 vdso_data.c
    我理解这些文件中的内容都是为了实现 components/lwp/vdso/kernel/vdso.h 中声明的函数,所以全部叫 vdso.c 是不是更好,否则总要让人想一下 data 这里有何区别?

vdso_data.c应该有些不同的,做了一定的划分,后续在看看对vdso整体在代码层面是否做一个重构。目前PR主要还是偏构建层面多一些。

@unicornx
Copy link
Contributor

我看这次改动涉及了 vdso_data.c 能否一并修一下这个 issue :

@BernardXiong
Copy link
Member Author

我看这次改动涉及了 vdso_data.c 能否一并修一下这个 issue :

有警告吗?我这边打开后没见到。或者这个警告下一个PR再解吧,先能合并

@unicornx
Copy link
Contributor

我看这次改动涉及了 vdso_data.c 能否一并修一下这个 issue :

有警告吗?我这边打开后没见到。或者这个警告下一个PR再解吧,先能合并

不确定你那边为啥看不到,这个 issue 是基于没有合入这个 PR 之前发现的。
也可以先合并目前这个 PR 改动,后面再试试。

@supperthomas supperthomas requested a review from Copilot May 16, 2025 01:34
Copy link
Contributor

@Copilot 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 optimizes the vDSO build process by refining build scripts for different architectures and relocating weak inline functions for RISCV. In addition, the changes update library naming conventions and remove obsolete build files.

  • Updated the VDSO configuration to use a new library name.
  • Removed outdated build scripts (xmake.lua and obsolete SConstruct) in favor of updated SConstruct/SConscript logic.
  • Moved weak inline functions for RISCV from headers into a dedicated .c file and updated vDSO ABI naming.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
components/lwp/vdso/vdso_config.h Updated the VDSO library path for consistent naming.
components/lwp/vdso/user/xmake.lua Deleted obsolete build script.
components/lwp/vdso/user/arch/risc-v/vdso_sys.h Added RISCV vDSO header with new functionality.
components/lwp/vdso/user/arch/risc-v/vdso_sys.c Added RISCV vDSO implementation and relocated weak inline functions.
components/lwp/vdso/user/arch/risc-v/vdso.lds.S Introduced a new linker script for RISCV.
components/lwp/vdso/user/arch/risc-v/SConstruct Provided SConstruct file for RISCV build support.
components/lwp/vdso/user/arch/aarch64/SConstruct Added SConstruct file for Aarch64 builds.
components/lwp/vdso/user/SConstruct Removed obsolete SConstruct file.
components/lwp/vdso/SConscript Updated build script to support multiple architectures.
components/lwp/vdso/Kconfig Modified configuration strings for clarity.
components/lwp/terminal/Kconfig Reduced default pty device limit from 64 to 32.
components/lwp/arch/risc-v/common/vdso_data.c Added RISCV vDSO data update implementation.
components/lwp/arch/common/vdso.c Refactored vDSO ABI handling and updated code for common vDSO usage.
components/lwp/SConscript Adjusted source file inclusion to reflect the new build structure.
components/lwp/Kconfig Updated lwP configuration description.
Comments suppressed due to low confidence (2)

components/lwp/Kconfig:2

  • [nitpick] The term 'lwP' in the configuration is unconventional; consider using 'LWP (light weight process)' for improved clarity.
bool "lwP(light weight Process)"

components/lwp/vdso/SConscript:9

  • [nitpick] Avoid using 'list' as a variable name since it shadows the built-in Python type. Consider renaming it to a less ambiguous identifier such as 'files' or 'entries'.
list    = os.listdir(cwd)


do {
seq = rt_vdso_read_begin(vd);
cycles = __arch_get_hw_counter(vd->clock_mode, vd);
Copy link
Preview

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

The function __arch_get_hw_counter is defined without any parameters but is invoked here with two arguments, which will cause a compile-time error. Consider updating the function signature or its invocation to match.

Copilot uses AI. Check for mistakes.

Positive FeedbackNegative Feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: lwp Component RT-Smart RT-Thread Smart related PR or issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.