From: "Patel, Vedang" <vedang.patel@intel.com>
To: "linux-rt-users@vger.kernel.org" <linux-rt-users@vger.kernel.org>
Cc: "Koppolu, Chanakya" <chanakya.koppolu@intel.com>
Subject: yielding while running SCHED_DEADLINE
Date: Fri, 14 Sep 2018 23:13:17 +0000 [thread overview]
Message-ID: <1536966797.25468.109.camel@intel.com> (raw)
Hi all,
We have been playing around with SCHED_DEADLINE and found some
discrepancy around the calculation of nr_involuntary_switches and
nr_voluntary_switches in /proc/${PID}/sched.
Whenever the task is done with it's work earlier and executes
sched_yield() to voluntarily gives up the CPU this increments
nr_involuntary_switches. It should have incremented
nr_voluntary_switches.
This can be easily demonstrated by running cyclicdeadline task which is
part of rt-tests(https://git.kernel.org/pub/scm/utils/rt-tests/rt-tests
.git/) and checking the value of nr_voluntary_switches.
Please note that the issue seems to be with sched_yield() and not
SCHED_DEADLINE because we have seen similar behavior when we tried
switching to other policies. But, we are using SCHED_DEADLINE because
it is one of the (very) few scenarios where sched_yield() can be used
correctly.
Some analysis:
--------------
I enabled the sched/sched_switch (setting cyclicdeadline as filter) and
syscalls/sys_enter_sched_yield events to check whether the
sched_yield() call was resulting in a new task running. I got the
following results:
cyclicdeadline-3290 [003] ....... 3111.132786: tracing_mark_write: start at 3111125101 off=3 (period=3111125098 next=3111126098)
cyclicdeadline-3290 [003] ....1.. 3111.132789: sys_sched_yield()
cyclicdeadline-3290 [003] d...2.. 3111.132797: sched_switch: prev_comm=cyclicdeadline prev_pid=3290 prev_prio=-1 prev_state=R ==> next_comm=swapper/3 next_pid=0 next_prio=120
cyclicdeadline-3290 [003] ....... 3111.133786: tracing_mark_write: start at 3111126101 off=3 (period=3111126098 next=3111127098)
cyclicdeadline-3290 [003] ....1.. 3111.133789: sys_sched_yield()
cyclicdeadline-3290 [003] d...2.. 3111.133797: sched_switch: prev_comm=cyclicdeadline prev_pid=3290 prev_prio=-1 prev_state=R ==> next_comm=swapper/3 next_pid=0 next_prio=120
cyclicdeadline-3290 [003] ....... 3111.134786: tracing_mark_write: start at 3111127101 off=3 (period=3111127098 next=3111128098)
cyclicdeadline-3290 [003] ....1.. 3111.134789: sys_sched_yield()
cyclicdeadline-3290 [003] d...2.. 3111.134797: sched_switch: prev_comm=cyclicdeadline prev_pid=3290 prev_prio=-1 prev_state=R ==> next_comm=swapper/3 next_pid=0 next_prio=120
....
As seen above, all the sched_yield calls are followed by sched switch.
So, we believe that the sched_yield() is actually resulting in a
switch. The values for nr_voluntary_switches/nr_involuntary_switches in
this scenario:
nr_switches : 138753
nr_voluntary_switches : 1
nr_involuntary_switches : 138752
Looking at __schedule() in kernel/sched/core.c, the switch is counted
as part of nr_involuntary_switches if the task has not been preempted
and the task is TASK_RUNNING state. This does not seem to happen when
sched_yield() is called.
Is there something we are missing over here? OR Is this a known issue
and is planned to be fixed later?
Thanks,
Vedang Patel
next reply other threads:[~2018-09-15 4:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-14 23:13 Patel, Vedang [this message]
2018-09-17 9:26 ` yielding while running SCHED_DEADLINE Juri Lelli
2018-09-17 11:42 ` Peter Zijlstra
2018-09-17 17:14 ` Patel, Vedang
2018-09-21 0:19 ` Bowles, Matthew K
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=1536966797.25468.109.camel@intel.com \
--to=vedang.patel@intel.com \
--cc=chanakya.koppolu@intel.com \
--cc=linux-rt-users@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).