Skip to contentSkip to conversation

Next vcpu in queue

DISCUSSION Ananth 1 participant 3 messages Apr 24, 2009 1 message not in the archive

lore
Share & tools
lore

Ananth

author
#0 lore raw

Hi,
I am using xen 3.3.1 I want to destroy the head element of that list and assign the next in line vcpu as the head.
I have declared a pointer struct vcpu * vcpu_list_head.
I would like to assign vpu_list_head = ' get the next vcpu in queue which can be scheduled'. I am not sure if there is a already a function available which can do this.
Please guide.

Thank you

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#1 lore raw

Hi,
In connection with my previous mail, I have attached a file. This file has source code picked up from the book, 'The definitive guide to Xen hypervisor', for adding a simple scheduler to xen.

In the functions, rrobin_vcpu_init and rrobin_vcpu_destroy, the book uses (probably a macro call) VCPU_NEXT(struct vcpu). But there is no definition given for that function. It would be great if you can point to an existing function from xen 3.3.1 source code can be used.

Also, in the function rrobin_schedule (s_time_t ), the function __get_per_cpu is used (line no. 82) , which is not existing in 3.3.1 code. I want to return an idle task. Could you guide me as to which function in the 3.3.1 source code would be appropriate for the same?

Thank you very much.

Regards
Ananth

---------- Forwarded message ----------
From: Ananth <[email protected]>
Date: Fri, Apr 24, 2009 at 9:35 AM
Subject: Next vcpu in queue
To: "[email protected]" <[email protected]>

Hi,
I am using xen 3.3.1 I want to destroy the head element of that list and assign the next in line vcpu as the head.
I have declared a pointer struct vcpu * vcpu_list_head.
I would like to assign vpu_list_head = ' get the next vcpu in queue which can be scheduled'. I am not sure if there is a already a function available which can do this.
Please guide.

Thank you

#include <xen/config.h>
#include <xen/init.h>
#include <xen/lib.h>
#include <xen/sched.h>
#include <xen/domain.h>
#include <xen/delay.h>
#include <xen/event.h>
#include <xen/time.h>
#include <xen/perfc.h>
#include <xen/sched-if.h>
#include <xen/softirq.h>
#include <asm/atomic.h>
#include <xen/errno.h>

/* New VCPUs will be appended to the below linked list. The VCPU on the head of the list will be scheduled and then moved to the end of the list.*/

static struct vcpu *vcpu_list_head = NULL;
static struct vcpu *vcpu_list_tail = NULL;
static struct vcpu *head;
unsigned int vcpus = 0;

/* Move the head VCPU to the end */

static inline void increment_run_queue(void){
    (struct vcpu) (vcpu_list_tail)->sched_priv = vcpu_list_head;
    vcpu_list_tail = vcpu_list_head;
    vcpu_list_head = VCPU_NEXT(vcpu_list_tail);
    (vcpu_list_tail)->sched_priv = NULL;
}
/* Add a VCPU */
int rrobin_vcpu_init(struct vcpu *v){
    if(vcpu_list_head == NULL){
        vcpu_list_tail = v;
        vcpu_list_head = vcpu_list_tail;
    }
    else{
        vcpu_list_tail = v;
        (struct vcpu) vcpu_list_tail->sched_priv = vcpu_list_tail;
    }
    v->sched_priv = NULL;
    return 0;
}

/*Remove a VCPU*/

void rrobin_vcpu_destroy(struct vcpu *v){
    if(v == vcpu_list_head){
        vcpu_list_head = VCPU_NEXT(v);
    }
    else{
        struct vcpu *last = NULL;
        struct vcpu *current = vcpu_list_head;
        while((current != v) && (current != NULL)){
            last = current;
            current = VCPU_NEXT(current);
        }
        if(current != NULL){
            last->sched_priv = VCPU_NEXT(current);
        }
    }
}

/* Pick a VCPU from the list */

struct task_slice rrobin_schedule(s_time_t now){
    struct task_slice ret;
    ret.time = MILLISECS(10); /* Time quantum to scan the VCPU list to find a runnable VCPU */
    head = vcpu_list_head; /* Since its round robin, we pick the head of the list for scheduling and later move it back */
    do{
        /* Find a runnable CPU in the list */
        increment_run_queue();

        if(vcpu_runnable(vcpu_list_head)){
            ret.task = vcpu_list_head;
        }
    }while(head != vcpu_list_head);
/* If no runnable VCPU is found, return the idle task */
    ret.task = ((struct vcpu) __get_per_cpu(schedule_data).idle);
    return ret;

}
struct scheduler sched_rrobin_def = {

    .name           = "Round robin Scheduler",
    .opt_name       = "rrobin",
    .sched_id       = XEN_SCHEDULER_RR,

.init_vcpu = rrobin_vcpu_init,
.destroy_vcpu = rrobin_vcpu_destroy,

.do_schedule = rrobin_schedule,

};

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#3 lore raw

I looked through their code. But the issue I am facing is, they are specifically designed for an SMP environment. Whereas I am not too concerned about getting this working on SMP. Also, they use a lot of macros specific to their scheduler implementation. It wont be appropriate to copy all of them again to this scheduler code.

I have another question. For example, in Credit scheduer, is the list of VCPUs created while running the sched_credit.c? Or is it created through other files which is accessed through data structures in this file? Because, if it is created only in this file, then I must create the list from the sched_rrobin.c file also.

Thanks & Regards
Ananth

Quoted 39 lines · George Dunlap

Have you looked through the other schedulers (xen/common/sched_sedf.c, xen/common/sched_credit.c) to see if you can learn anything / copy any code?

-George

Quoted 3 lines · Ananth

Hi,
In connection with my previous mail, I have attached a file. This file

has

Quoted 5 lines

source code picked up from the book, 'The definitive guide to Xen hypervisor', for adding a simple scheduler to xen.

In the functions, rrobin_vcpu_init and rrobin_vcpu_destroy, the book uses (probably a macro call) VCPU_NEXT(struct vcpu). But there is no

definition

Quoted 1 line

given for that function. It would be great if you can point to an

existing

Quoted 4 lines

function from xen 3.3.1 source code can be used.

Also, in the function rrobin_schedule (s_time_t ), the function __get_per_cpu is used (line no. 82) , which is not existing in 3.3.1

code.

Quoted 15 lines

I want to return an idle task. Could you guide me as to which function in the 3.3.1 source code would be appropriate for the same?

Thank you very much.

Regards
Ananth

---------- Forwarded message ----------
From: Ananth <[email protected]>
Date: Fri, Apr 24, 2009 at 9:35 AM
Subject: Next vcpu in queue
To: "[email protected]" <[email protected]>

Quoted 21 lines
Quoted 6 lines

Hi,
I am using xen 3.3.1 I want to destroy the head element of that list and assign the next in line vcpu as the head.
I have declared a pointer struct vcpu * vcpu_list_head.
I would like to assign vpu_list_head = ' get the next vcpu in queue which can be scheduled'. I am not sure if there is a already a function

available

Quoted 13 lines

which can do this.
Please guide.

Thank you

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel