1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* -*- linux-c -*-
* Print Flush Function
* Copyright (C) 2007 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
* Public License (GPL); either version 2, or (at your option) any
* later version.
*/
/** Send the print buffer to the transport now.
* Output accumulates in the print buffer until it
* is filled, or this is called. This MUST be called before returning
* from a probe or accumulated output in the print buffer will be lost.
*
* @note Preemption must be disabled to use this.
*/
spinlock_t _stp_print_lock = SPIN_LOCK_UNLOCKED;
void _stp_print_flush (void)
{
_stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id());
uint32_t len = pb->len;
/* check to see if there is anything in the buffer */
if (likely (len == 0))
return;
pb->len = 0;
if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running))
return;
#ifdef STP_BULKMODE
{
#ifdef NO_PERCPU_HEADERS
void *buf = relay_reserve(_stp_utt->rchan, len);
if (likely(buf))
memcpy(buf, pb->buf, len);
else
atomic_inc (&_stp_transport_failures);
#else
struct _stp_trace *t = relay_reserve(_stp_utt->rchan, sizeof(*t) + len);
if (likely(t)) {
t->sequence = _stp_seq_inc();
t->pdu_len = len;
memcpy((void *) t + sizeof(*t), pb->buf, len);
} else
atomic_inc (&_stp_transport_failures);
#endif
}
#else
{
void *buf;
spin_lock(&_stp_print_lock);
buf = relay_reserve(_stp_utt->rchan, len);
if (likely(buf))
memcpy(buf, pb->buf, len);
else
atomic_inc (&_stp_transport_failures);
spin_unlock(&_stp_print_lock);
}
#endif /* STP_BULKMODE */
}
|