[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-users] xen credit


  • To: xen-users@xxxxxxxxxxxxx
  • From: 张伟 <zhangwqh@xxxxxxx>
  • Date: Tue, 16 Apr 2013 03:34:58 +0800 (CST)
  • Delivery-date: Mon, 15 Apr 2013 19:35:46 +0000
  • List-id: Xen user discussion <xen-users.lists.xen.org>

Hi all,

Now I am reading the source code sched-credit. The xen version is 4.2.1.  I can not fully understand two places.

One place is:
There is a variable in schedule.c. There is per cpu variable, tasklet_work_to_do. Read this variable, set the tasklet_work, 
unsigned long        *tasklet_work = &this_cpu(tasklet_work_to_do);
    bool_t                tasklet_work_scheduled = 0;

Then according to the task_work, set the tasklet_work_scheduled:
/* Update tasklet scheduling status. */
    switch ( *tasklet_work )
    {
    case TASKLET_enqueued:
        set_bit(_TASKLET_scheduled, tasklet_work);
    case TASKLET_enqueued|TASKLET_scheduled:
        tasklet_work_scheduled = 1;
        break;
    case TASKLET_scheduled:
        clear_bit(_TASKLET_scheduled, tasklet_work);
    case 0:
        /*tasklet_work_scheduled = 0;*/
        break;
    default:
        BUG();
    }
I can not understand the function of tasklet_work_to_do, tasklet_work, tasklet_work_scheduled. I can not understand  their meaning. In the sched_credit.c file, 
there are two places that use tasklet_work_scheduled. I can not understand the meaning of tasklet_work_scheduled.
One place:
if ( !tasklet_work_scheduled
         && prv->ratelimit_us
         && vcpu_runnable(current)
         && !is_idle_vcpu(current)
         && runtime < MICROSECS(prv->ratelimit_us) )
    {
        snext = scurr;
        snext->start_time += now;
        perfc_incr(delay_ms);
        tslice = MICROSECS(prv->ratelimit_us);
        ret.migrated = 0;
        goto out;
}

the other place:
if ( tasklet_work_scheduled )
    {
        snext = CSCHED_VCPU(idle_vcpu[cpu]);
        snext->pri = CSCHED_PRI_TS_BOOST;
    }

This variable tasklet_work_scheduled is obstacle I understand the source code.

Other question is the member s_time_t start_time in structure struct csched_vcpu. The meaning and function for this variable?
I do not know why when a vcpu is descheduled, its start_time - now, why a vcpu is scheduled, its start_time + now?
deschedule:
if ( !is_idle_vcpu(scurr->vcpu) )
    {
        /* Update credits of a non-idle VCPU. */
        burn_credits(scurr, now);
        scurr->start_time -= now;
    }

schedule:
if ( !tasklet_work_scheduled
         && prv->ratelimit_us
         && vcpu_runnable(current)
         && !is_idle_vcpu(current)
         && runtime < MICROSECS(prv->ratelimit_us) )
    {
        snext = scurr;
        snext->start_time += now;
        perfc_incr(delay_ms);
        tslice = MICROSECS(prv->ratelimit_us);
        ret.migrated = 0;
        goto out;
    }

Anybody can give me some advice for these problems? Thank you in advance!


_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxx
http://lists.xen.org/xen-users

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.