All of lore.kernel.org
 help / color / mirror / Atom feed
* How task_struct.rt.time_slice is initialized?
@ 2015-06-06 10:53 Simon Guo
  2015-06-06 11:07 ` Simon Guo
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Guo @ 2015-06-06 10:53 UTC (permalink / raw)
  To: kernelnewbies

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

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

* How task_struct.rt.time_slice is initialized?
  2015-06-06 10:53 How task_struct.rt.time_slice is initialized? Simon Guo
@ 2015-06-06 11:07 ` Simon Guo
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Guo @ 2015-06-06 11:07 UTC (permalink / raw)
  To: kernelnewbies

Hi, 

On Sat, Jun 06, 2015 at 06:53:22PM +0800, Simon Guo wrote:
> 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.
Looks the initialization logic is in arch_dup_task_struct(). Please
ignore my previous question.

Thanks,
Simon

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

end of thread, other threads:[~2015-06-06 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-06 10:53 How task_struct.rt.time_slice is initialized? Simon Guo
2015-06-06 11:07 ` Simon Guo

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.