All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] CPU occupation without context switches?
@ 2012-05-22 16:09 Arnout Vandecappelle
  2012-05-22 18:17 ` Gilles Chanteperdrix
  2012-05-22 19:44 ` Philippe Gerum
  0 siblings, 2 replies; 6+ messages in thread
From: Arnout Vandecappelle @ 2012-05-22 16:09 UTC (permalink / raw)
  To: xenomai

  Hoi,

  After a few minutes of running my application, I see this:

# cat /proc/xenomai/stat
CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
   1  828    22         65         0     00300182    9.8  bench_RTnet_scope_thread_loop
   1  839    2          46627538   0     00300186   53.8  bench_RTnet
...

  i.e. the bench_RTnet_scope_thread_loop takes 10% CPU but no
context switches.  How is this possible?  I've looked at the
source code and can't find an explanation: when the exectime
accounting is updated, the csw is incremented as well (in
__xnpod_schedule()).

  I'm asking because I can't find a reason why this thread should
occupy 10% of the CPU, so I'm wondering if there's something wrong
with the accounting instead.

  BTW this is on Xenomai 2.5.6, on an SMP x86 with affinity=0x01.

  Regards,
  Arnout

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] CPU occupation without context switches?
  2012-05-22 16:09 [Xenomai] CPU occupation without context switches? Arnout Vandecappelle
@ 2012-05-22 18:17 ` Gilles Chanteperdrix
  2012-05-22 19:44 ` Philippe Gerum
  1 sibling, 0 replies; 6+ messages in thread
From: Gilles Chanteperdrix @ 2012-05-22 18:17 UTC (permalink / raw)
  To: Arnout Vandecappelle; +Cc: xenomai

On 05/22/2012 06:09 PM, Arnout Vandecappelle wrote:
>   Hoi,
> 
>   After a few minutes of running my application, I see this:
> 
> # cat /proc/xenomai/stat
> CPU  PID    MSW        CSW        PF    STAT       %CPU  NAME
>    1  828    22         65         0     00300182    9.8  bench_RTnet_scope_thread_loop
>    1  839    2          46627538   0     00300186   53.8  bench_RTnet
> ...
> 
>   i.e. the bench_RTnet_scope_thread_loop takes 10% CPU but no
> context switches.  How is this possible?  I've looked at the
> source code and can't find an explanation: when the exectime
> accounting is updated, the csw is incremented as well (in
> __xnpod_schedule()).
> 
>   I'm asking because I can't find a reason why this thread should
> occupy 10% of the CPU, so I'm wondering if there's something wrong
> with the accounting instead.
> 
>   BTW this is on Xenomai 2.5.6, on an SMP x86 with affinity=0x01.

Could you test Xenomai 2.6.0 to see if you still have the issue? Could
you provide us with some minimal code allowing us to reproduce this issue?

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] CPU occupation without context switches?
  2012-05-22 16:09 [Xenomai] CPU occupation without context switches? Arnout Vandecappelle
  2012-05-22 18:17 ` Gilles Chanteperdrix
@ 2012-05-22 19:44 ` Philippe Gerum
  2012-05-23  8:31   ` Arnout Vandecappelle
  1 sibling, 1 reply; 6+ messages in thread
From: Philippe Gerum @ 2012-05-22 19:44 UTC (permalink / raw)
  To: Arnout Vandecappelle; +Cc: xenomai

On 05/22/2012 06:09 PM, Arnout Vandecappelle wrote:
> Hoi,
>
> After a few minutes of running my application, I see this:
>
> # cat /proc/xenomai/stat
> CPU PID MSW CSW PF STAT %CPU NAME
> 1 828 22 65 0 00300182 9.8 bench_RTnet_scope_thread_loop
> 1 839 2 46627538 0 00300186 53.8 bench_RTnet
> ...
>
> i.e. the bench_RTnet_scope_thread_loop takes 10% CPU but no
> context switches. How is this possible? I've looked at the
> source code and can't find an explanation: when the exectime
> accounting is updated, the csw is incremented as well (in
> __xnpod_schedule()).
>

Unless your thread which seems to repeatedly attempt to pend on some 
sync object has its wait condition satisfied on entry to the syscall 
most of the time, which may cause __xnpod_schedule() to leave it running 
without incrementing the switch count.

> I'm asking because I can't find a reason why this thread should
> occupy 10% of the CPU, so I'm wondering if there's something wrong
> with the accounting instead.
>
> BTW this is on Xenomai 2.5.6, on an SMP x86 with affinity=0x01.
>
> Regards,
> Arnout
>


-- 
Philippe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] CPU occupation without context switches?
  2012-05-22 19:44 ` Philippe Gerum
