kernel: let kwsnd periods go down to 2 ms, in a buffer of 10 ms or more (#22)

The shortest period and tick drop from 5 ms to 2 ms for programs that
ask for low latency. A buffer is 10 ms or more as before (two 5 ms
periods), and a late tick still hands over up to 15 ms' worth when ticks
are shorter than 5 ms, so a short period tolerates the same host stall.
Programs that leave the period to alsa-lib, plain aplay, OSS without
SETFRAGMENT and requests of 256 frames or more negotiate what they did;
snd_pcm_set_params() with a latency under 20 ms now gets four periods of
2.5 to 3.75 ms (measured on Node, 2026-11-24).

Co-authored-by: Adam Meghji <566793+adammeghji@users.noreply.github.com>
This commit is contained in:
Pooya Parsa
2026-11-24 16:25:03 +00:00
parent bc8ac778da
commit 951bb8e5dd
36 changed files with 88 additions and 75 deletions

View File

@@ -126,9 +126,10 @@ no mixer, no capture, no PCM timer, no `/proc/asound`.
which the host copies during the call and answers with the frames it has
queued.
- A kernel timer on the host's monotonic clock hands over the frames the
elapsed time is worth every 5-10 ms; no IRQ bit. A late tick hands over
at most three ticks' worth, and an underrun stops the stream, so nothing
spins.
elapsed time is worth every 2-10 ms (the period, 2 ms or more, in a
buffer of 10 ms or more); no IRQ bit. A late tick hands over at most
three ticks' worth (15 ms' worth when ticks are shorter than 5 ms), and
an underrun stops the stream, so nothing spins.
## kwvsock (AF_VSOCK)

View File

@@ -11,7 +11,7 @@
// Then wasm_driver_sound_event() reports each state change: open, prepare
// (rate, channels, ALSA format: 1 = U8, 2 = S16_LE), start, stop (with 1
// when the stream drained) and close. While the stream runs, a kernel timer
// on the host's monotonic clock (WASI clock_time_get) fires every 5 to 10
// on the host's monotonic clock (WASI clock_time_get) fires every 2 to 10
// ms and hands the frames the elapsed time is worth to
// wasm_driver_sound_write(addr, bytes), which copies them out of kernel
// memory during the call. The return value is how many frames the sink

View File

@@ -1,4 +1,4 @@
From b1bf6cc5d082b1505e1cea0252768ef4ac606418 Mon Sep 17 00:00:00 2001
From 56cc67bbc6080a15e42d6c8aa5d7a66c6d10657c Mon Sep 17 00:00:00 2001
From: Pooya Parsa <pooya@pi0.io>
Date: Sun, 15 Nov 2026 10:16:10 +0000
Subject: [PATCH] wasm: kwsnd, ALSA playback to the JavaScript host
@@ -8,10 +8,10 @@ when the host has audio (wasm_driver_sound_init() < 0 means none, so a
normal boot only pays for the code). With audio it is card 0 with one
PCM (hw:0,0: /dev/snd/pcmC0D0p and controlC0), no mixer and no capture:
U8 and S16_LE, mono or stereo, 8000-48000 Hz (continuous), up to 64 KiB
of buffer, periods of 5 ms or more. alsa-lib's default device for an
unknown card is plug:hw, so no PCM timer (dmix) is needed. The init
import also returns the host's preferred rate, which the card's long
name shows.
of buffer, periods of 2 ms or more in a buffer of 10 ms or more.
alsa-lib's default device for an unknown card is plug:hw, so no PCM
timer (dmix) is needed. The init import also returns the host's
preferred rate, which the card's long name shows.
Nothing runs and nothing beyond the card is allocated until a program
opens the PCM: the per-open state is allocated at open, and the ring is
@@ -20,17 +20,17 @@ hw_params), which is direct-mapped, so the host reads it at a plain
linear address and mmap works through remap_pfn_range.
An hrtimer on CLOCK_MONOTONIC (the host's monotonic clock) paces the
stream every 5 to 10 ms (the period time, clamped). Each tick hands the
stream every 2 to 10 ms (the period time, clamped). Each tick hands the
frames the elapsed time is worth to wasm_driver_sound_write(), which
copies them out during the call, and advances the hardware pointer by
as much; the host's return value (frames it still has queued) becomes
runtime->delay. Frames past appl_ptr are never sent unless the stream
fills silence: the pointer still advances, so the core sees an underrun
and stops the stream, and the host plays silence. A tick more than two
ticks late (a long stay in the kernel) advances by three ticks' worth
and skips the rest, so the queued frames play on at the normal pace
rather than being rushed out, and the pointer never moves by a whole
buffer.
and stops the stream, and the host plays silence. A late tick (a long
stay in the kernel) advances by three ticks' worth at most, or 15 ms'
worth with ticks shorter than 5 ms, and skips the rest, so the queued
frames play on at the normal pace rather than being rushed out, and the
pointer never moves by a whole buffer.
wasm_driver_sound_event() reports open, prepare (rate, channels,
format), start, stop (and whether it was the end of a drain) and close.
@@ -42,8 +42,8 @@ OSS PCM emulation (/dev/dsp, which static SDL 1.2 builds use) is 29 KiB
---
sound/drivers/Kconfig | 9 ++
sound/drivers/Makefile | 2 +
sound/drivers/kwsnd.c | 340 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 351 insertions(+)
sound/drivers/kwsnd.c | 351 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 362 insertions(+)
create mode 100644 sound/drivers/kwsnd.c
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
@@ -88,10 +88,10 @@ index a08bdd70ec9..a5abb0cf1ad 100644
obj-$(CONFIG_SND_PCMTEST) += snd-pcmtest.o
diff --git a/sound/drivers/kwsnd.c b/sound/drivers/kwsnd.c
new file mode 100644
index 00000000000..8f4e9138ec8
index 00000000000..a10a5442ac6
--- /dev/null
+++ b/sound/drivers/kwsnd.c
@@ -0,0 +1,340 @@
@@ -0,0 +1,351 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * kwsnd: ALSA playback to the JavaScript host (unkernel).
@@ -106,7 +106,7 @@ index 00000000000..8f4e9138ec8
+ * plain linear address.
+ *
+ * Playback is paced by an hrtimer on CLOCK_MONOTONIC, which is the host's
+ * monotonic clock (WASI clock_time_get), every 5 to 10 ms (the period time,
+ * monotonic clock (WASI clock_time_get), every 2 to 10 ms (the period time,
+ * clamped). Each tick works out how many frames the elapsed time is worth,
+ * hands that many frames of the ring to the host with
+ * wasm_driver_sound_write() (the host copies them out during the call) and
@@ -119,12 +119,13 @@ index 00000000000..8f4e9138ec8
+ * time is worth more than the queued frames, the pointer still advances
+ * (so the core sees the underrun and stops the stream, or, with silence
+ * filling as dmix uses, keeps running) but only the written part goes to
+ * the host, which plays silence for the rest. A tick that comes more than
+ * two ticks late (a long stay in the kernel, a host that did not run)
+ * advances by three ticks' worth at most and skips the rest of the missed
+ * time: the queued frames then play on at the normal pace instead of
+ * being rushed out, the program sees no underrun from the stall alone, and
+ * the pointer never moves by a whole buffer, which the core cannot see.
+ * the host, which plays silence for the rest. A tick that comes late (a
+ * long stay in the kernel, a host that did not run) advances by three
+ * ticks' worth at most (15 ms' worth with ticks shorter than 5 ms, so a
+ * short period tolerates the same stall) and skips the rest of the missed
+ * time: the queued frames then play on at the normal pace instead of being
+ * rushed out, the program sees no underrun from the stall alone, and the
+ * pointer never moves by a whole buffer, which the core cannot see.
+ *
+ * A tick reports to the core (snd_pcm_period_elapsed()) only when the
+ * pointer crossed a period boundary or reached appl_ptr (the end of a
@@ -157,8 +158,12 @@ index 00000000000..8f4e9138ec8
+#define KWSND_EV_START 3
+#define KWSND_EV_STOP 4 /* rate = 1 when the stream drained */
+
+#define KWSND_TICK_MIN_NS (5 * NSEC_PER_MSEC)
+#define KWSND_TICK_MIN_NS (2 * NSEC_PER_MSEC)
+#define KWSND_TICK_MAX_NS (10 * NSEC_PER_MSEC)
+/* The shortest buffer: a short period is no reason for less slack. */
+#define KWSND_BUFFER_MIN_NS (10 * NSEC_PER_MSEC)
+/* A late tick hands over this much at least, however short the tick. */
+#define KWSND_BURST_MIN_NS (15 * NSEC_PER_MSEC)
+
+/* Host imports, module "unkernel". None of them suspends. */
+/* < 0: no audio. Else the host's preferred rate in Hz (0: no preference). */
@@ -233,7 +238,7 @@ index 00000000000..8f4e9138ec8
+ want = due > s->played ? due - s->played : 0;
+ if (want > s->burst) {
+ /*
+ * Late by more than two ticks (a long stay in the kernel, a host
+ * Late by more than the burst (a long stay in the kernel, a host
+ * that did not run): skip the missed time instead of catching up,
+ * so the queued frames still play at the normal pace.
+ */
@@ -306,6 +311,11 @@ index 00000000000..8f4e9138ec8
+ SNDRV_PCM_HW_PARAM_PERIOD_TIME,
+ KWSND_TICK_MIN_NS / NSEC_PER_USEC,
+ UINT_MAX);
+ if (err >= 0)
+ err = snd_pcm_hw_constraint_minmax(runtime,
+ SNDRV_PCM_HW_PARAM_BUFFER_TIME,
+ KWSND_BUFFER_MIN_NS / NSEC_PER_USEC,
+ UINT_MAX);
+ if (err < 0) {
+ kfree(s);
+ return err;
@@ -335,7 +345,8 @@ index 00000000000..8f4e9138ec8
+ hrtimer_cancel(&s->timer);
+ s->tick_ns = clamp_t(u64, period_ns, KWSND_TICK_MIN_NS, KWSND_TICK_MAX_NS);
+ s->burst = min_t(u64, runtime->buffer_size - 1,
+ div_u64(3 * s->tick_ns * runtime->rate, NSEC_PER_SEC));
+ div_u64(max_t(u64, 3 * s->tick_ns, KWSND_BURST_MIN_NS) *
+ runtime->rate, NSEC_PER_SEC));
+ runtime->delay = 0;
+ wasm_driver_sound_event(KWSND_EV_PREPARE, runtime->rate,
+ runtime->channels, runtime->format);

View File

@@ -1,4 +1,4 @@
From a50ea4cda9c9b4004b66fc61c948dd372437dc53 Mon Sep 17 00:00:00 2001
From fa5bcc8253ffe215d39d1bb0244ace647746ed63 Mon Sep 17 00:00:00 2001
From: Pooya Parsa <pooya@pi0.io>
Date: Sun, 15 Nov 2026 10:16:10 +0000
Subject: [PATCH] wasm: kwvsock, an AF_VSOCK transport to the JavaScript host

View File

@@ -1,4 +1,4 @@
From 9aa6c1c656df8a61db109525af8bc0470576d86f Mon Sep 17 00:00:00 2001
From c33d4ae4c0c7a841b107ec99efc26b55757a13ee Mon Sep 17 00:00:00 2001
From: Pooya Parsa <pooya@pi0.io>
Date: Sun, 15 Nov 2026 10:16:10 +0000
Subject: [PATCH] wasm: kwshm, host access to the pages of shmem files

View File

@@ -1,4 +1,4 @@
From aeeb20e82fc895b06eec63a4eb8ce946937c8f2c Mon Sep 17 00:00:00 2001
From 760e6488d7ed3baea94243a786bb0f634ebe8c26 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Sat, 21 Nov 2026 18:55:03 +0000
Subject: [PATCH] wasm: kwvirtio, a virtio transport to the JavaScript host

View File

@@ -1,4 +1,4 @@
From 5708992022afc0624e39016ad2552d5fec2cf70c Mon Sep 17 00:00:00 2001
From 35a1567525d86d3e493c5a80cc471546e26443b4 Mon Sep 17 00:00:00 2001
From: Pooya Parsa <pooya@pi0.io>
Date: Sun, 15 Nov 2026 13:43:35 +0000
Subject: [PATCH] wasm: park every task and resume it on a fresh stack, and

View File

@@ -1,4 +1,4 @@
From 8674181a80bcd064b1fac2b276d7764e39fba4bb Mon Sep 17 00:00:00 2001
From 5522cd888c956d26b761391fc586fe230dec7e68 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Sun, 15 Nov 2026 14:41:37 +0000
Subject: [PATCH] wasm: kwvsock: reset connections after a snapshot restore

View File

@@ -1,4 +1,4 @@
From 44885b0596c2ae4d63699bd02b16f3e0d84b6502 Mon Sep 17 00:00:00 2001
From 13fcbbc8f815731f09d3deaf9a4bed577a44c99e Mon Sep 17 00:00:00 2001
From: Pooya Parsa <pooya@pi0.io>
Date: Sun, 15 Nov 2026 10:16:10 +0000
Subject: [PATCH] wasm: add kw_defconfig

View File

@@ -1,4 +1,4 @@
From 7c303d3de8eb7e084b08665e8a383877d060b63d Mon Sep 17 00:00:00 2001
From f35605c1abbe6b8def3a27a94151484045d9191e Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 13:12:25 +0000
Subject: [PATCH] wasm: optional atomics and shared-memory builds (KW_ATOMICS,

View File

@@ -1,4 +1,4 @@
From 79e481ce724f19475cd5f2f01cc76ac40a0f466d Mon Sep 17 00:00:00 2001
From f9b6646346065d22b151c0771a1a0d52a32ff8c1 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 14:54:54 +0000
Subject: [PATCH] wasm: make atomic_read and atomic_set plain accesses

View File

@@ -1,4 +1,4 @@
From 4070a45f95f1b20d6f88cf86e39d44a04049ab54 Mon Sep 17 00:00:00 2001
From 705d1a6d1ef892c79a22eb41e8ec22cc0c7a7937 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 14:54:54 +0000
Subject: [PATCH] mm: skip folio_ref_add() of zero when mapping an order-0

View File

@@ -1,4 +1,4 @@
From e367c1409e80f327f1433f412687aec96a92ae04 Mon Sep 17 00:00:00 2001
From f72f7b8d8130ec9186f4de5244053d704bb59ef2 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 16:06:57 +0000
Subject: [PATCH] mm: allow percpu-km on SMP with a flat vmalloc

View File

@@ -1,4 +1,4 @@
From 906870a61ecb7afff6b82b9094301ca3ebfcab63 Mon Sep 17 00:00:00 2001
From cbc6b4684681307adfeca73eb0bc8d489a079231 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 16:06:57 +0000
Subject: [PATCH] sched: let an arch hold tasks on their CPU except where they

View File

@@ -1,4 +1,4 @@
From 3c9007f024a2deb4261e2baaa5b383c3ca0e865f Mon Sep 17 00:00:00 2001
From 92ce9c81b5c246d114c55f3ca79786ed942ca5cd Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 16:06:57 +0000
Subject: [PATCH] kthread, workqueue: restart points for ARCH_TASKS_STAY_ON_CPU

View File

@@ -1,4 +1,4 @@
From e1fe174c6f737734a1eb051acfca0c4db3ce82c1 Mon Sep 17 00:00:00 2001
From f43d410db3a2730d9125dca3c3d9019ffff5228d Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 23:07:54 +0000
Subject: [PATCH] smp: let an arch wait for a csd and wake its waiter

View File

@@ -1,4 +1,4 @@
From 3bb4d10b58a68042410cdbb0dbff6e5b2ec89fcc Mon Sep 17 00:00:00 2001
From f44accde67e0ded2323f21b81091e5e17d0db80b Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 16:07:10 +0000
Subject: [PATCH] wasm: SMP

View File

@@ -1,4 +1,4 @@
From 44f27c58da220ee20ba3f8462b3d5a667d07aa5a Mon Sep 17 00:00:00 2001
From 6e055af643c4e4b34c7046647c82d178adb45f50 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 16:07:10 +0000
Subject: [PATCH] wasm: host devices on SMP
@@ -415,10 +415,10 @@ index 90cb8521bb3..4c088366a0c 100644
err_irq:
diff --git a/sound/drivers/kwsnd.c b/sound/drivers/kwsnd.c
index 8f4e9138ec8..d8e0be82cbb 100644
index a10a5442ac6..31da6ef241c 100644
--- a/sound/drivers/kwsnd.c
+++ b/sound/drivers/kwsnd.c
@@ -306,6 +306,11 @@ static int __init kwsnd_init(void)
@@ -317,6 +317,11 @@ static int __init kwsnd_init(void)
pr_info("kwsnd: no host audio\n");
return 0;
}

View File

@@ -1,4 +1,4 @@
From 3cd70ba641ac8ac093edf044c9f3a19fd48e4a77 Mon Sep 17 00:00:00 2001
From 4e6b087a61f3bd4f1e5cea90cc997d047fe37cda Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 20:16:02 +0000
Subject: [PATCH] wasm: kwblk on SMP

View File

@@ -1,4 +1,4 @@
From 83653ca4be0510d085a32b5f7484a54f9669faed Mon Sep 17 00:00:00 2001
From 4b1dbb2c2fbff53182a0b06f35e9a64aee0bc95c Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 20:16:03 +0000
Subject: [PATCH] wasm: kwshm on SMP

View File

@@ -1,4 +1,4 @@
From 8d66fafc644e76c693d0e3073e4a73711b58a293 Mon Sep 17 00:00:00 2001
From f072f697f344946b7b561ef6da3d5297747836b3 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 20:16:03 +0000
Subject: [PATCH] wasm: kwfb on SMP

View File

@@ -1,4 +1,4 @@
From 63b271f1f206785790161c59ac02e2481f73a4ba Mon Sep 17 00:00:00 2001
From 28a57039959326d283cc0a6db686d8e35e3804cb Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 20:16:04 +0000
Subject: [PATCH] wasm: kwinput on SMP

View File

@@ -1,4 +1,4 @@
From c3056b2ff073ce2661180ca268258a953409cd1b Mon Sep 17 00:00:00 2001
From f66f70884db8db0ea2e9b29e46104fd17b61c43f Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 20:16:04 +0000
Subject: [PATCH] wasm: kwsnd on SMP
@@ -16,10 +16,10 @@ before its frames. The UP build is unchanged.
1 file changed, 113 insertions(+), 9 deletions(-)
diff --git a/sound/drivers/kwsnd.c b/sound/drivers/kwsnd.c
index d8e0be82cbb..403d3a76805 100644
index 31da6ef241c..337214a630f 100644
--- a/sound/drivers/kwsnd.c
+++ b/sound/drivers/kwsnd.c
@@ -45,6 +45,14 @@
@@ -46,6 +46,14 @@
* The host is told about every state change with wasm_driver_sound_event():
* open, prepare (rate, channels, format), start, stop (drain or not) and
* close. No import suspends.
@@ -34,7 +34,7 @@ index d8e0be82cbb..403d3a76805 100644
*/
#include <linux/hrtimer.h>
@@ -52,6 +60,7 @@
@@ -53,6 +61,7 @@
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -42,7 +42,7 @@ index d8e0be82cbb..403d3a76805 100644
#include <sound/core.h>
#include <sound/pcm.h>
#include <asm/wasm.h>
@@ -85,8 +94,75 @@ struct kwsnd_stream {
@@ -90,8 +99,75 @@ struct kwsnd_stream {
u64 tick_ns;
u32 burst; /* most frames one tick hands over */
bool running;
@@ -118,7 +118,7 @@ index d8e0be82cbb..403d3a76805 100644
static const struct snd_pcm_hardware kwsnd_hw = {
.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER,
@@ -131,6 +207,9 @@ static enum hrtimer_restart kwsnd_tick(struct hrtimer *timer)
@@ -136,6 +212,9 @@ static enum hrtimer_restart kwsnd_tick(struct hrtimer *timer)
unsigned long flags;
snd_pcm_stream_lock_irqsave(s->substream, flags);
@@ -128,7 +128,7 @@ index d8e0be82cbb..403d3a76805 100644
if (!s->running)
goto stopped;
@@ -217,7 +296,10 @@ static int kwsnd_open(struct snd_pcm_substream *substream)
@@ -227,7 +306,10 @@ static int kwsnd_open(struct snd_pcm_substream *substream)
return err;
}
runtime->private_data = s;
@@ -140,7 +140,7 @@ index d8e0be82cbb..403d3a76805 100644
return 0;
}
@@ -225,9 +307,16 @@ static int kwsnd_close(struct snd_pcm_substream *substream)
@@ -235,9 +317,16 @@ static int kwsnd_close(struct snd_pcm_substream *substream)
{
struct kwsnd_stream *s = substream->runtime->private_data;
@@ -157,7 +157,7 @@ index d8e0be82cbb..403d3a76805 100644
return 0;
}
@@ -238,13 +327,16 @@ static int kwsnd_prepare(struct snd_pcm_substream *substream)
@@ -248,14 +337,17 @@ static int kwsnd_prepare(struct snd_pcm_substream *substream)
u64 period_ns = div_u64((u64)runtime->period_size * NSEC_PER_SEC,
runtime->rate);
@@ -167,7 +167,8 @@ index d8e0be82cbb..403d3a76805 100644
hrtimer_cancel(&s->timer);
s->tick_ns = clamp_t(u64, period_ns, KWSND_TICK_MIN_NS, KWSND_TICK_MAX_NS);
s->burst = min_t(u64, runtime->buffer_size - 1,
div_u64(3 * s->tick_ns * runtime->rate, NSEC_PER_SEC));
div_u64(max_t(u64, 3 * s->tick_ns, KWSND_BURST_MIN_NS) *
runtime->rate, NSEC_PER_SEC));
runtime->delay = 0;
- wasm_driver_sound_event(KWSND_EV_PREPARE, runtime->rate,
- runtime->channels, runtime->format);
@@ -176,7 +177,7 @@ index d8e0be82cbb..403d3a76805 100644
return 0;
}
@@ -264,12 +356,29 @@ static int kwsnd_trigger(struct snd_pcm_substream *substream, int cmd)
@@ -275,12 +367,29 @@ static int kwsnd_trigger(struct snd_pcm_substream *substream, int cmd)
s->played = 0;
s->pos0 = runtime->status->hw_ptr % runtime->buffer_size;
s->running = true;
@@ -207,7 +208,7 @@ index d8e0be82cbb..403d3a76805 100644
wasm_driver_sound_event(KWSND_EV_STOP,
runtime->state == SNDRV_PCM_STATE_DRAINING,
0, 0);
@@ -306,11 +415,6 @@ static int __init kwsnd_init(void)
@@ -317,11 +426,6 @@ static int __init kwsnd_init(void)
pr_info("kwsnd: no host audio\n");
return 0;
}

View File

@@ -1,4 +1,4 @@
From 21c584d5fec5803098ebcb2829830433dc4f1bc4 Mon Sep 17 00:00:00 2001
From 2f7d1db260dc6bf80d3e89784a17f53f8ce752a5 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Sat, 21 Nov 2026 18:55:03 +0000
Subject: [PATCH] wasm: kwvirtio on SMP

View File

@@ -1,4 +1,4 @@
From c5b794ce5f619aa14e9294ce04feacbcf06f6c81 Mon Sep 17 00:00:00 2001
From a344a230ff57b724438bf0c29756c02fcbf78716 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 16 Nov 2026 23:07:54 +0000
Subject: [PATCH] wasm: block instead of spinning for another CPU (SMP)

View File

@@ -1,4 +1,4 @@
From 0b3add7f4bf282a9730a0a44ebb4a155e38e44d0 Mon Sep 17 00:00:00 2001
From 125a53758d516849f6de75ccc9b4441d4e7576f0 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Tue, 17 Nov 2026 09:05:49 +0000
Subject: [PATCH] wasm: take a free spinlock out of turn (kw_spin_unfair=, SMP)

View File

@@ -1,4 +1,4 @@
From 2c81bcbefbb1e03aab3c7bd59b169ffa2e959956 Mon Sep 17 00:00:00 2001
From 56adecd2c6df603b2124fa4ad4faa1d040a98379 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Tue, 17 Nov 2026 14:38:17 +0000
Subject: [PATCH] wasm: do not wait for a CPU that compiles or yields to its

View File

@@ -1,4 +1,4 @@
From 677502fde4d8dc803e243a46afa7a669c8dd68a1 Mon Sep 17 00:00:00 2001
From 65c070a26fb86085e2de5690224db0cf9902b5ce Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Fri, 20 Nov 2026 08:27:30 +0000
Subject: [PATCH] wasm: parking and snapshots on SMP

View File

@@ -1,4 +1,4 @@
From c633e79036bb1dbaa575ac43771ba69fbc565f54 Mon Sep 17 00:00:00 2001
From cf23a1bff0334f6057167e98fbb2db2210c5b197 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Wed, 18 Nov 2026 21:04:24 +0000
Subject: [PATCH] wasm: run arm64 user space

View File

@@ -1,4 +1,4 @@
From aedd4301393056e3b0d2f933f491fd7a7e11fea2 Mon Sep 17 00:00:00 2001
From 5d0826c6eb1723e9aa65198d316611c75b7f73ca Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Fri, 20 Nov 2026 16:38:40 +0000
Subject: [PATCH] wasm: guest pc sampling for the host

View File

@@ -1,4 +1,4 @@
From 2d46ebfca2f3d9bcae3558ffd3efd6df6b914cb7 Mon Sep 17 00:00:00 2001
From 0eb29ae81edfe8d7a4c801a11dddcbaf919c9d3d Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 23 Nov 2026 09:01:35 +0000
Subject: [PATCH] wasm: give each CPU's word of pending interrupts 128 bytes

