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

zynq7000: SMP kernel #548

Merged
merged 7 commits into from
Jul 2, 2024
Merged

zynq7000: SMP kernel #548

merged 7 commits into from
Jul 2, 2024

Conversation

jmaksymowicz
Copy link
Contributor

@jmaksymowicz jmaksymowicz commented May 10, 2024

Allows tasks to be scheduled on both CPU cores on zynq7000 platform.

Description

NOTE: the corresponding PR in PLO must be merged first - otherwise on zynq7000 kernel will hang waiting for other CPU cores which will never start.

Code is capable of detecting number of available CPUs at runtime, the NUM_CPUS constant is used as maximum number of CPUs to prepare for.

One change was made not related to SMP: size of page directories was changed from 0x4000 bytes to 0x2000 bytes, as the upper half was unnecessary

Memory attributes were changed in common armv7a code, which affects imx6ull (but should not cause significant change).

Using SMP on armv7a9-zynq7000-qemu causes drastic slowdown (about 4x-5x slower) when executing single-core workloads. This is because under QEMU the idle thread creates a lot of load on the host CPU, as well as contention on the timer spinlock. This slowdown does not occur on real hardware. For this reason I suggest limiting QEMU to emulating only one core, as we can test SMP configurations on real hardware.

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: armv7a9-zynq7000-zturn, armv7a9-zynq7000-qemu

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

hal/armv7a/pmap.c Outdated Show resolved Hide resolved
hal/armv7a/zynq7000/_init.S Outdated Show resolved Hide resolved
hal/armv7a/zynq7000/_init.S Outdated Show resolved Hide resolved
hal/armv7a/zynq7000/_init.S Outdated Show resolved Hide resolved
Copy link

github-actions bot commented May 13, 2024

Unit Test Results

7 460 tests  +724   6 745 ✅ +695   39m 33s ⏱️ + 6m 14s
  420 suites ±  0     715 💤 + 75 
    1 files   ±  0       0 ❌  -  46 

Results for commit b1884db. ± Comparison against base commit 47ac14e.

This pull request removes 20 and adds 744 tests. Note that renamed tests count towards both.
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit
phoenix-rtos-tests/libc/exit ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/exit
phoenix-rtos-tests/libc/math ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/math
phoenix-rtos-tests/libc/misc ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/misc
phoenix-rtos-tests/libc/pthread ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/pthread
phoenix-rtos-tests/libc/scanf ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/scanf
phoenix-rtos-tests/libc/stdio ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/stdio
phoenix-rtos-tests/libc/stdlib ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/stdlib
phoenix-rtos-tests/libc/string ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/string
phoenix-rtos-tests/libc/time ‑ riscv64-generic-qemu:phoenix-rtos-tests/libc/time
…
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_in
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_in_big
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_inout
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_inout_big
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_out
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.data_out_big
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.in_val
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.invalid_req
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.no_data
phoenix-rtos-tests/ioctl/unit ‑ riscv64-generic-qemu:phoenix-rtos-tests/ioctl/unit.ioctl.not_valid_fd
…

♻️ This comment has been updated with latest results.

@jmaksymowicz jmaksymowicz changed the title WIP zynq7000: SMP kernel zynq7000: SMP kernel May 17, 2024
hal/armv7a/_interrupts.S Show resolved Hide resolved
hal/armv7a/arch/cpu.h Show resolved Hide resolved
hal/armv7a/zynq7000/zynq.c Outdated Show resolved Hide resolved
hal/armv7a/zynq7000/zynq.c Outdated Show resolved Hide resolved
@jmaksymowicz jmaksymowicz force-pushed the jmaksymowicz/zynq7000-smp branch 2 times, most recently from 9519331 to 9871ea2 Compare May 24, 2024 12:45
@jmaksymowicz jmaksymowicz force-pushed the jmaksymowicz/zynq7000-smp branch 2 times, most recently from 7cd9b24 to 7d80140 Compare May 24, 2024 15:42
agkaminski
agkaminski previously approved these changes May 27, 2024
@jmaksymowicz
Copy link
Contributor Author

jmaksymowicz commented Jun 21, 2024

Reverted change that activated L2 cache - it caused stability problems in some tests. I haven't found the reason for it yet. Because it's not necessary for SMP I think we should do it in a different PR.

EDIT: it didn't help, only reduced frequency of failing

Darchiv
Darchiv previously approved these changes Jun 25, 2024
Move memory barrier in spinlock clear operation
zynq7000: Add memory barriers to SLCR locking/unlocking

JIRA: RTOS-796
Page directories were previously 0x4000 bytes, but the upper half
was never used by the hardware - only by pmap_resolve().
pmap_resolve() behavior was modified to closer align with how hardware
resolves virtual memory addresses.

JIRA: RTOS-796
Add scheduler lock
Add TLB management broadcast functions
Implement correct CPU ID and CPU count functions
Add inter-processor interrupt
Add core count to CPU info print at startup

JIRA: RTOS-796
Set memory as shareable and enable write-allocate - needed for SMP
Change AP values of 110 into 111 - previous value is deprecated

JIRA: RTOS-796
Activate SCU and cache/TLB mainenance broadcast

JIRA: RTOS-796
Allow interrupts to run on any core
Schedule timer interrupt in a round-robin fashion across both cores
Adjust timer to keep the current scheduling period on both cores

JIRA: RTOS-796
@Darchiv Darchiv merged commit 041233c into master Jul 2, 2024
30 checks passed
@Darchiv Darchiv deleted the jmaksymowicz/zynq7000-smp branch July 2, 2024 11:31
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.

3 participants