rtdm/nrtsig: Move inband work description off the stack
PATCH 1/1 rtdm/nrtsig: Move inband work description off the stack
From: Jan Kiszka <[email protected]>
Unlike the I-pipe, Dovetail does not copy the work descriptor but merely hands over the request to the common irq_work() mechanism. We must guarantee that such descriptor lives in a portion of memory which won't go stale until the handler has run, which by design can only happen once the calling out-of-band context unwinds.
Therefore, we have to move the non-rt signal descriptors off the stack. When it comes to the basic non-RT signal, the rtdm_nrtsig_t descriptor itself is a proper place to host the inband work descriptor which carries out the work under the hood.
When a task work needs to be scheduled, we enqueue it into global, lock-protected list, trigger a common lostage handler, and let that transfer the item to schedule_work.
Based on original patch by Philippe Gerum, avoiding xnmalloc in RT code paths.
--- include/cobalt/kernel/rtdm/driver.h | 9 +++- kernel/cobalt/rtdm/drvlib.c | 74 ++++++++++++++++------------- 2 files changed, 50 insertions(+), 33 deletions(-)
include/cobalt/kernel/rtdm/driver.h +8 -1
@@ -33,6 +33,7 @@#include <linux/wait.h> #include <linux/notifier.h> #include <pipeline/lock.h> +#include <pipeline/inband_work.h> #include <xenomai/version.h> #include <cobalt/kernel/heap.h> #include <cobalt/kernel/sched.h>
@@ -896,6 +897,7 @@ typedef struct rtdm_nrtsig rtdm_nrtsig_t;typedef void (*rtdm_nrtsig_handler_t )(rtdm_nrtsig_t *nrt_sig,void *arg);struct rtdm_nrtsig { +struct pipeline_inband_work inband_work;/* Must be first */ rtdm_nrtsig_handler_t handler;void *arg; };
@@ -904,9 +906,14 @@ void rtdm_schedule_nrt_work(struct work_struct *lostage_work);/** @} rtdm_nrtsignal */ #ifndef DOXYGEN_CPP /* Avoid static inline tags for RTDM in doxygen */ +void __rtdm_nrtsig_execute (struct pipeline_inband_work *inband_work); +static inline void rtdm_nrtsig_init (rtdm_nrtsig_t *nrt_sig, -rtdm_nrtsig_handler_t handler,void *arg) +rtdm_nrtsig_handler_t handler,void *arg) { + nrt_sig->inband_work = (struct pipeline_inband_work ) +PIPELINE_INBAND_WORK_INITIALIZER (*nrt_sig, + __rtdm_nrtsig_execute); nrt_sig->handler = handler; nrt_sig->arg = arg; }
kernel/cobalt/rtdm/drvlib.c +42 -32
107 lines not on this page · raw message
Signature · 1 line
2.26.2