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

rpmsg_virtio.c: replace metal_cpu_yield to metal_yield #613

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

Conversation

wyr-7
Copy link
Contributor

@wyr-7 wyr-7 commented Sep 18, 2024

The CPU yield is not supported by all OSes/processors. If not supported, this causes a busy loop that monopolizes the CPU. Replace it with the new metal_yield, it would be managed at the OS level and dispatched to metal_cpu_yield, metal_sleep_usec, or others.

@wyr-7 wyr-7 force-pushed the replace_metal_cpu_yield branch 2 times, most recently from fd55a2d to 01ed340 Compare September 19, 2024 07:15
Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

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

This PR seems valid to me. We should not have the CPU yield notion in OpenAMP. Waiting 1 ms is more generic, and seems enough.

Please rework your commit message to something more generic.

Commit proposal:

The CPU yield is not supported by all OSes/processors. If not supported, this causes
a busy loop that monopolizes the CPU. Replace it with metal_sleep_usec, which is
OS-dependent and allows the OS scheduler to switch to another thread.

lib/rpmsg/rpmsg_virtio.c Outdated Show resolved Hide resolved
lib/rpmsg/rpmsg_virtio.c Outdated Show resolved Hide resolved
@wyr-7 wyr-7 force-pushed the replace_metal_cpu_yield branch 2 times, most recently from 3e2d89a to 66b0ca4 Compare September 23, 2024 07:56
Copy link
Contributor

@edmooring edmooring left a comment

Choose a reason for hiding this comment

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

I disagree with this change. It overrides decisions made in

  • lib/processor/cpu/hosted.h
  • lib/processor/cpu/x86.h
  • lib/processor/cpu/aarch64.h

which could surprise current users of the library.
I think changing the implementation of metal_cpu_yield() in lib/processor/generic/cpu.h to use metal_sleep_usec() would solve the same problem, with fewer surprises to our current users.

@arnopo
Copy link
Collaborator

arnopo commented Oct 4, 2024

We discussed this with @edmooring. He is right; it is more flexible to manage this in libmetal. As metal_cpu_yield is processor-dependent, the proposal is to create a new libmetal API metal_yield.

metal_yield would be managed at the OS level and dispatched to metal_cpu_yield, metal_sleep_usec, or others.

@wyr-7
Copy link
Contributor Author

wyr-7 commented Oct 8, 2024

We discussed this with @edmooring. He is right; it is more flexible to manage this in libmetal. As metal_cpu_yield is processor-dependent, the proposal is to create a new libmetal API metal_yield.

metal_yield would be managed at the OS level and dispatched to metal_cpu_yield, metal_sleep_usec, or others.

We discussed this with @edmooring. He is right; it is more flexible to manage this in libmetal. As metal_cpu_yield is processor-dependent, the proposal is to create a new libmetal API metal_yield.

metal_yield would be managed at the OS level and dispatched to metal_cpu_yield, metal_sleep_usec, or others.

Ok, add metal_yield() in pr:OpenAMP/libmetal#311, this pr is denpends on it.

@arnopo arnopo requested a review from edmooring October 8, 2024 08:40
@arnopo arnopo changed the title rpmsg_virtio.c: replace metal_cpu_yield to metal_sleep_usec rpmsg_virtio.c: replace metal_cpu_yield to metal_yield Oct 8, 2024
Copy link
Contributor

@edmooring edmooring left a comment

Choose a reason for hiding this comment

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

The change itself looks good. The commit message needs to be changed to match the new implementation. It could be as simple as "Replace it with the new metal_yield(),".

The CPU yield is not supported by all OSes/processors. If not supported,
this causes a busy loop that monopolizes the CPU. Replace it with the
new metal_yield, it would be managed at the OS level and dispatched to
metal_cpu_yield, metal_sleep_usec, or others.

Signed-off-by: Yongrong Wang <[email protected]>
@wyr-7
Copy link
Contributor Author

wyr-7 commented Oct 9, 2024

The change itself looks good. The commit message needs to be changed to match the new implementation. It could be as simple as "Replace it with the new metal_yield(),".

Ok, thanks, done.

Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

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

LGTM to rebase after OpenAMP/libmetal#311 integration to pass the CI

@arnopo arnopo requested a review from edmooring October 9, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants