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

Re: [Xen-devel] Question about xentrace to trace s_time_t type of data



On Mon, Aug 25, 2014 at 11:14:52AM -0400, Meng Xu wrote:
> Hi Konrad,
> 
> Thank you very much for answering my question!
> 
> âI actually have a question regarding to your answer.
> 
> Briefly speaking, I'm thinking what you suggests is doing the same (or
> similar) thing as I did? Below is my reason.
> 
> 
> > >
> > > I'm trying to trace the scheduler-specific events for debug purpose by
> > > using xentrace (instead of using printk). I read the trace code in credit
> > > and credit2 scheduler (sched_credit.c and sched_credit2.c) and "followed"
> > > the way credit2 wrote.
> > >
> > > I added the following code into the burn_budget() in my scheduler file,
> > > sched_rt.c:
> > >
> > >         /* TRACE */
> > >
> > >         {
> > >
> > >             struct {
> > >
> > >                 unsigned dom:16,vcpu:16;
> > >
> > >                 s_time_t cur_budget;
> > >
> > >             } d;
> > >
> > >             d.dom = svc->vcpu->domain->domain_id;
> > >
> > >             d.vcpu = svc->vcpu->vcpu_id;
> > >
> > >             d.cur_budget = svc->cur_budget;
> > >
> > >             trace_var(TRC_RT_BUDGET_REPLENISH, 1,
> > >
> > >                       sizeof(d),
> > >
> > >                       (unsigned char *) &d);
> >
> > You put the virtual address addresss of your 'd' structure
> > that is on the stack in the trace file. That does not contain any
> > data except an address.
> >
> > What you need to do is to put the data as such:
> >
> >         uint32_t dom_vcpu;
> >
> >         dom_vcpu = srv->vcpu->domain->domain_id;
> >         dom_vcpu |= (svc->vcpu->vcpu_id << 16);
> >         TRACE_2D(TRC_RT_BUDGET_REPLENISH, dom_vcpu, svc->cur_budget);
> >
> 
> âIn file xen/include/xen/trace.h, TRACE_2D is defined as follows:
> 
> #define TRACE_2D(_e,d1,d2)                                      \
> 
>     do {                                                        \
> 
>         if ( unlikely(tb_init_done) )                           \
> 
>         {                                                       \
> 
>             u32 _d[2];                                          \
> 
>             _d[0] = d1;                                         \
> 
>             _d[1] = d2;                                         \
> 
>             __trace_var(_e, 1, sizeof(_d), _d);                 \
> 
>         }                                                       \
>     } while ( 0 )â
> 
> 
> 
> âIn the same file, the trace_var() is defined as follows:
> 
> static inline void trace_var(u32 event, int cycles, int extra,
> 
>                              const void *extra_data)
> 
> {
> 
>     if ( unlikely(tb_init_done) )
> 
>         __trace_var(event, cycles, extra, extra_data);
> }   â
> 
> â
> The description of the function __trace_var(u32 event, bool_t cycles,
> unsigned int extra,const void *extra_data) is in xen/common/trace.c:
> 
> /**
> 
>  * __trace_var - Enters a trace tuple into the trace buffer for the current
> CPU.
> 
>  * @event: the event type being logged
> 
>  * @cycles: include tsc timestamp into trace record
> 
>  * @extra: size of additional trace data in bytes
> 
>  * @extra_data: pointer to additional trace data
> 
>  *
> 
>  * Logs a trace record into the appropriate buffer.
>  */â
> 
> 
> So I'm thinking what you suggests is doing the same (or similar) thing as I
> did? In addition, from the description of the function __trace_var() , it
> seems I should parse the pointer of the struct d to this function.
> 
> âMaybe I misunderstood your suggestion?
> 
> Thank you very much for your time!

I have to be honest I hadn't actually dug in what was underneath
the macro. Just been using the macro and it had worked for me.


> 
> Best,
> 
> Mengâ
> 
> 
> 
> 
> -----------
> Meng Xu
> PhD Student in Computer and Information Science
> University of Pennsylvania

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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