From: Jan Kiszka <jan.kiszka@domain.hid>
To: Daniel Simon <Daniel.Simon@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] measuring tasks execution time
Date: Wed, 11 Jul 2007 16:30:03 +0200 [thread overview]
Message-ID: <4694E96B.5020801@domain.hid> (raw)
In-Reply-To: <20070711155932.4b88699e@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 4930 bytes --]
Daniel Simon wrote:
> On Sun, 08 Jul 2007 12:11:56 +0200
> Jan Kiszka <jan.kiszka@domain.hid> wrote:
>
> Hello,
>> You are welcome to test, fix, improve, or just use it. Looking forward
>> to your feedback!
>
> here are attached some corrections against your previous patch (itself against
> #2758 files): from my tests I now get likely exectime values from both remote
> and self measurement (i.e. we get the accumulated exectime at the instant we
> call rt_task_inquire ), and the stats given in /proc still seem to behave
> normally...
>
> the full patch against the original 2758 version is also given in attachement
To check if I got it the first attachment is an add-on patch, the second
one is the base patch as in my repos + the former add-on patch?
Then let's comment on the add-on:
> diff -urN xenomai-2758/include/nucleus/stat.h xenomai-2758-V2/include/nucleus/stat.h
> --- xenomai-2758/include/nucleus/stat.h 2007-07-11 15:16:14.000000000 +0200
> +++ xenomai-2758-V2/include/nucleus/stat.h 2007-07-11 15:09:38.000000000 +0200
> @@ -42,7 +42,7 @@
> do { \
> (sched)->current_account->total += \
> date - (sched)->last_account_switch; \
> - (sched)->last_account_switch = date; \
> + (sched)->last_account_switch = (sched)->current_account->start = date; \
That looks bogus on first sight, but I might miss your intention.
current_account points to the overall stats of an accounted entity.
Therefore, start must always contain the start time, not the last switch
time. Please explain your idea.
> /* All changes must be committed before changing the current_account \
> reference in sched (required for xnintr_sync_stat_references) */ \
> xnarch_memory_barrier(); \
> @@ -71,6 +71,9 @@
> #define xnstat_runtime_get_start(account) ((account)->start)
> #define xnstat_runtime_get_total(account) ((account)->total)
>
> +/* Obtain last time something has been switched */
> +#define xnstat_runtime_get_last_switch(sched) ((sched)->last_account_switch)
> +
OK (though a more precise comment would be good :))
> /* Reset statistics from inside the accounted entity (e.g. after CPU
> migration). */
> #define xnstat_runtime_reset_stats(stat) \
> @@ -113,6 +116,7 @@
> #define xnstat_runtime_finalize(sched, new_account) do { } while (0)
> #define xnstat_runtime_get_start(account) ({ 0; })
> #define xnstat_runtime_get_total(account) ({ 0; })
> +#define xnstat_runtime_get_last_switch(sched) ({ 0; })
> #define xnstat_runtime_reset_stats(account) do { } while (0)
>
> typedef struct xnstat_counter {
> diff -urN xenomai-2758/include/nucleus/thread.h xenomai-2758-V2/include/nucleus/thread.h
> --- xenomai-2758/include/nucleus/thread.h 2007-07-11 15:16:14.000000000 +0200
> +++ xenomai-2758-V2/include/nucleus/thread.h 2007-07-11 14:28:15.000000000 +0200
> @@ -294,7 +294,7 @@
> #define xnthread_affinity(thread) ((thread)->affinity)
> #define xnthread_affine_p(thread, cpu) xnarch_cpu_isset(cpu, (thread)->affinity)
> #define xnthread_get_exectime(thread) xnstat_runtime_get_total(&(thread)->stat.account)
> -#define xnthread_get_lastswitch(thread) xnstat_runtime_get_start(&(thread)->stat.account)
> +#define xnthread_get_lastswitch(thread) xnstat_runtime_get_last_switch((thread)->sched)
Yeah, that was wrong. Did your first patch hunk relate to an initial
attempt to fix this bug?
>
> /* Class-level operations for threads. */
> static inline int xnthread_get_denormalized_prio(xnthread_t *t)
> diff -urN xenomai-2758/ksrc/skins/native/task.c xenomai-2758-V2/ksrc/skins/native/task.c
> --- xenomai-2758/ksrc/skins/native/task.c 2007-07-11 15:16:14.000000000 +0200
> +++ xenomai-2758-V2/ksrc/skins/native/task.c 2007-07-11 15:22:10.000000000 +0200
> @@ -1144,10 +1144,13 @@
> info->cprio = xnthread_current_priority(&task->thread_base);
> info->status = xnthread_state_flags(&task->thread_base);
> info->relpoint = xntimer_get_date(&task->thread_base.ptimer);
> + if(task == xeno_current_task())
> info->exectime = xnarch_tsc_to_ns(
> xnthread_get_exectime(&task->thread_base) +
> xnstat_runtime_now() -
> xnthread_get_lastswitch(&task->thread_base));
> + else
> + info->exectime = xnarch_tsc_to_ns(xnthread_get_exectime(&task->thread_base));
OK, second bug taken. But you approach was written without SMP in mind
(while I thought too much about SMP). The correct condition is "task is
running, somewhere?":
if (task->thread_base.sched->runthread == &task->thread_base)
<exectime up to now>
else
<currently stored exectime>
Of course, one may still optimise the expression.
> info->modeswitches = xnstat_counter_get(&task->thread_base.stat.ssw);
> info->ctxswitches = xnstat_counter_get(&task->thread_base.stat.csw);
> info->pagefaults = xnstat_counter_get(&task->thread_base.stat.pf);
>
>
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
next prev parent reply other threads:[~2007-07-11 14:30 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-07 16:23 [Xenomai-help] real time task disapears... memory problem ? desvages
2007-06-07 17:44 ` Jan Kiszka
2007-06-08 10:49 ` [Xenomai-help] measuring tasks execution time Daniel Simon
2007-06-08 11:20 ` [Xenomai-core] " Jan Kiszka
2007-06-08 13:09 ` Daniel Simon
2007-06-08 15:24 ` Jan Kiszka
2007-06-08 16:04 ` Jan Kiszka
2007-06-25 15:51 ` [Xenomai-core] " Daniel Simon
2007-06-25 16:55 ` Jan Kiszka
2007-06-27 8:57 ` Daniel Simon
2007-06-27 11:56 ` Jan Kiszka
2007-06-29 14:43 ` Daniel Simon
2007-06-29 15:00 ` Jan Kiszka
2007-06-29 15:29 ` Daniel Simon
2007-06-29 15:47 ` Philippe Gerum
2007-06-29 15:56 ` Gilles Chanteperdrix
2007-06-29 15:52 ` Jan Kiszka
2007-07-08 10:11 ` Jan Kiszka
2007-07-09 8:49 ` Daniel Simon
2007-07-11 13:59 ` Daniel Simon
2007-07-11 14:30 ` Jan Kiszka [this message]
2007-07-11 15:35 ` Daniel Simon
2007-07-11 15:56 ` Jan Kiszka
2007-07-11 16:55 ` Daniel Simon
2007-07-11 21:20 ` Jan Kiszka
2007-07-12 9:30 ` Daniel Simon
2007-07-12 11:02 ` Jan Kiszka
2007-07-16 16:19 ` Daniel Simon
[not found] ` <1753.194.254.210.7.1181246882.squirrel@domain.hid>
2007-06-08 15:19 ` [Xenomai-help] real time task disapears... memory problem ? Jan Kiszka
2007-06-09 16:06 ` desvages
2007-06-09 17:10 ` Jan Kiszka
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=4694E96B.5020801@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=Daniel.Simon@domain.hid \
--cc=xenomai@xenomai.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.