[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] Re: [PATCH][RFC]xenperf hypercall pretty print TAKE 2



On Fri, 25 Aug 2006 11:59:32 +0900, Ken Hironaka wrote:
> 
> --=-yBSrtz68cegIGbb41dH7
> Content-Type: text/plain
> Content-Transfer-Encoding: 7bit
> 
> 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.

> Signed-off-by Ken Hironaka <kenny@xxxxxxxxxxxxxxxxxxxxxxxx>
> 
> --=-yBSrtz68cegIGbb41dH7
> Content-Disposition: attachment; filename=xenperf.v2.patch
> Content-Type: text/x-patch; name=xenperf.v2.patch; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> diff -r 3e54734e55f3 tools/misc/xenperf.c
> --- a/tools/misc/xenperf.c    Wed Aug 23 13:26:46 2006 -0600
> +++ b/tools/misc/xenperf.c    Thu Aug 24 18:01:41 2006 +0900
> @@ -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*/
> +};

Is it possible for the above code to be sanely reformated
into < 80 columns wide?

> 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) ){

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.

> +            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.

> +        }
>         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?

>     }



-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.