@ 2012-05-23  8:31   ` Arnout Vandecappelle
  2012-05-23  8:45     ` Philippe Gerum
  0 siblings, 1 reply; 6+ messages in thread
From: Arnout Vandecappelle @ 2012-05-23  8:31 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

On 05/22/12 21:44, Philippe Gerum wrote:
> On 05/22/2012 06:09 PM, Arnout Vandecappelle wrote:
>> Hoi,
>>
>> After a few minutes of running my application, I see this:
>>
>> # cat /proc/xenomai/stat
>> CPU PID MSW CSW PF STAT %CPU NAME
>> 1 828 22 65 0 00300182 9.8 bench_RTnet_scope_thread_loop
>> 1 839 2 46627538 0 00300186 53.8 bench_RTnet
>> ...
>>
>> i.e. the bench_RTnet_scope_thread_loop takes 10% CPU but no
>> context switches. How is this possible? I've looked at the
>> source code and can't find an explanation: when the exectime
>> accounting is updated, the csw is incremented as well (in
>> __xnpod_schedule()).
>>
>
> Unless your thread which seems to repeatedly attempt to pend on some sync object has its wait condition satisfied on
> entry to the syscall most of the time, which may cause __xnpod_schedule() to leave it running without incrementing the
> switch count.

  It is indeed possible that my application does something like that.  But
wouldn't the switch count be incremented every time the bench_RTnet thread
is executed?  That thread runs at 20kHz and at higher priority so it should
pre-empt the other one, which should lead to context switches in the _loop
thread.

  Unfortunately, I can't reproduce the situation anymore...  If I can I'll
try with Xenomai 2.6.0.


  Regards,
  Arnout

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] CPU occupation without context switches?
  2012-05-23  8:31   ` Arnout Vandecappelle
@ 2012-05-23  8:45     ` Philippe Gerum
  2012-05-23  9:37       ` Philippe Gerum
  0 siblings, 1 reply; 6+ messages in thread
From: Philippe Gerum @ 2012-05-23  8:45 UTC (permalink / raw)
  To: Arnout Vandecappelle; +Cc: xenomai

On 05/23/2012 10:31 AM, Arnout Vandecappelle wrote:
> On 05/22/12 21:44, Philippe Gerum wrote:
>> On 05/22/2012 06:09 PM, Arnout Vandecappelle wrote:
>>> Hoi,
>>>
>>> After a few minutes of running my application, I see this:
>>>
>>> # cat /proc/xenomai/stat
>>> CPU PID MSW CSW PF STAT %CPU NAME
>>> 1 828 22 65 0 00300182 9.8 bench_RTnet_scope_thread_loop
>>> 1 839 2 46627538 0 00300186 53.8 bench_RTnet
>>> ...
>>>
>>> i.e. the bench_RTnet_scope_thread_loop takes 10% CPU but no
>>> context switches. How is this possible? I've looked at the
>>> source code and can't find an explanation: when the exectime
>>> accounting is updated, the csw is incremented as well (in
>>> __xnpod_schedule()).
>>>
>>
>> Unless your thread which seems to repeatedly attempt to pend on some
>> sync object has its wait condition satisfied on
>> entry to the syscall most of the time, which may cause
>> __xnpod_schedule() to leave it running without incrementing the
>> switch count.
>
> It is indeed possible that my application does something like that. But
> wouldn't the switch count be incremented every time the bench_RTnet thread
> is executed? That thread runs at 20kHz and at higher priority so it should
> pre-empt the other one, which should lead to context switches in the _loop
> thread.

20Khz does not put much pressure on mid/high end x86, so I believe 
bench_RTnet does not preempt the loop thread that much actually, but the 
latter does consume most of the 500 us time slot without suspending, 
with the former switching in in the remaining quantum most of the time 
(i.e. not preempting any other RT thread).

>
> Unfortunately, I can't reproduce the situation anymore... If I can I'll
> try with Xenomai 2.6.0.
>
>
> Regards,
> Arnout
>


-- 
Philippe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xenomai] CPU occupation without context switches?
  2012-05-23  8:45     ` Philippe Gerum
@ 2012-05-23  9:37       ` Philippe Gerum
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Gerum @ 2012-05-23  9:37 UTC (permalink / raw)
  To: Arnout Vandecappelle; +Cc: xenomai

On 05/23/2012 10:45 AM, Philippe Gerum wrote:
> On 05/23/2012 10:31 AM, Arnout Vandecappelle wrote:
>> On 05/22/12 21:44, Philippe Gerum wrote:
>>> On 05/22/2012 06:09 PM, Arnout Vandecappelle wrote:
>>>> Hoi,
>>>>
>>>> After a few minutes of running my application, I see this:
>>>>
>>>> # cat /proc/xenomai/stat
>>>> CPU PID MSW CSW PF STAT %CPU NAME
>>>> 1 828 22 65 0 00300182 9.8 bench_RTnet_scope_thread_loop
>>>> 1 839 2 46627538 0 00300186 53.8 bench_RTnet
>>>> ...
>>>>
>>>> i.e. the bench_RTnet_scope_thread_loop takes 10% CPU but no
>>>> context switches. How is this possible? I've looked at the
>>>> source code and can't find an explanation: when the exectime
>>>> accounting is updated, the csw is incremented as well (in
>>>> __xnpod_schedule()).
>>>>
>>>
>>> Unless your thread which seems to repeatedly attempt to pend on some
>>> sync object has its wait condition satisfied on
>>> entry to the syscall most of the time, which may cause
>>> __xnpod_schedule() to leave it running without incrementing the
>>> switch count.
>>
>> It is indeed possible that my application does something like that. But
>> wouldn't the switch count be incremented every time the bench_RTnet
>> thread
>> is executed? That thread runs at 20kHz and at higher priority so it
>> should
>> pre-empt the other one, which should lead to context switches in the
>> _loop
>> thread.
>
> 20Khz does not put much pressure on mid/high end x86, so I believe
> bench_RTnet does not preempt the loop thread that much actually, but the
> latter does consume most of the 500 us time slot without suspending,
> with the former switching in in the remaining quantum most of the time
> (i.e. not preempting any other RT thread).

Except that 20Khz means a 50 us time slot, not 500 us. This leaves much 
less opportunity for the explanation above to stand up.

What is the typical latency of your system?

>
>>
>> Unfortunately, I can't reproduce the situation anymore... If I can I'll
>> try with Xenomai 2.6.0.
>>
>>
>> Regards,
>> Arnout
>>
>
>


-- 
Philippe.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-23  9:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-22 16:09 [Xenomai] CPU occupation without context switches? Arnout Vandecappelle
2012-05-22 18:17 ` Gilles Chanteperdrix
2012-05-22 19:44 ` Philippe Gerum
2012-05-23  8:31   ` Arnout Vandecappelle
2012-05-23  8:45     ` Philippe Gerum
2012-05-23  9:37       ` Philippe Gerum

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.