Skip to content
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

risc-v: Accelerate schedule by percpu #15081

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

no1wudi
Copy link
Contributor

@no1wudi no1wudi commented Dec 9, 2024

Summary

Fetch TCB info in percpu scratch register for better performance.

Similar to 948ac9b

Impact

RISC-V arch level code

Testing

ostest

@no1wudi no1wudi marked this pull request as draft December 9, 2024 06:02
@github-actions github-actions bot added Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Size: M The size of the change in this PR is medium labels Dec 9, 2024
@nuttxpr
Copy link

nuttxpr commented Dec 9, 2024

[Experimental Bot, please feedback here]

No, this PR does not fully meet the NuttX requirements. While it provides a summary of the change and mentions testing, it lacks crucial details.

Here's what's missing:

  • Summary: While the what is described, the why and how are missing. Why is fetching TCB info in percpu scratch registers better for performance? Explain the mechanism and the expected performance gains. Mention any related NuttX issues.
  • Impact: The impact section is overly simplistic. While it mentions RISC-V arch code, it doesn't explicitly answer the required questions. Each impact question (user, build, hardware, documentation, security, compatibility) needs a YES/NO answer followed by a description if YES. Even if the answer is NO, stating it explicitly is important for clarity. For example:
    • Impact on user: NO
    • Impact on build: NO
    • Impact on hardware: YES (Affects RISC-V architectures. No changes to existing boards or drivers, but modifies low-level architecture code.)
    • Impact on documentation: NO (or YES if documentation needs updating)
    • Impact on security: NO (or YES with explanation if applicable)
    • Impact on compatibility: NO (or YES with explanation if applicable)
  • Testing: "ostest" is insufficient. Provide details about the build host (OS, CPU, compiler) and the specific RISC-V target (simulator, board, configuration) used for testing. Crucially, the testing logs before and after the change are missing. These logs are essential to demonstrate the actual performance improvement and validate the change's effectiveness. If ostest was run before and after, include the relevant output. Even a simple timing comparison would be helpful.

The PR needs to be significantly more detailed to be considered complete. Provide the missing information to ensure reviewers can properly assess the change.

arch/risc-v/include/irq.h Outdated Show resolved Hide resolved
@no1wudi no1wudi force-pushed the riscv branch 3 times, most recently from fe66e6f to ba568f6 Compare December 10, 2024 08:30
arch/risc-v/include/arch.h Outdated Show resolved Hide resolved
@@ -120,6 +245,84 @@ extern "C"
#define EXTERN extern
#endif

#ifndef __ASSEMBLY__

/****************************************************************************
Copy link
Contributor

Choose a reason for hiding this comment

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

We cannot have APIs with riscv_ prefix in public arch.h, do we need these APIs ?

Copy link
Contributor Author

@no1wudi no1wudi Dec 16, 2024

Choose a reason for hiding this comment

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

How about change prefix to arch_?

Copy link
Contributor

Choose a reason for hiding this comment

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

public arch api should start with up_

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 Dec 16, 2024

Choose a reason for hiding this comment

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

but we only need move riscv_percpu_s to public heder files, all other definition can still keep in riscv_percpu.h

Copy link
Contributor

Choose a reason for hiding this comment

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

For example the stack pointers are needed immediately when entering exception_common. You cannot replace this functionality with anything else. I'm sorry, you need to think of something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about add a new option to control this behavior?

Allow the user to choose between using percpu registers to store the TCB to accelerate scheduling or maintaining the current functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess I don't have any objections to this. It can work in flat mode.

Btw you could use tp in protected / kernel mode (CONFIG_SYSCALL=y), just swap the user tp with CSR_SCRATCH->tcb in exception_common, and update tp when a context switch occurs. This way even the protected builds could enjoy the speed benefit?

Copy link
Contributor

Choose a reason for hiding this comment

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

why not always enable the acceleration to simplify the code base, I don't see other arch provide this type of flexibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, let's implement it for flat build first

arch/risc-v/include/arch.h Outdated Show resolved Hide resolved
arch/risc-v/include/arch.h Outdated Show resolved Hide resolved
arch/risc-v/include/arch.h Outdated Show resolved Hide resolved
arch/risc-v/include/arch.h Outdated Show resolved Hide resolved
arch/risc-v/include/irq.h Outdated Show resolved Hide resolved
arch/risc-v/include/irq.h Outdated Show resolved Hide resolved
@no1wudi no1wudi marked this pull request as ready for review December 16, 2024 01:45
@no1wudi no1wudi force-pushed the riscv branch 2 times, most recently from 92d1a27 to fdb91ee Compare December 16, 2024 04:31
@github-actions github-actions bot added Size: S The size of the change in this PR is small and removed Size: M The size of the change in this PR is medium labels Dec 16, 2024
@no1wudi no1wudi force-pushed the riscv branch 4 times, most recently from 21549c5 to e0334c0 Compare December 20, 2024 03:20
Fetch TCB info in percpu scratch register for better performance.

Signed-off-by: Huang Qi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Size: S The size of the change in this PR is small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants