diff options
| author | Takashi Iwai <tiwai@suse.de> | 2026-08-10 15:37:06 +0200 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2026-08-10 17:44:34 +0200 |
| commit | 0252ad169c5eb8d9cfd2ee646a7cd055865e1f12 (patch) | |
| tree | 47ad7eb0b57627bf0007759010b48f9ab4dd71dd /tools/perf/scripts/python/bin | |
| parent | 7ffa5d2462dcf307746a79e959ceac6cd5828bfe (diff) | |
ALSA: seq: Use RCU for the UMP client output substream
The UMP sequencer client protects its output rawmidi file (out_rfile)
with an rwlock (output_lock). seq_ump_process_event(), the port's
event_input callback, reads out_rfile.output under read_lock on every
delivered UMP event, while the open/close paths (serialized by
ump->open_mutex) publish and clear out_rfile under write_lock.
Output is opened/closed only on the subscribe/use lifecycle while
delivery happens per event, so this is another read-mostly hot path.
Convert it to RCU and drop the rwlock. out_rfile is an embedded struct
rather than a pointer, so instead of restructuring it, add an
RCU-protected shadow of the substream (out_substream) for the reader;
out_rfile itself becomes writer-only state accessed solely under
open_mutex. The reader now runs lock-free under rcu_read_lock() via
rcu_dereference(), and open publishes the substream with
rcu_assign_pointer().
On close the substream is cleared with rcu_assign_pointer(NULL) and the
rawmidi is released only after synchronize_rcu(), so no reader in the
delivery path can still be writing to the substream when
snd_rawmidi_kernel_release() runs.
Dropping write_lock_irqsave() from the writers is safe: they run in
process context under open_mutex, and the sole atomic reader now uses
RCU, which is IRQ-safe.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260810133711.42483-6-tiwai@suse.de
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions
