ia64/xen-unstable
changeset 1215:d19b6a99967b
bitkeeper revision 1.826 (4061dc112UgMgszCetN8gJQ20L0AUw)
Features to pause domains (and repin them) synchronously.
Features to pause domains (and repin them) synchronously.
author | mwilli2@equilibrium.research.intel-research.net |
---|---|
date | Wed Mar 24 19:05:53 2004 +0000 (2004-03-24) |
parents | 33b04523c4ab |
children | 53a93ee1224d |
files | tools/examples/xc_dom_control.py xen/common/dom0_ops.c xen/common/sched_bvt.c xen/common/sched_rrobin.c xen/common/schedule.c xen/include/xen/sched-if.h xen/include/xen/sched.h |
line diff
1.1 --- a/tools/examples/xc_dom_control.py Tue Mar 23 11:55:59 2004 +0000 1.2 +++ b/tools/examples/xc_dom_control.py Wed Mar 24 19:05:53 2004 +0000 1.3 @@ -85,17 +85,9 @@ elif cmd == 'pincpu': 1.4 sys.exit(-1) 1.5 1.6 cpu = int(sys.argv[3]) 1.7 - orig_state = xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped'] 1.8 - 1.9 - while xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped'] != 1: 1.10 - xc.domain_stop( dom=dom ) 1.11 - time.sleep(0.1) 1.12 - 1.13 + 1.14 rc = xc.domain_pincpu( dom, cpu ) 1.15 1.16 - if orig_state == 0: 1.17 - xc.domain_start( dom=dom ) 1.18 - 1.19 elif cmd == 'list': 1.20 print 'Dom Name Mem(kb) CPU State Time(s)' 1.21 for domain in xc.domain_getinfo():
2.1 --- a/xen/common/dom0_ops.c Tue Mar 23 11:55:59 2004 +0000 2.2 +++ b/xen/common/dom0_ops.c Wed Mar 24 19:05:53 2004 +0000 2.3 @@ -160,40 +160,48 @@ long do_dom0_op(dom0_op_t *u_dom0_op) 2.4 2.5 case DOM0_PINCPUDOMAIN: 2.6 { 2.7 - struct task_struct * p = find_domain_by_id(op->u.pincpudomain.domain); 2.8 - int cpu = op->u.pincpudomain.cpu; 2.9 - ret = -EINVAL; 2.10 - if ( p != NULL ) 2.11 + domid_t dom = op->u.pincpudomain.domain; 2.12 + 2.13 + if ( dom == current->domain || dom == IDLE_DOMAIN_ID ) 2.14 + ret = -EINVAL; 2.15 + else 2.16 { 2.17 - if ( cpu == -1 ) 2.18 + struct task_struct * p = find_domain_by_id(dom); 2.19 + int cpu = op->u.pincpudomain.cpu; 2.20 + int we_paused = 0; 2.21 + 2.22 + ret = -ESRCH; 2.23 + 2.24 + if ( p != NULL ) 2.25 { 2.26 - p->cpupinned = 0; 2.27 - ret = 0; 2.28 - } 2.29 - else 2.30 - { 2.31 - /* For the moment, we are unable to move running 2.32 - domains between CPUs. (We need a way of synchronously 2.33 - stopping running domains). For now, if we discover the 2.34 - domain is not stopped already then cowardly bail out 2.35 - with ENOSYS */ 2.36 - 2.37 - if( !(p->state & TASK_STOPPED) ) 2.38 + if ( cpu == -1 ) 2.39 { 2.40 - ret = -ENOSYS; 2.41 - } 2.42 + p->cpupinned = 0; 2.43 + ret = 0; 2.44 + } 2.45 else 2.46 { 2.47 - /* We need a task structure lock here!!! 2.48 - FIX ME!! */ 2.49 - cpu = cpu % smp_num_cpus; 2.50 - p->processor = cpu; 2.51 - p->cpupinned = 1; 2.52 + /* Pause domain if necessary. */ 2.53 + if( !(p->state & TASK_STOPPED) && !(p->state & TASK_PAUSED) ) 2.54 + { 2.55 + sched_pause_sync(p); 2.56 + we_paused = 1; 2.57 + } 2.58 + 2.59 + /* We need a task structure lock here!!! 2.60 + FIX ME!! */ 2.61 + cpu = cpu % smp_num_cpus; 2.62 + p->processor = cpu; 2.63 + p->cpupinned = 1; 2.64 + 2.65 + if ( we_paused ) 2.66 + wake_up(p); 2.67 + 2.68 ret = 0; 2.69 } 2.70 - } 2.71 - put_task_struct(p); 2.72 - } 2.73 + put_task_struct(p); 2.74 + } 2.75 + } 2.76 } 2.77 break; 2.78
3.1 --- a/xen/common/sched_bvt.c Tue Mar 23 11:55:59 2004 +0000 3.2 +++ b/xen/common/sched_bvt.c Wed Mar 24 19:05:53 2004 +0000 3.3 @@ -401,6 +401,11 @@ int bvt_init_scheduler() 3.4 return 0; 3.5 } 3.6 3.7 +static void bvt_pause(struct task_struct *p) 3.8 +{ 3.9 + if( __task_on_runqueue(p) ) 3.10 + __del_from_runqueue(p); 3.11 +} 3.12 3.13 struct scheduler sched_bvt_def = { 3.14 .name = "Borrowed Virtual Time", 3.15 @@ -419,5 +424,6 @@ struct scheduler sched_bvt_def = { 3.16 .dump_settings = bvt_dump_settings, 3.17 .dump_cpu_state = bvt_dump_cpu_state, 3.18 .dump_runq_el = bvt_dump_runq_el, 3.19 + .pause = bvt_pause, 3.20 }; 3.21
4.1 --- a/xen/common/sched_rrobin.c Tue Mar 23 11:55:59 2004 +0000 4.2 +++ b/xen/common/sched_rrobin.c Wed Mar 24 19:05:53 2004 +0000 4.3 @@ -42,6 +42,12 @@ static void rr_dump_settings() 4.4 printk("rr_slice = %llu ", rr_slice); 4.5 } 4.6 4.7 +static void rr_pause(struct task_struct *p) 4.8 +{ 4.9 + if ( __task_on_runqueue(p) ) 4.10 + __del_from_runqueue(p); 4.11 +} 4.12 + 4.13 struct scheduler sched_rrobin_def = { 4.14 .name = "Round-Robin Scheduler", 4.15 .opt_name = "rrobin", 4.16 @@ -51,6 +57,7 @@ struct scheduler sched_rrobin_def = { 4.17 .do_schedule = rr_do_schedule, 4.18 .control = rr_ctl, 4.19 .dump_settings = rr_dump_settings, 4.20 + .pause = rr_pause, 4.21 }; 4.22 4.23
5.1 --- a/xen/common/schedule.c Tue Mar 23 11:55:59 2004 +0000 5.2 +++ b/xen/common/schedule.c Wed Mar 24 19:05:53 2004 +0000 5.3 @@ -167,7 +167,6 @@ int sched_rem_domain(struct task_struct 5.4 return 1; 5.5 } 5.6 5.7 - 5.8 void init_idle_task(void) 5.9 { 5.10 unsigned long flags; 5.11 @@ -281,6 +280,35 @@ long do_sched_op(unsigned long op) 5.12 return ret; 5.13 } 5.14 5.15 + 5.16 +/* sched_pause_sync - synchronously pause a domain's execution */ 5.17 +void sched_pause_sync(struct task_struct *p) 5.18 +{ 5.19 + unsigned long flags; 5.20 + int cpu = p->processor; 5.21 + 5.22 + spin_lock_irqsave(&schedule_lock[cpu], flags); 5.23 + 5.24 + if ( schedule_data[cpu].curr != p ) 5.25 + /* if not the current task, we can remove it from scheduling now */ 5.26 + SCHED_FN(pause, p); 5.27 + 5.28 + p->state = TASK_PAUSED; 5.29 + 5.30 + spin_unlock_irqrestore(&schedule_lock[cpu], flags); 5.31 + 5.32 + /* spin until domain is descheduled by its local scheduler */ 5.33 + while ( schedule_data[cpu].curr == p ) 5.34 + { 5.35 + set_bit(_HYP_EVENT_NEED_RESCHED, &p->hyp_events); 5.36 + hyp_event_notify(1 << cpu); 5.37 + do_yield(); 5.38 + } 5.39 + 5.40 + 5.41 + /* The domain will not be scheduled again until we do a wake_up(). */ 5.42 +} 5.43 + 5.44 /* Per-domain one-shot-timer hypercall. */ 5.45 long do_set_timer_op(unsigned long timeout_hi, unsigned long timeout_lo) 5.46 {
6.1 --- a/xen/include/xen/sched-if.h Tue Mar 23 11:55:59 2004 +0000 6.2 +++ b/xen/include/xen/sched-if.h Wed Mar 24 19:05:53 2004 +0000 6.3 @@ -50,6 +50,7 @@ struct scheduler 6.4 void (*dump_settings) (void); 6.5 void (*dump_cpu_state) (int); 6.6 void (*dump_runq_el) (struct task_struct *); 6.7 + void (*pause) (struct task_struct *); 6.8 }; 6.9 6.10 /* per CPU scheduler information */
7.1 --- a/xen/include/xen/sched.h Tue Mar 23 11:55:59 2004 +0000 7.2 +++ b/xen/include/xen/sched.h Wed Mar 24 19:05:53 2004 +0000 7.3 @@ -163,6 +163,7 @@ struct task_struct 7.4 * arbitrary event or timer. 7.5 * TASK_STOPPED: Domain is stopped. 7.6 * TASK_DYING: Domain is about to cross over to the land of the dead. 7.7 + * TASK_PAUSED: Task currently removed from scheduling. 7.8 */ 7.9 7.10 #define TASK_RUNNING 0 7.11 @@ -170,7 +171,7 @@ struct task_struct 7.12 #define TASK_UNINTERRUPTIBLE 2 7.13 #define TASK_STOPPED 4 7.14 #define TASK_DYING 8 7.15 -#define TASK_SCHED_PRIV 16 7.16 +#define TASK_PAUSED 16 7.17 7.18 #include <asm/uaccess.h> /* for KERNEL_DS */ 7.19 7.20 @@ -246,6 +247,7 @@ void sched_add_domain(struct task_struct 7.21 int sched_rem_domain(struct task_struct *p); 7.22 long sched_ctl(struct sched_ctl_cmd *); 7.23 long sched_adjdom(struct sched_adjdom_cmd *); 7.24 +void sched_pause_sync(struct task_struct *); 7.25 void init_idle_task(void); 7.26 void __wake_up(struct task_struct *p); 7.27 void wake_up(struct task_struct *p);