View File

@@ -1,4 +1,4 @@
From d2806628f8b8ccbb62161e2d49add14a730fd707 Mon Sep 17 00:00:00 2001
From 0a59939c6120b107d31643e3e09baf27eb16556a Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 23 Nov 2026 22:47:49 +0000
Subject: [PATCH] wasm: ptrace register sets in arm64's layouts

View File

@@ -1,4 +1,4 @@
From 1aa0ce50c13a457311e6ab6ffd245d91944d0025 Mon Sep 17 00:00:00 2001
From b969c2d110d8d99f2e63775d641ef6a9c37f3384 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 23 Nov 2026 22:48:26 +0000
Subject: [PATCH] wasm: make the kernel's writes into user code visible to

View File

@@ -1,4 +1,4 @@
From 58a0f1855c13844dc331e0e516cbf19e30f138b7 Mon Sep 17 00:00:00 2001
From e8390b7a936c0f1189ac0640790d22b5d3e7ddc7 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 23 Nov 2026 22:49:19 +0000
Subject: [PATCH] wasm: single-step user mode for ptrace

View File

@@ -1,4 +1,4 @@
From c9a684915fedf524eff12a98305322cdb970c004 Mon Sep 17 00:00:00 2001
From dec59e088d617b262c5d6226e8c6d340e1319dc2 Mon Sep 17 00:00:00 2001
From: kernel-wasm <kernel-wasm@localhost>
Date: Mon, 23 Nov 2026 23:00:37 +0000
Subject: [PATCH] wasm: core dumps

View File

@@ -3,7 +3,7 @@
// The guest's sound on the page (kwsnd; on unless ?sound=0): a SoundSink
// for the SDK (js/core/sound.ts) that plays the PCM with Web Audio.
//
// - The kernel hands over PCM from a timer every 5-10 ms, from inside a
// - The kernel hands over PCM from a timer every 2-10 ms, from inside a
// synchronous import, while the main thread is busy running the guest
// (it only gets back to its event loop at the kernel's 20 ms yields and
// when idle). So the chunks are posted at once to an AudioWorklet, whose