From bb5ad12e438fde2e53580c2e2949c88d94dc6d92 Mon Sep 17 00:00:00 2001 From: LekKit <50500857+LekKit@users.noreply.github.com> Date: Sat, 23 Mar 2024 13:34:22 +0200 Subject: [PATCH] Ports: Update rvvm to 0.6 - New upstream stable version is available - Networking is now fully stable and enabled by default - SDL2 backend is now available alongside SDL1, so switch to it - Fixed a name collision of PAGE_SIZE with Serenity headers - Disable threaded IO on Serenity for now - Many other changes and fixes - See https://github.com/LekKit/RVVM/releases/tag/v0.6 for more --- Ports/AvailablePorts.md | 2 +- Ports/rvvm/package.sh | 12 ++-- ...0001-Disable-threaded-IO-on-Serenity.patch | 60 +++++++++++++++++++ Ports/rvvm/patches/ReadMe.md | 19 ++++++ 4 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 Ports/rvvm/patches/0001-Disable-threaded-IO-on-Serenity.patch create mode 100644 Ports/rvvm/patches/ReadMe.md diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index 55b038588a74d2..dd17508b6d55ad 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -280,7 +280,7 @@ This list is also available at [ports.serenityos.net](https://ports.serenityos.n | [`rsync`](rsync/) | rsync | 3.2.7 | https://rsync.samba.org/ | | [`rubberband`](rubberband/) | Rubberband | 3.3.0 | https://breakfastquay.com/rubberband/ | | [`ruby`](ruby/) | Ruby | 3.2.2 | https://www.ruby-lang.org/ | -| [`rvvm`](rvvm/) | RVVM - The RISC-V Virtual Machine | 0.5 | https://github.com/LekKit/RVVM | +| [`rvvm`](rvvm/) | RVVM - The RISC-V Virtual Machine | 0.6 | https://github.com/LekKit/RVVM | | [`sam`](sam/) | Software Automatic Mouth (SAM) | c86ea39 | https://github.com/vidarh/SAM | | [`scummvm`](scummvm/) | ScummVM | 2.8.0 | https://www.scummvm.org/ | | [`sdl12-compat`](sdl12-compat/) | SDL2 compatibility layer for SDL 1.2 games | 1.2.64 | https://github.com/libsdl-org/sdl12-compat/ | diff --git a/Ports/rvvm/package.sh b/Ports/rvvm/package.sh index 9cfabd1c809c5c..31293e148df263 100755 --- a/Ports/rvvm/package.sh +++ b/Ports/rvvm/package.sh @@ -1,18 +1,18 @@ #!/usr/bin/env -S bash ../.port_include.sh + port='rvvm' -version='0.5' -archive_hash='3a1dbb91ad04f068078bc6c6c27cc5792eebc111907cb5a14bde158fe6e757c9' +version='0.6' +archive_hash='97e98c95d8785438758b81fb5c695b8eafb564502c6af7f52555b056e3bb7d7a' files=( "https://github.com/LekKit/RVVM/archive/v${version}.tar.gz#${archive_hash}" ) workdir="RVVM-${version}" -depends=('sdl12-compat') +depends=('SDL2') build_opts=( - 'GIT_COMMIT=76796ba' + 'GIT_COMMIT=f937fd8' 'OS=SerenityOS' - 'USE_NET=1' - 'USE_SDL=1' + 'USE_SDL=2' ) makeopts+=("${build_opts[@]}" 'all' 'lib') installopts+=("${build_opts[@]}") diff --git a/Ports/rvvm/patches/0001-Disable-threaded-IO-on-Serenity.patch b/Ports/rvvm/patches/0001-Disable-threaded-IO-on-Serenity.patch new file mode 100644 index 00000000000000..05a053267a19b8 --- /dev/null +++ b/Ports/rvvm/patches/0001-Disable-threaded-IO-on-Serenity.patch @@ -0,0 +1,60 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: LekKit <50500857+LekKit@users.noreply.github.com> +Date: Sat, 23 Mar 2024 13:31:42 +0200 +Subject: [PATCH] Disable threaded IO on Serenity + +Due to sloppy scheduler/threading behavior on Serenity, +threaded IO is disabled in this port for now. +Otherwise U-Boot randomly fails to read data from NVMe, +or fails to initialize NVMe altogether, along with other IO +issues in guests - all due to threaded tasks being randomly +delayed for very long. + +I am not an expert on how scheduler works in Serenity, +so I am unable to fix it yet. +This problem was also visible in previous v0.5 version of this port, +but back then I thought it's some kind of a temporary problem. +Couldn't reproduce this on any other host OS. +--- + src/threading.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/src/threading.c b/src/threading.c +index 98883ede4fe63faf6b328e427fc1be9e5114c445..705749ca60092ddc42f07ff19d8a66bce797dc80 100644 +--- a/src/threading.c ++++ b/src/threading.c +@@ -318,6 +318,12 @@ void condvar_free(cond_var_t* cond) + + // Threadpool task offloading + ++// Serenity has serious scheduler issues that cause threadpool to ++// perform very poorly when vCPU is not sleeping. ++// Basically a thread that uses 100% of CPU on Serenity somehow ++// monopolizes host CPU so threadpool/eventloop tasks are timing out. ++ ++#ifndef __serenity__ + #define WORKER_THREADS 4 + #define WORKQUEUE_SIZE 2048 + #define WORKQUEUE_MASK (WORKQUEUE_SIZE - 1) +@@ -440,8 +446,11 @@ static void* threadpool_worker(void* ptr) + return ptr; + } + ++#endif ++ + static bool thread_queue_task(thread_func_t func, void** arg, unsigned arg_count, bool va) + { ++#ifndef __serenity__ + DO_ONCE ({ + atomic_store_uint32_ex(&pool_run, 1, ATOMIC_RELAXED); + workqueue_init(&pool_wq); +@@ -461,6 +470,9 @@ static bool thread_queue_task(thread_func_t func, void** arg, unsigned arg_count + // Still not queued! + // Assuming entire threadpool is busy, just do a blocking task + DO_ONCE(rvvm_warn("Blocking on workqueue task %p", func)); ++#else ++ UNUSED(func); UNUSED(arg); UNUSED(arg_count); UNUSED(va); ++#endif + return false; + } + diff --git a/Ports/rvvm/patches/ReadMe.md b/Ports/rvvm/patches/ReadMe.md new file mode 100644 index 00000000000000..76f57e2839920d --- /dev/null +++ b/Ports/rvvm/patches/ReadMe.md @@ -0,0 +1,19 @@ +# Patches for rvvm on SerenityOS + +## `0001-Disable-threaded-IO-on-Serenity.patch` + +Disable threaded IO on Serenity + +Due to sloppy scheduler/threading behavior on Serenity, +threaded IO is disabled in this port for now. +Otherwise U-Boot randomly fails to read data from NVMe, +or fails to initialize NVMe altogether, along with other IO +issues in guests - all due to threaded tasks being randomly +delayed for very long. + +I am not an expert on how scheduler works in Serenity, +so I am unable to fix it yet. +This problem was also visible in previous v0.5 version of this port, +but back then I thought it's some kind of a temporary problem. +Couldn't reproduce this on any other host OS. +