@@ -235,14 +235,14 @@ static int32_t profiling_sbuf_put_variable(struct shared_buf *sbuf,
235
235
* 5. return number of bytes of data put in buffer
236
236
*/
237
237
238
+ stac ();
238
239
if ((sbuf == NULL ) || (data == NULL )) {
239
- dev_dbg ( ACRN_DBG_PROFILING , "buffer or data not initialized!" );
240
+ clac ( );
240
241
return - EINVAL ;
241
242
}
242
243
243
244
if (size == 0U ) {
244
- dev_dbg (ACRN_DBG_PROFILING ,
245
- "0 bytes reqeusted to be put in buffer!" );
245
+ clac ();
246
246
return 0 ;
247
247
}
248
248
@@ -257,19 +257,15 @@ static int32_t profiling_sbuf_put_variable(struct shared_buf *sbuf,
257
257
* Since if the next_tail equals head, then it is assumed
258
258
* that buffer is empty, not full
259
259
*/
260
- dev_dbg (ACRN_DBG_PROFILING ,
261
- "Not enough space to write data! Returning without writing" );
260
+ clac ();
262
261
return 0 ;
263
262
}
264
263
265
264
next_tail = sbuf_next_ptr (sbuf -> tail , size , sbuf -> size );
266
- dev_dbg (ACRN_DBG_PROFILING , "sbuf->tail: %llu, next_tail: %llu" ,
267
- sbuf -> tail , next_tail );
268
265
269
266
to = (void * )sbuf + SBUF_HEAD_SIZE + sbuf -> tail ;
270
267
271
268
if (next_tail < sbuf -> tail ) { /* wrap-around */
272
- dev_dbg (ACRN_DBG_PROFILING , "wrap-around condition!" );
273
269
offset = sbuf -> size - sbuf -> tail ;
274
270
(void )memcpy_s (to , offset , data , offset );
275
271
@@ -281,11 +277,11 @@ static int32_t profiling_sbuf_put_variable(struct shared_buf *sbuf,
281
277
data + offset , size - offset );
282
278
}
283
279
} else {
284
- dev_dbg (ACRN_DBG_PROFILING , "non-wrap-around!" );
285
280
(void )memcpy_s (to , size , data , size );
286
281
}
287
282
288
283
sbuf -> tail = next_tail ;
284
+ clac ();
289
285
290
286
return (int32_t )size ;
291
287
}
@@ -306,6 +302,8 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type)
306
302
struct sep_state * ss = & (get_cpu_var (profiling_info .sep_state ));
307
303
struct sw_msr_op_info * sw_msrop
308
304
= & (get_cpu_var (profiling_info .sw_msr_op_info ));
305
+ uint64_t rflags ;
306
+ spinlock_t * sw_lock = NULL ;
309
307
310
308
dev_dbg (ACRN_DBG_PROFILING , "%s: entering cpu%d" ,
311
309
__func__ , get_cpu_id ());
@@ -322,12 +320,14 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type)
322
320
}
323
321
324
322
if (ss -> pmu_state == PMU_RUNNING ) {
323
+ stac ();
325
324
if (sbuf -> tail >= sbuf -> head ) {
326
325
remaining_space = sbuf -> size
327
326
- (sbuf -> tail - sbuf -> head );
328
327
} else {
329
328
remaining_space = sbuf -> head - sbuf -> tail ;
330
329
}
330
+ clac ();
331
331
332
332
/* populate the data header */
333
333
pkt_header .tsc = rdtsc ();
@@ -393,12 +393,16 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type)
393
393
return 0 ;
394
394
}
395
395
396
+ sw_lock = & (get_cpu_var (profiling_info .sw_lock ));
397
+ spinlock_irqsave_obtain (sw_lock , & rflags );
398
+ stac ();
396
399
if (sbuf -> tail >= sbuf -> head ) {
397
400
remaining_space
398
401
= sbuf -> size - (sbuf -> tail - sbuf -> head );
399
402
} else {
400
403
remaining_space = sbuf -> head - sbuf -> tail ;
401
404
}
405
+ clac ();
402
406
403
407
/* populate the data header */
404
408
pkt_header .tsc = rdtsc ();
@@ -448,6 +452,7 @@ static int32_t profiling_generate_data(int32_t collector, uint32_t type)
448
452
(void )profiling_sbuf_put_variable ((struct shared_buf * )sbuf ,
449
453
(uint8_t * )payload , (uint32_t )payload_size );
450
454
455
+ spinlock_irqrestore_release (sw_lock , rflags );
451
456
} else {
452
457
dev_dbg (ACRN_ERR_PROFILING ,
453
458
"%s: Unknown collector type" , __func__ );
0 commit comments