All of lore.kernel.org
 help / color / mirror / Atom feed
From: wei.guo.simon@gmail.com (Simon Guo)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How task_struct.rt.time_slice is initialized?
Date: Sat, 6 Jun 2015 18:53:22 +0800	[thread overview]
Message-ID: <20150606105322.GA11106@thunderCat> (raw)

Dear alias,

I noticed there is a time_slice variable for SCHED_RR policy in
task_struct.rt member (I am using 4.1.0 kernel):
        struct sched_rt_entity {
                ...
                unsigned int time_slice;
                ...
        };

Per my understanding, the task_struct.rt.time_slice should be
initialized to sched_rr_timeslice or RR_TIMESLICE . Like what process 0 has done:
#define INIT_TASK(tsk)  \
{   
        ...
                .rt             = { \
                                .run_list       = LIST_HEAD_INIT(tsk.rt.run_list), \
                                .time_slice     = RR_TIMESLICE, \
                },
        ...
}

However I didn't see somewhere in copy_process() to set time_slice
value for a new forked SCHED_RR process.

If time_slice is not initialized, time_slice will be with value 0 and
will be overflow to a big value in following "if (--p->rt.time_slice)" statement:
static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued)
{
        ...
	/*
	 * RR tasks need a special form of timeslice management.
	 * FIFO tasks have no timeslices.
	 */
	if (p->policy != SCHED_RR)
		return;

	if (--p->rt.time_slice)                          
		return;

	p->rt.time_slice = sched_rr_timeslice;
        ...
}

Is it a bug? Please correct me if I am wrong.

Thanks,
Simon

             reply	other threads:[~2015-06-06 10:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-06 10:53 Simon Guo [this message]
2015-06-06 11:07 ` How task_struct.rt.time_slice is initialized? Simon Guo

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=20150606105322.GA11106@thunderCat \
    --to=wei.guo.simon@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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.