Cpupools: hypervisor part
PATCH 1/6 Cpupools: hypervisor part
Signature · 6 lines
-- Juergen Gross Principal Developer Operating Systems TSP ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967 Fujitsu Technology Solutions e-mail: [email protected] Domagkstr. 28 Internet: ts.fujitsu.com D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
Signed-off-by [email protected]
xen/arch/x86/domain_build.c +8 -3
@@ -9,6 +9,7 @@#include <xen/lib.h> #include <xen/ctype.h> #include <xen/sched.h> +#include <xen/sched-if.h> #include <xen/smp.h> #include <xen/delay.h> #include <xen/event.h>
@@ -84,7 +85,7 @@ struct vcpu *__init alloc_dom0_vcpu0(voistruct vcpu *__init alloc_dom0_vcpu0 (void ) {if ( opt_dom0_max_vcpus ==0 ) - opt_dom0_max_vcpus =num_online_cpus (); + opt_dom0_max_vcpus =num_cpupool_cpus (cpupool0);if ( opt_dom0_max_vcpus >MAX_VIRT_CPUS ) opt_dom0_max_vcpus =MAX_VIRT_CPUS ;
@@ -277,7 +278,7 @@ int __init construct_dom0( unsigned long _initrd_start, unsigned long initrd_len, char *cmdline) { - int i, rc, compatible, compat32, order, machine; + int i, cpu, rc, compatible, compat32, order, machine;struct cpu_user_regs *regs;unsigned long pfn, mfn;unsigned long nr_pages;
@@ -776,8 +777,12 @@ int __init construct_dom0(printk ("Dom0 has maximum %u VCPUs\n" , opt_dom0_max_vcpus); + cpu =first_cpu (cpupool0->cpu_valid);for ( i =1 ; i < opt_dom0_max_vcpus; i++ ) - (void )alloc_vcpu (d, i, i %num_online_cpus ()); + { + cpu =cycle_cpu (cpu, cpupool0->cpu_valid); + (void )alloc_vcpu (d, i, cpu); + }/* Set up CR3 value for write_ptbase */ if (paging_mode_enabled (d) )
xen/arch/x86/setup.c +6 -0
@@ -2,6 +2,7 @@#include <xen/init.h> #include <xen/lib.h> #include <xen/sched.h> +#include <xen/sched-if.h> #include <xen/domain.h> #include <xen/serial.h> #include <xen/softirq.h>
@@ -1093,6 +1094,11 @@ void __init __start_xen(unsigned long mbif ( !tboot_protect_mem_regions () )panic ("Could not protect TXT memory regions\n" ); +/* Create initial cpupool 0. */ + cpupool0 =cpupool_create (0 ,NULL ); +if ( (cpupool0 ==NULL ) ||cpupool0_cpu_assign (cpupool0) ) +panic ("Error creating cpupool 0\n" ); +/* Create initial domain 0. */ dom0 =domain_create (0 , DOMCRF_s3_integrity,DOM0_SSIDREF );if ( (dom0 ==NULL ) || (alloc_dom0_vcpu0 () ==NULL ) )
xen/arch/x86/smpboot.c +10 -4
@@ -39,6 +39,7 @@#include <xen/mm.h> #include <xen/domain.h> #include <xen/sched.h> +#include <xen/sched-if.h> #include <xen/irq.h> #include <xen/delay.h> #include <xen/softirq.h>
@@ -1296,10 +1297,11 @@ int __cpu_disable(void)remove_siblinginfo (cpu);/* It's now safe to remove this processor from the online map */ +cpu_clear (cpu, cpupool0->cpu_valid);cpu_clear (cpu, cpu_online_map);fixup_irqs (); -cpu_disable_scheduler (); +cpu_disable_scheduler (cpu,0 );return 0 ; }
@@ -1331,15 +1333,16 @@ int cpu_down(unsigned int cpu)int cpu_down (unsigned int cpu) {int err =0 ; +int pool_rm =0 ;/* spin_trylock() avoids deadlock with stop_machine_run(). */ if (!spin_trylock (&cpu_add_remove_lock))return -EBUSY ; - -if (num_online_cpus () ==1 ) { - err = -EBUSY ; + err =cpupool_cpu_remove (cpu); +if (err) { goto out; } + pool_rm =1 ;/* Can not offline BSP */ if (cpu ==0 ) {
@@ -1370,6 +1373,8 @@ out: out:if (!err)send_guest_global_virq (dom0,VIRQ_PCPU_STATE ); +else if (pool_rm) +cpupool_cpu_add (cpu);spin_unlock (&cpu_add_remove_lock);return err; }
@@ -1559,6 +1564,7 @@ int __devinit __cpu_up(unsigned int cpu)process_pending_softirqs (); } +cpupool_cpu_add (cpu);cpufreq_add_cpu (cpu);return 0 ; }
xen/common/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-y += bitmap.o obj-y += bitmap.o obj-y += cpu.o +obj-y += cpupool.o obj-y += domctl.o obj-y += domain.o obj-y += event_channel.o
xen/common/cpupool.c new file +604 -0
604 lines not on this page · raw message
xen/common/domain.c +8 -0
@@ -218,6 +218,7 @@ struct domain *domain_create(enum { INIT_xsm =1u <<0 , INIT_rangeset =1u <<1 , INIT_evtchn =1u <<2 , INIT_gnttab =1u <<3 , INIT_arch =1u <<4 };int init_status =0 ; +int poolid =CPUPOOLID_NONE ;if ( (d =alloc_domain_struct ()) ==NULL )return NULL ;
@@ -282,6 +283,8 @@ struct domain *domain_create(if (grant_table_create (d) !=0 ) goto fail; init_status |= INIT_gnttab; + + poolid =0 ; }if (arch_domain_create (d, domcr_flags) !=0 )
@@ -291,6 +294,9 @@ struct domain *domain_create( d->iomem_caps =rangeset_new (d,"I/O Memory" , RANGESETF_prettyprint_hex); d->irq_caps =rangeset_new (d,"Interrupts" ,0 );if ( (d->iomem_caps ==NULL ) || (d->irq_caps ==NULL ) ) + goto fail; + +if (cpupool_add_domain (d, poolid) !=0 ) goto fail;if (sched_init_domain (d) !=0 )
@@ -600,6 +606,8 @@ static void complete_domain_destroy(struarch_domain_destroy (d);rangeset_domain_destroy (d); + +cpupool_rm_domain (d);sched_destroy_domain (d);
xen/common/domctl.c +17 -4
@@ -11,6 +11,7 @@#include <xen/lib.h> #include <xen/mm.h> #include <xen/sched.h> +#include <xen/sched-if.h> #include <xen/domain.h> #include <xen/event.h> #include <xen/domain_page.h>
@@ -140,10 +141,12 @@ void getdomaininfo(struct domain *d, str info->shared_info_frame =mfn_to_gmfn (d,__pa (d->shared_info)>>PAGE_SHIFT );BUG_ON (SHARED_M2P (info->shared_info_frame)); + info->cpupool = d->cpupool ? d->cpupool->cpupool_id :CPUPOOLID_NONE ; +memcpy (info->handle, d->handle,sizeof (xen_domain_handle_t)); } -static unsigned int default_vcpu0_location (void ) +static unsigned int default_vcpu0_location (cpumask_t *online) {struct domain *d;struct vcpu *v;
@@ -173,7 +176,7 @@ static unsigned int default_vcpu0_locatiif (cpus_weight (per_cpu (cpu_sibling_map,0 )) >1 ) cpu =next_cpu (cpu,per_cpu (cpu_sibling_map,0 )); cpu_exclude_map =per_cpu (cpu_sibling_map,0 ); -for_each_online_cpu ( i ) +for_each_cpu_mask (i, *online) {if (cpu_isset (i, cpu_exclude_map) )continue ;
@@ -450,6 +453,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc {struct domain *d;unsigned int i, max = op->u.max_vcpus.max, cpu; +cpumask_t *online; ret = -ESRCH ;if ( (d =rcu_lock_domain_by_id (op->domain)) ==NULL )
@@ -498,6 +502,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc goto maxvcpu_out; ret = -ENOMEM ; + online = (d->cpupool ==NULL ) ? &cpu_online_map : &d->cpupool->cpu_valid;if ( max > d->max_vcpus ) {struct vcpu **vcpus;
@@ -521,8 +526,8 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domccontinue ; cpu = (i ==0 ) ? -default_vcpu0_location () : -cycle_cpu (d->vcpu[i-1 ]->processor, cpu_online_map); +default_vcpu0_location (online) : +cycle_cpu (d->vcpu[i-1 ]->processor, *online);if (alloc_vcpu (d, i, cpu) ==NULL ) goto maxvcpu_out;
@@ -961,6 +966,14 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc }break ; +case XEN_DOMCTL_cpupool_op: + { + ret =cpupool_do_domctl (&op->u.cpupool_op); +if ( (ret ==0 ) &©_to_guest (u_domctl, op,1 ) ) + ret = -EFAULT ; + } +break ; +default : ret =arch_do_domctl (op, u_domctl);break ;
xen/common/sched_credit.c +276 -139
864 lines not on this page · raw message
xen/common/sched_credit2.c +189 -114
607 lines not on this page · raw message
xen/common/sched_sedf.c +104 -52
278 lines not on this page · raw message
xen/common/schedule.c +254 -46
436 lines not on this page · raw message
xen/include/xen/sched-if.h +45 -15
60 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Part of the diff is not shown here. View the raw message.