xenperf hypercall pretty print TAKE 2
RFC PATCH 1/1 xenperf hypercall pretty print TAKE 2
This patch pretty prints the hypercall section for
$xenperf -f
Each hypercall count is tagged by its name.
Reference:
http://lists.xensource.com/archives/html/xen-ia64-devel/2006-08/msg00261.html
Signed-off-by Ken Hironaka <[email protected]>
tools/misc/xenperf.c +77 -4
@@ -10,13 +10,81 @@* Description: */ -#include <xenctrl.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <errno.h> #include <string.h> + +const char * hypercall_name_table[64 ]= +{ + [__HYPERVISOR_set_trap_table] ="set_trap_table" ,/*0*/ + [__HYPERVISOR_mmu_update] ="mmu_update" ,/*1*/ + [__HYPERVISOR_set_gdt] ="set_gdt" ,/*2*/ + [__HYPERVISOR_stack_switch] ="stack_switch" ,/*3*/ + [__HYPERVISOR_set_callbacks] ="set_callbacks" ,/*4*/ + [__HYPERVISOR_fpu_taskswitch] ="fpu_taskswitch" ,/*5*/ + [__HYPERVISOR_sched_op_compat] ="sched_op_compat" ,/*6*/ + [__HYPERVISOR_dom0_op] ="dom0_op" ,/*7*/ + [__HYPERVISOR_set_debugreg] ="set_debugreg" ,/*8*/ + [__HYPERVISOR_get_debugreg] ="get_debugreg" ,/*9*/ + [__HYPERVISOR_update_descriptor] ="update_descriptor" ,/*10*/ + [11 ] ="NULL" ,/*11*/ + [__HYPERVISOR_memory_op] ="memory_op" ,/*12*/ + [__HYPERVISOR_multicall] ="multicall" ,/*13*/ + [__HYPERVISOR_update_va_mapping] ="update_va_mapping" ,/*14*/ + [__HYPERVISOR_set_timer_op] ="set_timer_op" ,/*15*/ + [__HYPERVISOR_event_channel_op_compat] ="event_channel_op_compat" ,/*16 compat since 0x00030202 */ + [__HYPERVISOR_xen_version] ="xen_version" ,/*17*/ + [__HYPERVISOR_console_io] ="console_io" ,/*18*/ + [__HYPERVISOR_physdev_op_compat] ="physdev_op_compat" ,/*19 compat since 0x00030202 */ + [__HYPERVISOR_grant_table_op] ="grant_table_op" ,/*20*/ + [__HYPERVISOR_vm_assist] ="vm_assist" ,/*21*/ + [__HYPERVISOR_update_va_mapping_otherdomain] ="update_va_mapping_otherdomain" ,/*22*/ + [__HYPERVISOR_iret] ="iret" ,/*23 x86 only */ + [__HYPERVISOR_vcpu_op] ="vcpu_op" ,/*24*/ + [__HYPERVISOR_set_segment_base] ="set_segment_base" ,/*25 x86/64 only */ + [__HYPERVISOR_mmuext_op] ="mmuext_op" ,/*26*/ + [__HYPERVISOR_acm_op] ="acm_op" ,/*27*/ + [__HYPERVISOR_nmi_op] ="nmi_op" ,/*28*/ + [__HYPERVISOR_sched_op] ="sched_op" ,/*29*/ + [__HYPERVISOR_callback_op] ="callback_op" ,/*30*/ + [__HYPERVISOR_xenoprof_op] ="xenoprof_op" ,/*31*/ + [__HYPERVISOR_event_channel_op] ="event_channel_op" ,/*32*/ + [__HYPERVISOR_physdev_op] ="physdev_op" ,/*33*/ + [__HYPERVISOR_hvm_op] ="hvm_op" ,/*34*/ + [35 ] ="NULL" ,/*35*/ + [36 ] ="NULL" ,/*36*/ + [37 ] ="NULL" ,/*37*/ + [38 ] ="NULL" ,/*38*/ + [39 ] ="NULL" ,/*39*/ + [40 ] ="NULL" ,/*40*/ + [41 ] ="NULL" ,/*41*/ + [42 ] ="NULL" ,/*42*/ + [43 ] ="NULL" ,/*43*/ + [44 ] ="NULL" ,/*44*/ + [45 ] ="NULL" ,/*45*/ + [46 ] ="NULL" ,/*46*/ + [47 ] ="NULL" ,/*47*/ +/* Architecture-specific hypercall definitions. */ + [__HYPERVISOR_arch_0] ="arch_0" ,/*48*/ + [__HYPERVISOR_arch_1] ="arch_1" ,/*49*/ + [__HYPERVISOR_arch_2] ="arch_2" ,/*50*/ + [__HYPERVISOR_arch_3] ="arch_3" ,/*51*/ + [__HYPERVISOR_arch_4] ="arch_4" ,/*52*/ + [__HYPERVISOR_arch_5] ="arch_5" ,/*53*/ + [__HYPERVISOR_arch_6] ="arch_6" ,/*54*/ + [__HYPERVISOR_arch_7] ="arch_7" ,/*55*/ + [56 ] ="NULL" ,/*56*/ + [57 ] ="NULL" ,/*57*/ + [58 ] ="NULL" ,/*58*/ + [59 ] ="NULL" ,/*59*/ + [60 ] ="NULL" ,/*60*/ + [61 ] ="NULL" ,/*61*/ + [62 ] ="NULL" ,/*62*/ + [63 ] ="NULL" /*63*/ +};int main (int argc,char *argv[]) {
@@ -117,10 +185,15 @@ int main(int argc, char *argv[]) sum += val[j];printf ("T=%10u " , (unsigned int )sum); -if ( full || (pcd[i].nr_vals <=4 ) ) +if ( full || (pcd[i].nr_vals <=4 ) ){ +if (strcmp (pcd[i].name,"hypercalls" ) ==0 ){ +for ( j =0 ; j < pcd[i].nr_vals; j++ ) +printf ("%s\t" , hypercall_name_table[j]); +printf ("\n" ); + }for ( j =0 ; j < pcd[i].nr_vals; j++ ) -printf (" %10u" , (unsigned int )val[j]); - +printf (" %10u" , (unsigned int )val[j]); + }printf ("\n" ); val += pcd[i].nr_vals; }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 5 lines · Ken Hironaka
--=-yBSrtz68cegIGbb41dH7
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Quoted 8 lines
This patch pretty prints the hypercall section for
$xenperf -f
Each hypercall count is tagged by its name.
Reference:
http://lists.xensource.com/archives/html/xen-ia64-devel/2006-08/msg00261.html
Hi Ken,
I have put some formating comments inline.
Quoted 80 lines
Signed-off-by Ken Hironaka <[email protected]>
--=-yBSrtz68cegIGbb41dH7
Content-Disposition: attachment; filename=xenperf.v2.patch
Content-Type: text/x-patch; name=xenperf.v2.patch; charset=us-ascii
Content-Transfer-Encoding: 7bitdiff -r
3e54734e55f3tools/misc/xenperf.ctools/misc/xenperf.c +59
-1@@ -10,13 +10,81 @@* Description: */ -#include <xenctrl.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <errno.h> #include <string.h> + +const char * hypercall_name_table[64 ]= +{ + [__HYPERVISOR_set_trap_table] ="set_trap_table" ,/*0*/ + [__HYPERVISOR_mmu_update] ="mmu_update" ,/*1*/ + [__HYPERVISOR_set_gdt] ="set_gdt" ,/*2*/ + [__HYPERVISOR_stack_switch] ="stack_switch" ,/*3*/ + [__HYPERVISOR_set_callbacks] ="set_callbacks" ,/*4*/ + [__HYPERVISOR_fpu_taskswitch] ="fpu_taskswitch" ,/*5*/ + [__HYPERVISOR_sched_op_compat] ="sched_op_compat" ,/*6*/ + [__HYPERVISOR_dom0_op] ="dom0_op" ,/*7*/ + [__HYPERVISOR_set_debugreg] ="set_debugreg" ,/*8*/ + [__HYPERVISOR_get_debugreg] ="get_debugreg" ,/*9*/ + [__HYPERVISOR_update_descriptor] ="update_descriptor" ,/*10*/ + [11 ] ="NULL" ,/*11*/ + [__HYPERVISOR_memory_op] ="memory_op" ,/*12*/ + [__HYPERVISOR_multicall] ="multicall" ,/*13*/ + [__HYPERVISOR_update_va_mapping] ="update_va_mapping" ,/*14*/ + [__HYPERVISOR_set_timer_op] ="set_timer_op" ,/*15*/ + [__HYPERVISOR_event_channel_op_compat] ="event_channel_op_compat" ,/*16 compat since 0x00030202 */ + [__HYPERVISOR_xen_version] ="xen_version" ,/*17*/ + [__HYPERVISOR_console_io] ="console_io" ,/*18*/ + [__HYPERVISOR_physdev_op_compat] ="physdev_op_compat" ,/*19 compat since 0x00030202 */ + [__HYPERVISOR_grant_table_op] ="grant_table_op" ,/*20*/ + [__HYPERVISOR_vm_assist] ="vm_assist" ,/*21*/ + [__HYPERVISOR_update_va_mapping_otherdomain] ="update_va_mapping_otherdomain" ,/*22*/ + [__HYPERVISOR_iret] ="iret" ,/*23 x86 only */ + [__HYPERVISOR_vcpu_op] ="vcpu_op" ,/*24*/ + [__HYPERVISOR_set_segment_base] ="set_segment_base" ,/*25 x86/64 only */ + [__HYPERVISOR_mmuext_op] ="mmuext_op" ,/*26*/ + [__HYPERVISOR_acm_op] ="acm_op" ,/*27*/ + [__HYPERVISOR_nmi_op] ="nmi_op" ,/*28*/ + [__HYPERVISOR_sched_op] ="sched_op" ,/*29*/ + [__HYPERVISOR_callback_op] ="callback_op" ,/*30*/ + [__HYPERVISOR_xenoprof_op] ="xenoprof_op" ,/*31*/ + [__HYPERVISOR_event_channel_op] ="event_channel_op" ,/*32*/ + [__HYPERVISOR_physdev_op] ="physdev_op" ,/*33*/ + [__HYPERVISOR_hvm_op] ="hvm_op" ,/*34*/ + [35 ] ="NULL" ,/*35*/ + [36 ] ="NULL" ,/*36*/ + [37 ] ="NULL" ,/*37*/ + [38 ] ="NULL" ,/*38*/ + [39 ] ="NULL" ,/*39*/ + [40 ] ="NULL" ,/*40*/ + [41 ] ="NULL" ,/*41*/ + [42 ] ="NULL" ,/*42*/ + [43 ] ="NULL" ,/*43*/ + [44 ] ="NULL" ,/*44*/ + [45 ] ="NULL" ,/*45*/ + [46 ] ="NULL" ,/*46*/ + [47 ] ="NULL" ,/*47*/ +/* Architecture-specific hypercall definitions. */ + [__HYPERVISOR_arch_0] ="arch_0" ,/*48*/ + [__HYPERVISOR_arch_1] ="arch_1" ,/*49*/ + [__HYPERVISOR_arch_2] ="arch_2" ,/*50*/ + [__HYPERVISOR_arch_3] ="arch_3" ,/*51*/ + [__HYPERVISOR_arch_4] ="arch_4" ,/*52*/ + [__HYPERVISOR_arch_5] ="arch_5" ,/*53*/ + [__HYPERVISOR_arch_6] ="arch_6" ,/*54*/
tools/misc/xenperf.c line 87
Quoted 10 lines
tools/misc/xenperf.c +10
-0+ [__HYPERVISOR_arch_7] = "arch_7", /*55*/ + [56] = "NULL", /*56*/ + [57] = "NULL", /*57*/ + [58] = "NULL", /*58*/ + [59] = "NULL", /*59*/ + [60] = "NULL", /*60*/ + [61] = "NULL", /*61*/ + [62] = "NULL", /*62*/ + [63] = "NULL" /*63*/ +};
Is it possible for the above code to be sanely reformated into < 80 columns wide?
tools/misc/xenperf.c int main(int argc, char *argv[]) · line 188
Quoted 8 lines
tools/misc/xenperf.c +1
-1int main (int argc,char *argv[]) {@@ -117,10 +185,15 @@ int main(int argc, char *argv[]) sum += val[j];printf ("T=%10u " , (unsigned int )sum); -if ( full || (pcd[i].nr_vals <=4 ) ) +if ( full || (pcd[i].nr_vals <=4 ) ){
The prevailing coding style seems to palce the trailing { on a newling
if ( full || (pcd[i].nr_vals <= 4) )
{Ditto for the if statement on the following line.
tools/misc/xenperf.c int main(int argc, char *argv[]) · line 195
Quoted 9 lines
tools/misc/xenperf.c +6
-2+if (strcmp (pcd[i].name,"hypercalls" ) ==0 ){ +for ( j =0 ; j < pcd[i].nr_vals; j++ ) +printf ("%s\t" , hypercall_name_table[j]); +printf ("\n" ); + }for ( j =0 ; j < pcd[i].nr_vals; j++ ) -printf (" %10u" , (unsigned int )val[j]); - +printf (" %10u" , (unsigned int )val[j]);
The change in the line immediately above is bogus as it only introduces trailing whitespace.
tools/misc/xenperf.c int main(int argc, char *argv[]) · line 198
Quoted 3 lines
tools/misc/xenperf.c +1
-0+ }printf ("\n" ); val += pcd[i].nr_vals;
While whe are here, is it possible to convert the two tabs in the line above into 8 spaces to make it consistent with the rest of the indentation in this snippet?
Quoted 1 line
tools/misc/xenperf.c +0
-0}
Signature · 3 lines
Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/