mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [Question] Linux CFS sched_entity
@ 2014-03-17  4:55 lwcheng
  2014-03-25 11:49 ` Morten Rasmussen
  0 siblings, 1 reply; 3+ messages in thread
From: lwcheng @ 2014-03-17  4:55 UTC (permalink / raw)
  To: linux-kernel

Hi,

I am studying Linux CFS recently. After numerous searches, I am still
unable to get rid of the following question. Finally I decide to bother
this group for the answer.

In group scheduling, sched_entity can represent both "task group" and "task",
indicated by "se->my_q".
When CFS tries to pick a new task, it first selects a "task group" and then
selects a "task" from that "task group":
--------------
static struct task_struct *pick_next_task_fair(struct rq *rq)
{
     struct task_struct *p;
     struct cfs_rq *cfs_rq = &rq->cfs;
     struct sched_entity *se;

     ... ...
     do {
         se = pick_next_entity(cfs_rq);
         set_next_entity(cfs_rq, se);
         cfs_rq = group_cfs_rq(se);
     } while (cfs_rq);

     p = task_of(se);
     ... ...
}
--------------
Therefore, cfs_rq->curr should *always* represent a "task" here, right?

However, cfs_rq->curr seems *not* to be a "task" sometimes:
--------------
static void update_curr(struct cfs_rq *cfs_rq)
{
     struct sched_entity *curr = cfs_rq->curr;

     ... ...
     if (entity_is_task(curr)) {              /* WHY? */
         struct task_struct *curtask = task_of(curr);

         trace_sched_stat_runtime(curtask, delta_exec, curr->vruntime);
         cpuacct_charge(curtask, delta_exec);
         account_group_exec_runtime(curtask, delta_exec);
     }
     ... ...
}
--------------

My question is:
In what situations does cfs_rq->curr point to a task_group?
What's the sense? I thought it should always contain a "real" task.

Appreciated for anyone who is able to help. Thanks in advance!

Regards,
Luwei Cheng
--
CS Student
The University of Hong Kong

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

* Re: [Question] Linux CFS sched_entity
  2014-03-17  4:55 [Question] Linux CFS sched_entity lwcheng
@ 2014-03-25 11:49 ` Morten Rasmussen
  2014-03-25 13:02   ` lwcheng
  0 siblings, 1 reply; 3+ messages in thread
From: Morten Rasmussen @ 2014-03-25 11:49 UTC (permalink / raw)
  To: lwcheng; +Cc: linux-kernel

On Mon, Mar 17, 2014 at 04:55:41AM +0000, lwcheng@cs.hku.hk wrote:
> In what situations does cfs_rq->curr point to a task_group?
> What's the sense? I thought it should always contain a "real" task.

In nested task groups cfs_rq->curr may point to a sched_entity which is
a nested task group (cfs_rq).

parent_group -> child_group -> task

Morten

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

* Re: [Question] Linux CFS sched_entity
  2014-03-25 11:49 ` Morten Rasmussen
@ 2014-03-25 13:02   ` lwcheng
  0 siblings, 0 replies; 3+ messages in thread
From: lwcheng @ 2014-03-25 13:02 UTC (permalink / raw)
  To: Morten Rasmussen; +Cc: linux-kernel


Quoting Morten Rasmussen <morten.rasmussen@arm.com>:

> On Mon, Mar 17, 2014 at 04:55:41AM +0000, lwcheng@cs.hku.hk wrote:
>> In what situations does cfs_rq->curr point to a task_group?
>> What's the sense? I thought it should always contain a "real" task.
>
> In nested task groups cfs_rq->curr may point to a sched_entity which is
> a nested task group (cfs_rq).
>
> parent_group -> child_group -> task
>
> Morten

Thanks for your reply.

Luwei




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

end of thread, other threads:[~2014-03-25 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-17  4:55 [Question] Linux CFS sched_entity lwcheng
2014-03-25 11:49 ` Morten Rasmussen
2014-03-25 13:02   ` lwcheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®