Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


gcc-instrumenation added
[palacios.git] / palacios / src / palacios / vmm_instrument.c
1 /*
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Chang Bae <c.s.bae@u.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #ifdef INSTRUMENT_VMM
21  
22 #include <palacios/svm_handler.h>
23 #include <palacios/vmm_instrument.h>
24 #include <palacios/vmm_ringbuffer.h>
25  
26 void __attribute__((__no_instrument_function__)) v3_init_cyg_profiler (){
27
28 // initialize
29
30         v3_Inst_RingBuff_init (&ring_buff, 2048); //dequeue at every 4095
31         
32         instrument_start = 1;
33         
34 }
35
36 static void inline __attribute__((__no_instrument_function__)) read_cyg_profiler (){
37
38                 while( v3_Inst_RingBuff_data_size(ring_buff) > 0) {
39
40                 v3_Inst_RingBuff_read (ring_buff, pack_data, 1); 
41                 PrintDebug("CYG_PROF: %d %8lu %08x %08x\n", pack_data->state, (unsigned long)pack_data->time, pack_data->cur_fn, pack_data->pre_fn);    
42         
43                 }       
44 }
45
46 void __attribute__((__no_instrument_function__))
47 __cyg_profile_func_enter( void *this, void *callsite )
48 {
49                 
50         if(instrument_start > 0) {
51
52         rdtscll(now);
53         
54         if((v3_Inst_RingBuff_data_size(ring_buff) % 500) == 0 || v3_Inst_RingBuff_data_size(ring_buff) == 4095) {
55         read_cyg_profiler();
56         }
57   
58   
59   pack_data->time = now - last; //time spent previous
60   pack_data->state = 0; //enter to be 0
61   pack_data->cur_fn = (unsigned int)this; //this
62   pack_data->pre_fn = (unsigned int)callsite; //callsite
63
64         v3_Inst_RingBuff_write (ring_buff, pack_data, 1);  
65
66   rdtscll(now);
67   last = now;
68         }
69 }
70
71 void __attribute__((__no_instrument_function__)) 
72 __cyg_profile_func_exit( void *this, void *callsite )
73 {
74         if(instrument_start > 0 ) {
75         rdtscll(now);
76
77         if((v3_Inst_RingBuff_data_size(ring_buff) % 500) == 0 || v3_Inst_RingBuff_data_size(ring_buff) == 4095) {
78         read_cyg_profiler();
79         }
80   
81   pack_data->time = now - last; //time spent previous
82   pack_data->state = 1; //exit to be 0
83   pack_data->cur_fn = (unsigned int)this; //this
84   pack_data->pre_fn = (unsigned int)callsite; //callsite
85   
86   v3_Inst_RingBuff_write (ring_buff, pack_data, 1);
87   
88   rdtscll(now);
89   last = now;
90         }
91 }
92
93 #endif