Xenoprof passive domain support
Quoted 3 lines
I tried the patch. The build of a xen0 kernel fails with:
arch/i386/oprofile/../../../drivers/oprofile/oprof.c:41: error:
?MAX_OPROF_DOMAINS? undeclared here (not in a function)
Steve,
Sorry for late response, for I'm taking vacation this week. Thanks for pointing this out. For me it's easy to make mistake to produce a patch of a patch. I may write a script to do this:)
Thanks,
Xiaowei
Add Xenoprof passive domain support
Signed-off-by Yang Xiaowei <[email protected]>
linux-2.6-xen-sparse/arch/i386/oprofile/xenoprof.c +119 -12
@@ -50,6 +50,11 @@/* cpu model type string - copied from Xen memory space on XENOPROF_init command */ char cpu_type[XENOPROF_CPU_TYPE_SIZE ]; +/* Passive sample buffers shared with Xen */ +xenoprof_buf_t *p_xenoprof_buf[MAX_OPROF_DOMAINS ][MAX_VIRT_CPUS ]; +/* Passive shared buffer area */ +char *p_shared_buffer[MAX_OPROF_DOMAINS ]; +#ifdef CONFIG_PM static int xenoprof_suspend (struct sys_device * dev,pm_message_t state)
@@ -102,16 +107,14 @@#endif /* CONFIG_PM */ unsigned long long oprofile_samples =0 ; - -static irqreturn_t -xenoprof_ovf_interrupt (int irq,void * dev_id,struct pt_regs * regs) +unsigned long long p_oprofile_samples =0 ; + +extern unsigned int pdomains; +extern struct xenoprof_passive passive_domains[MAX_OPROF_DOMAINS ]; + +static void xenoprof_add_pc (xenoprof_buf_t *buf,int is_passive) {int head, tail, size; -struct xenoprof_buf * buf; -int cpu; - - cpu =smp_processor_id (); - buf = xenoprof_buf[cpu]; head = buf->event_head; tail = buf->event_tail;
@@ -122,7 +125,10 @@oprofile_add_pc (buf->event_log[tail].eip, buf->event_log[tail].mode, buf->event_log[tail].event); - oprofile_samples++; +if (!is_passive) + oprofile_samples++; +else + p_oprofile_samples++; tail++; } tail =0 ;
@@ -131,11 +137,48 @@oprofile_add_pc (buf->event_log[tail].eip, buf->event_log[tail].mode, buf->event_log[tail].event); - oprofile_samples++; +if (!is_passive) + oprofile_samples++; +else + p_oprofile_samples++; tail++; } buf->event_tail = tail; +} + +static void xenoprof_handle_passive (void ) +{ +int i, j; + +for (i =0 ; i < pdomains; i++) +for (j =0 ; j < passive_domains[i].nbuf; j++) { +xenoprof_buf_t *buf = p_xenoprof_buf[i][j]; +if (buf->event_head == buf->event_tail) +continue ; +oprofile_add_pc (0 ,3 , passive_domains[i].domain_id); +xenoprof_add_pc (buf,1 ); +oprofile_add_pc (0 ,4 , passive_domains[i].domain_id); + } +} + +DECLARE_MUTEX (xenoprof_sem); + +static irqreturn_t +xenoprof_ovf_interrupt (int irq,void * dev_id,struct pt_regs * regs) +{ +struct xenoprof_buf * buf; +int cpu; + + cpu =smp_processor_id (); + buf = xenoprof_buf[cpu]; + +xenoprof_add_pc (buf,0 ); + +if (is_primary && !down_trylock (&xenoprof_sem)) { +xenoprof_handle_passive (); +up (&xenoprof_sem); + }return IRQ_HANDLED ; }
@@ -318,6 +361,60 @@ } active_defined =1 ; +return ret; +} + +static int xenoprof_set_passive (struct xenoprof_passive *passive_domains, +unsigned int pdomains) +{ +int ret; +int i, j; +int vm_size; +int npages; +struct xenoprof_buf *buf; +pgprot_t prot =__pgprot (_KERNPG_TABLE); + +if (!is_primary) +return 0 ; + +if (pdomains >MAX_OPROF_DOMAINS ) +return -E2BIG ; + + ret =HYPERVISOR_xenoprof_op (XENOPROF_reset_passive_list,NULL ); +if (ret) +return ret; + +for (i =0 ; i < pdomains; i++) { + ret =HYPERVISOR_xenoprof_op (XENOPROF_set_passive, &passive_domains[i]); +if (ret) +return ret; + + npages = (passive_domains[i].bufsize * passive_domains[i].nbuf -1 ) /PAGE_SIZE +1 ; + vm_size = npages *PAGE_SIZE ; + + p_shared_buffer[i] = (char *)vm_map_xen_pages (passive_domains[i].buf_maddr, + vm_size, prot); +if (!p_shared_buffer[i]) { + ret = -ENOMEM ; + goto out; + } + +for (j =0 ; j < passive_domains[i].nbuf; j++) { + buf = (struct xenoprof_buf *) + &p_shared_buffer[i][j * passive_domains[i].bufsize]; +BUG_ON (buf->vcpu_id >=MAX_VIRT_CPUS ); + p_xenoprof_buf[i][buf->vcpu_id] = buf; + } + + } +return 0 ; + +out: +for (j =0 ; j < i; j++) { +vunmap (p_shared_buffer[j]); + p_shared_buffer[j] =NULL ; + } +return ret; }
@@ -355,6 +452,7 @@struct oprofile_operations xenoprof_ops = { .create_files = xenoprof_create_files, .set_active = xenoprof_set_active, + .set_passive = xenoprof_set_passive, .setup = xenoprof_setup, .shutdown = xenoprof_shutdown, .start = xenoprof_start,
@@ -429,6 +527,8 @@ void __exit oprofile_arch_exit(void) { +int i; +if (using_xenoprof)exit_driverfs ();
@@ -436,6 +536,13 @@vunmap (shared_buffer); shared_buffer =NULL ; } -if (is_primary) +if (is_primary) { +for (i =0 ; i < pdomains; i++) +if (p_shared_buffer[i]) { +vunmap (p_shared_buffer[i]); + p_shared_buffer[i] =NULL ; + }HYPERVISOR_xenoprof_op (XENOPROF_shutdown,NULL ); -} + } + +}
patches/linux-2.6.16/xenoprof-generic.patch +165 -48
354 lines not on this page · raw message
xen/arch/x86/domain.c +0 -1
@@ -956,7 +956,6 @@/* Free page used by xen oprofile buffer */ free_xenoprof_pages (d); - }void arch_dump_domain_info (struct domain *d)
xen/arch/x86/hvm/vmx/vmx.c +1 -0
@@ -2069,6 +2069,7 @@ }__vmread (GUEST_RIP , &eip); + regs.eip = eip;TRACE_VMEXIT (0 ,exit_reason);switch (exit_reason) {
xen/arch/x86/oprofile/nmi_int.c +1 -1
@@ -269,7 +269,7 @@ {__u8 cpu_model = current_cpu_data.x86_model; -if (cpu_model >4 ) +if (cpu_model >7 )return 0 ;#ifndef CONFIG_SMP
xen/arch/x86/oprofile/xenoprof.c +92 -6
192 lines not on this page · raw message
xen/include/public/xenoprof.h +9 -0
@@ -77,6 +77,15 @@ } xenoprof_counter_t;DEFINE_XEN_GUEST_HANDLE (xenoprof_counter_t); +typedef struct xenoprof_passive { +uint16_t domain_id; +int32_t max_samples; +int32_t nbuf; +int32_t bufsize; +uint64_t buf_maddr; +}xenoprof_passive_t ; +DEFINE_XEN_GUEST_HANDLE (xenoprof_passive_t); +#endif /* __XEN_PUBLIC_XENOPROF_H__ */
xen/include/xen/xenoprof.h +1 -0
@@ -14,6 +14,7 @@#define XENOPROF_DOMAIN_IGNORED 0#define XENOPROF_DOMAIN_ACTIVE 1 +#define XENOPROF_DOMAIN_PASSIVE 2#define XENOPROF_IDLE 0#define XENOPROF_COUNTERS_RESERVED 1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel