From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Xenomai <xenomai@lists.linux.dev>
Subject: Re: [libevl][PATCH] tests: sched-quota: Simplify disruption
Date: Fri, 04 Sep 2026 11:26:03 +0200 [thread overview]
Message-ID: <877bl1fjv8.fsf@xenomai.org> (raw)
In-Reply-To: <72486647-41b3-448b-bfe3-85135c1ad53f@siemens.com> (Jan Kiszka's message of "Mon, 31 Aug 2026 19:50:25 +0200")
Jan Kiszka <jan.kiszka@siemens.com> writes:
> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> No need to spawn an extra thread here and also play ping-pong with it to
> generate an oscillating load. The main thread can do the very same thing
> within a few lines of code.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> On top of my previous patches.
>
> tests/sched-quota-accuracy.c | 52 +++---------------------------------
> 1 file changed, 3 insertions(+), 49 deletions(-)
>
> diff --git a/tests/sched-quota-accuracy.c b/tests/sched-quota-accuracy.c
> index ac04449..251ea30 100644
> --- a/tests/sched-quota-accuracy.c
> +++ b/tests/sched-quota-accuracy.c
> @@ -26,15 +26,13 @@
>
> #define MAX_THREADS 8
> #define QUOTA_PRIO 1
> -#define DISRUPTOR_PRIO 2
> -#define MAIN_PRIO 3
> +#define MAIN_PRIO 2
>
> enum runtime_phase {
> idle_phase,
> calibration_phase,
> accuracy_measurement_phase,
> noise_measurement_phase,
> - disruption_phase,
> } current_phase = idle_phase;
>
> static struct quota_thread_desc {
> @@ -111,23 +109,6 @@ static void wait_phase(enum runtime_phase phase)
> __Tcall_assert(ret, evl_unlock_mutex(&lock));
> }
>
> -static void wait_edge(enum runtime_phase phase)
> -{
> - enum runtime_phase old_phase = phase;
> - int ret;
> -
> - __Tcall_assert(ret, evl_lock_mutex(&lock));
> - for (;;) {
> - if (current_phase == phase) {
> - current_phase = old_phase;
> - break;
> - }
> - old_phase = current_phase;
> - __Tcall_assert(ret, evl_wait_event(&barrier, &lock));
> - }
> - __Tcall_assert(ret, evl_unlock_mutex(&lock));
> -}
> -
> static void start_phase(enum runtime_phase phase)
> {
> int ret;
> @@ -191,24 +172,6 @@ static void *quota_thread(void *arg)
> return NULL;
> }
>
> -static void *disruptor_thread(void *arg)
> -{
> - int ret;
> -
> - __Tcall_assert(ret, evl_attach_self("quota-disruptor:%d", getpid()));
> -
> - wait_phase(noise_measurement_phase);
> -
> - for (;;) {
> - wait_edge(disruption_phase);
> - do_trace("(...disrupting...)");
> - do_work(NULL, DISRUPT_NS);
> - start_phase(noise_measurement_phase);
> - }
> -
> - return NULL;
> -}
> -
> static int cleanup_group(void)
> {
> union evl_sched_ctlparam p;
> @@ -236,7 +199,6 @@ static struct accuracy_results run_quota(void)
> union evl_sched_ctlparam p;
> union evl_sched_ctlinfo q;
> struct timespec now, next;
> - pthread_t disruptor;
> struct sigaction sa;
> int ret, n;
>
> @@ -304,10 +266,6 @@ static struct accuracy_results run_quota(void)
>
> do_trace("CPU%d: starting noise measurement", test_cpu);
>
> - /* Start the disruptor thread then wait for sync. */
> - new_thread(&disruptor, SCHED_FIFO, DISRUPTOR_PRIO, disruptor_thread, NULL);
> - __Tcall_assert(ret, evl_get_sem(&ready));
> -
> reset_quota_period(PERIOD_NS);
> start_phase(noise_measurement_phase);
>
> @@ -316,17 +274,13 @@ static struct accuracy_results run_quota(void)
> evl_read_clock(EVL_CLOCK_MONOTONIC, &now);
> timespec_add_ns(&next, &now, DISRUPT_NS);
> __Tcall_assert(ret, evl_sleep_until(EVL_CLOCK_MONOTONIC, &next));
> - start_phase(disruption_phase);
> - wait_phase(noise_measurement_phase);
> - __Tcall_assert(ret, evl_get_sem(&ready));
> + do_trace("(...disrupting...)");
> + do_work(NULL, DISRUPT_NS);
> }
>
> for (n = 0; n < nrthreads; n++)
> pthread_join(threads[n].tid, NULL);
>
> - pthread_cancel(disruptor);
> - pthread_join(disruptor, NULL);
> -
> for (n = 0, loops_with_disruption = 0; n < nrthreads; n++) {
> loops_with_disruption += threads[n].loops;
> do_trace("CPU%d: noise: quota_thread[%d]: loops=%llu",
Merged, thanks.
--
Philippe.
prev parent reply other threads:[~2026-09-04 10:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 17:50 [libevl][PATCH] tests: sched-quota: Simplify disruption Jan Kiszka
2026-09-04 9:26 ` Philippe Gerum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877bl1fjv8.fsf@xenomai.org \
--to=rpm@xenomai.org \
--cc=jan.kiszka@siemens.com \
--cc=xenomai@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox