xen/trace: Misc improvements
cover xen/trace: Misc improvements
Misc fixes/improvements to trace.h noticed during the build fix for !CONFIG_TRACEBUFFER
Andrew Cooper (3):
xen/trace: Add trace.h to MAINTAINER
xen/trace: Implement TRACE_?D() in a more efficient fashon xen/trace: Adjust types in function declarations
MAINTAINERS | 1 + xen/include/xen/trace.h | 105 +++++++++++++----------------------------------- 2 files changed, 30 insertions(+), 76 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/3 xen/trace: Add trace.h to MAINTAINER
... to match the existing trace.c entry
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -513,6 +513,7 @@ M: George Dunlap <[email protected]> S: Supported F: tools/xentrace/ F: xen/common/trace.c +F: xen/include/xen/trace.h XSM/FLASK M: Daniel De Graaf <[email protected]>
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 1/3] xen/trace: Add trace.h to MAINTAINER
Quoted 8 lines · Andrew Cooper
... to match the existing
trace.centryReported-by Jan Beulich <[email protected]>Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/3 xen/trace: Implement TRACE_?D() in a more efficient fashon
In reply to Andrew CooperThese can easily be expressed with a variadic macro. No functional change.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
Interestingly, this results in fractionally different (but equally correct) code generation in vlapic_update_timer(). Everywhere else is identical.
--- xen/include/xen/trace.h | 99 +++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 73 deletions(-)
xen/include/xen/trace.h +26 -73
@@ -81,80 +81,33 @@ static inline void __trace_hypercall(uint32_t event, unsigned long op,do { \trace_var (_e,1 ,0 ,NULL ); \ }while (0 ) - -#define TRACE_1D (_e,d1) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[1]; \ - _d[0] = d1; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ - } while ( 0 ) - -#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 ) - -#define TRACE_3D (_e,d1,d2,d3) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[3]; \ - _d[0] = d1; \ - _d[1] = d2; \ - _d[2] = d3; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ - } while ( 0 ) - -#define TRACE_4D (_e,d1,d2,d3,d4) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[4]; \ - _d[0] = d1; \ - _d[1] = d2; \ - _d[2] = d3; \ - _d[3] = d4; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ - } while ( 0 ) - -#define TRACE_5D (_e,d1,d2,d3,d4,d5) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[5]; \ - _d[0] = d1; \ - _d[1] = d2; \ - _d[2] = d3; \ - _d[3] = d4; \ - _d[4] = d5; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ - } while ( 0 ) -#define TRACE_6D (_e,d1,d2,d3,d4,d5,d6) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[6]; \ - _d[0] = d1; \ - _d[1] = d2; \ - _d[2] = d3; \ - _d[3] = d4; \ - _d[4] = d5; \ - _d[5] = d6; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ +/* Common helper for TRACE_{1..6}D() below. */ +#define TRACE_varD (_e, ...) \ + do { \ + if ( unlikely(tb_init_done) ) \ + { \ + uint32_t _d[] = { __VA_ARGS__ }; \ + __trace_var(_e, true, sizeof(_d), _d); \ + } \ } while ( 0 ) +#define TRACE_1D (_e, d1) \ + TRACE_varD(_e, d1) + +#define TRACE_2D (_e, d1, d2) \ + TRACE_varD(_e, d1, d2) + +#define TRACE_3D (_e, d1, d2, d3) \ + TRACE_varD(_e, d1, d2, d3) + +#define TRACE_4D (_e, d1, d2, d3, d4) \ + TRACE_varD(_e, d1, d2, d3, d4) + +#define TRACE_5D (_e, d1, d2, d3, d4, d5) \ + TRACE_varD(_e, d1, d2, d3, d4, d5) + +#define TRACE_6D (_e, d1, d2, d3, d4, d5, d6) \ + TRACE_varD(_e, d1, d2, d3, d4, d5, d6) +#endif /* __XEN_TRACE_H__ */
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 2/3] xen/trace: Implement TRACE_?D() in a more efficient fashon
Quoted 97 lines · Andrew Cooper
These can easily be expressed with a variadic macro. No functional change.
Signed-off-by Andrew Cooper <[email protected]>---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>Interestingly, this results in fractionally different (but equally correct) code generation in
vlapic_update_timer(). Everywhere else is identical.
---xen/include/xen/trace.h| 99 +++++++++++++------------------------------------1 file changed, 26 insertions(+), 73 deletions(-)xen/include/xen/trace.h +0
-69@@ -81,80 +81,33 @@ static inline void __trace_hypercall(uint32_t event, unsigned long op,do { \trace_var (_e,1 ,0 ,NULL ); \ }while (0 ) - -#define TRACE_1D (_e,d1) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[1]; \ - _d[0] = d1; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ - } while ( 0 ) - -#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 ) - -#define TRACE_3D (_e,d1,d2,d3) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[3]; \ - _d[0] = d1; \ - _d[1] = d2; \ - _d[2] = d3; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ - } while ( 0 ) - -#define TRACE_4D (_e,d1,d2,d3,d4) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[4]; \ - _d[0] = d1; \ - _d[1] = d2; \ - _d[2] = d3; \ - _d[3] = d4; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ - } while ( 0 ) - -#define TRACE_5D (_e,d1,d2,d3,d4,d5) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[5]; \ - _d[0] = d1; \ - _d[1] = d2; \ - _d[2] = d3; \ - _d[3] = d4; \ - _d[4] = d5; \ - __trace_var(_e, 1, sizeof(_d), _d); \ - } \ - } while ( 0 ) -#define TRACE_6D (_e,d1,d2,d3,d4,d5,d6) \ - do { \ - if ( unlikely(tb_init_done) ) \ - { \ - u32 _d[6]; \ - _d[0] = d1; \ - _d[1] = d2; \ - _d[2] = d3; \ - _d[3] = d4; \
xen/include/xen/trace.h static inline void __trace_hypercall(uint32_t event, unsigned long op, · line 90
Quoted 10 lines
xen/include/xen/trace.h +6
-4- _d[4 ] = d5; \ - _d[5 ] = d6; \ -__trace_var (_e,1 ,sizeof (_d), _d); \ - } \ +/* Common helper for TRACE_{1..6}D() below. */ +#define TRACE_varD (_e, ...) \ + do { \ + if ( unlikely(tb_init_done) ) \ + { \ + uint32_t _d[] = { __VA_ARGS__ }; \
Just to check — this will clip any larger values to uint32_t?
If so:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 2/3] xen/trace: Implement TRACE_?D() in a more efficient fashon
Quoted 7 lines · George Dunlap
xen/include/xen/trace.h static inline void __trace_hypercall(uint32_t event, unsigned long op, · line 90
Quoted 6 lines
xen/include/xen/trace.h +6
-0+/* Common helper for TRACE_{1..6}D() below. */ +#define TRACE_varD (_e, ...) \ + do { \ + if ( unlikely(tb_init_done) ) \ + { \ + uint32_t _d[] = { __VA_ARGS__ }; \Just to check — this will clip any larger values to
uint32_t?
Yes. Each array element will be truncated based on its type.
Quoted 4 lines
If so:
Acked-by George Dunlap <[email protected]>
Thanks,
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/3 xen/trace: Adjust types in function declarations
In reply to Andrew CooperUse uint32_t consistently for 'event', bool consistently for 'cycles', and unsigned int consistently for 'extra'
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/include/xen/trace.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
xen/include/xen/trace.h +3 -3
@@ -41,9 +41,9 @@ int tb_control(struct xen_sysctl_tbuf_op *tbc);int trace_will_trace_event (u32 event); -void __trace_var (u32 event,bool_t cycles,unsigned int extra,const void *); +void __trace_var (uint32_t event,bool cycles,unsigned int extra,const void *); -static inline void trace_var (u32 event,int cycles,int extra, +static inline void trace_var (uint32_t event,bool cycles,unsigned int extra,const void *extra_data) {if (unlikely (tb_init_done) )
@@ -68,7 +68,7 @@ static inline int trace_will_trace_event(uint32_t event)return 0 ; } -static inline void trace_var (uint32_t event,int cycles,int extra, +static inline void trace_var (uint32_t event,bool cycles,unsigned int extra,const void *extra_data) {}static inline void __trace_var (uint32_t event,bool cycles,unsigned int extra,const void *extra_data) {}
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 3/3] xen/trace: Adjust types in function declarations
Quoted 8 lines · Andrew Cooper
Use
uint32_tconsistently for 'event', bool consistently for 'cycles', and unsigned int consistently for 'extra'Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel