Skip to content

Commit 89aafcf

Browse files
stsquadstefanhaRH
authored andcommitted
trace: remove code that depends on setting vcpu
Now we no longer have any events that are for vcpus we can start excising the code from the trace control. As the vcpu parameter is encoded as part of QMP we just stub out the has_vcpu/vcpu parameters rather than alter the API. Reviewed-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Message-id: [email protected] Message-Id: <[email protected]> Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 5485e52 commit 89aafcf

File tree

9 files changed

+20
-285
lines changed

9 files changed

+20
-285
lines changed

hw/core/cpu-common.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,13 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp)
211211
}
212212

213213
/* NOTE: latest generic point where the cpu is fully realized */
214-
trace_init_vcpu(cpu);
215214
}
216215

217216
static void cpu_common_unrealizefn(DeviceState *dev)
218217
{
219218
CPUState *cpu = CPU(dev);
220219

221220
/* NOTE: latest generic point before the cpu is fully unrealized */
222-
trace_fini_vcpu(cpu);
223221
cpu_exec_unrealizefn(cpu);
224222
}
225223

stubs/trace-control.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,3 @@ void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
3636
}
3737
}
3838
}
39-
40-
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
41-
TraceEvent *ev, bool state)
42-
{
43-
/* should never be called on non-target binaries */
44-
abort();
45-
}
46-
47-
void trace_init_vcpu(CPUState *vcpu)
48-
{
49-
/* should never be called on non-target binaries */
50-
abort();
51-
}

trace/control-internal.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ static inline uint32_t trace_event_get_id(TraceEvent *ev)
2525
return ev->id;
2626
}
2727

28-
static inline uint32_t trace_event_get_vcpu_id(TraceEvent *ev)
29-
{
30-
return 0;
31-
}
32-
33-
static inline bool trace_event_is_vcpu(TraceEvent *ev)
34-
{
35-
return false;
36-
}
37-
3828
static inline const char * trace_event_get_name(TraceEvent *ev)
3929
{
4030
assert(ev != NULL);

trace/control-target.c

Lines changed: 9 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -36,112 +36,22 @@ void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
3636

3737
void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
3838
{
39-
CPUState *vcpu;
4039
assert(trace_event_get_state_static(ev));
41-
if (trace_event_is_vcpu(ev) && likely(first_cpu != NULL)) {
42-
CPU_FOREACH(vcpu) {
43-
trace_event_set_vcpu_state_dynamic(vcpu, ev, state);
44-
}
45-
} else {
46-
/*
47-
* Without the "vcpu" property, dstate can only be 1 or 0. With it, we
48-
* haven't instantiated any vCPU yet, so we will set a global state
49-
* instead, and trace_init_vcpu will reconcile it afterwards.
50-
*/
51-
bool state_pre = *ev->dstate;
52-
if (state_pre != state) {
53-
if (state) {
54-
trace_events_enabled_count++;
55-
*ev->dstate = 1;
56-
} else {
57-
trace_events_enabled_count--;
58-
*ev->dstate = 0;
59-
}
60-
}
61-
}
62-
}
6340

64-
static void trace_event_synchronize_vcpu_state_dynamic(
65-
CPUState *vcpu, run_on_cpu_data ignored)
66-
{
67-
bitmap_copy(vcpu->trace_dstate, vcpu->trace_dstate_delayed,
68-
CPU_TRACE_DSTATE_MAX_EVENTS);
69-
tcg_flush_jmp_cache(vcpu);
70-
}
71-
72-
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
73-
TraceEvent *ev, bool state)
74-
{
75-
uint32_t vcpu_id;
76-
bool state_pre;
77-
assert(trace_event_get_state_static(ev));
78-
assert(trace_event_is_vcpu(ev));
79-
vcpu_id = trace_event_get_vcpu_id(ev);
80-
state_pre = test_bit(vcpu_id, vcpu->trace_dstate);
41+
/*
42+
* There is no longer a "vcpu" property, dstate can only be 1 or
43+
* 0. With it, we haven't instantiated any vCPU yet, so we will
44+
* set a global state instead, and trace_init_vcpu will reconcile
45+
* it afterwards.
46+
*/
47+
bool state_pre = *ev->dstate;
8148
if (state_pre != state) {
8249
if (state) {
8350
trace_events_enabled_count++;
84-
set_bit(vcpu_id, vcpu->trace_dstate_delayed);
85-
(*ev->dstate)++;
51+
*ev->dstate = 1;
8652
} else {
8753
trace_events_enabled_count--;
88-
clear_bit(vcpu_id, vcpu->trace_dstate_delayed);
89-
(*ev->dstate)--;
90-
}
91-
if (vcpu->created) {
92-
/*
93-
* Delay changes until next TB; we want all TBs to be built from a
94-
* single set of dstate values to ensure consistency of generated
95-
* tracing code.
96-
*/
97-
async_run_on_cpu(vcpu, trace_event_synchronize_vcpu_state_dynamic,
98-
RUN_ON_CPU_NULL);
99-
} else {
100-
trace_event_synchronize_vcpu_state_dynamic(vcpu, RUN_ON_CPU_NULL);
101-
}
102-
}
103-
}
104-
105-
static bool adding_first_cpu1(void)
106-
{
107-
CPUState *cpu;
108-
size_t count = 0;
109-
CPU_FOREACH(cpu) {
110-
count++;
111-
if (count > 1) {
112-
return false;
113-
}
114-
}
115-
return true;
116-
}
117-
118-
static bool adding_first_cpu(void)
119-
{
120-
QEMU_LOCK_GUARD(&qemu_cpu_list_lock);
121-
122-
return adding_first_cpu1();
123-
}
124-
125-
void trace_init_vcpu(CPUState *vcpu)
126-
{
127-
TraceEventIter iter;
128-
TraceEvent *ev;
129-
trace_event_iter_init_all(&iter);
130-
while ((ev = trace_event_iter_next(&iter)) != NULL) {
131-
if (trace_event_is_vcpu(ev) &&
132-
trace_event_get_state_static(ev) &&
133-
trace_event_get_state_dynamic(ev)) {
134-
if (adding_first_cpu()) {
135-
/* check preconditions */
136-
assert(*ev->dstate == 1);
137-
/* disable early-init state ... */
138-
*ev->dstate = 0;
139-
trace_events_enabled_count--;
140-
/* ... and properly re-enable */
141-
trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
142-
} else {
143-
trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
144-
}
54+
*ev->dstate = 0;
14555
}
14656
}
14757
}

trace/control-vcpu.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@
3030
trace_event_get_vcpu_state_dynamic_by_vcpu_id( \
3131
vcpu, _ ## id ## _EVENT.vcpu_id))
3232

33-
/**
34-
* trace_event_get_vcpu_state_dynamic:
35-
*
36-
* Get the dynamic tracing state of an event for the given vCPU.
37-
*/
38-
static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev);
39-
4033
#include "control-internal.h"
4134

4235
static inline bool
@@ -51,13 +44,4 @@ trace_event_get_vcpu_state_dynamic_by_vcpu_id(CPUState *vcpu,
5144
}
5245
}
5346

54-
static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu,
55-
TraceEvent *ev)
56-
{
57-
uint32_t vcpu_id;
58-
assert(trace_event_is_vcpu(ev));
59-
vcpu_id = trace_event_get_vcpu_id(ev);
60-
return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id);
61-
}
62-
6347
#endif

trace/control.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -262,22 +262,6 @@ void trace_init_file(void)
262262
#endif
263263
}
264264

265-
void trace_fini_vcpu(CPUState *vcpu)
266-
{
267-
TraceEventIter iter;
268-
TraceEvent *ev;
269-
270-
trace_event_iter_init_all(&iter);
271-
while ((ev = trace_event_iter_next(&iter)) != NULL) {
272-
if (trace_event_is_vcpu(ev) &&
273-
trace_event_get_state_static(ev) &&
274-
trace_event_get_vcpu_state_dynamic(vcpu, ev)) {
275-
/* must disable to affect the global counter */
276-
trace_event_set_vcpu_state_dynamic(vcpu, ev, false);
277-
}
278-
}
279-
}
280-
281265
bool trace_init_backends(void)
282266
{
283267
#ifdef CONFIG_TRACE_SIMPLE

trace/control.h

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,6 @@ static bool trace_event_is_pattern(const char *str);
8989
*/
9090
static uint32_t trace_event_get_id(TraceEvent *ev);
9191

92-
/**
93-
* trace_event_get_vcpu_id:
94-
*
95-
* Get the per-vCPU identifier of an event.
96-
*
97-
* Special value #TRACE_VCPU_EVENT_NONE means the event is not vCPU-specific
98-
* (does not have the "vcpu" property).
99-
*/
100-
static uint32_t trace_event_get_vcpu_id(TraceEvent *ev);
101-
102-
/**
103-
* trace_event_is_vcpu:
104-
*
105-
* Whether this is a per-vCPU event.
106-
*/
107-
static bool trace_event_is_vcpu(TraceEvent *ev);
108-
10992
/**
11093
* trace_event_get_name:
11194
*
@@ -172,21 +155,6 @@ static bool trace_event_get_state_dynamic(TraceEvent *ev);
172155
*/
173156
void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
174157

175-
/**
176-
* trace_event_set_vcpu_state_dynamic:
177-
*
178-
* Set the dynamic tracing state of an event for the given vCPU.
179-
*
180-
* Pre-condition: trace_event_get_vcpu_state_static(ev) == true
181-
*
182-
* Note: Changes for execution-time events with the 'tcg' property will not be
183-
* propagated until the next TB is executed (iff executing in TCG mode).
184-
*/
185-
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
186-
TraceEvent *ev, bool state);
187-
188-
189-
190158
/**
191159
* trace_init_backends:
192160
*
@@ -205,22 +173,6 @@ bool trace_init_backends(void);
205173
*/
206174
void trace_init_file(void);
207175

208-
/**
209-
* trace_init_vcpu:
210-
* @vcpu: Added vCPU.
211-
*
212-
* Set initial dynamic event state for a hot-plugged vCPU.
213-
*/
214-
void trace_init_vcpu(CPUState *vcpu);
215-
216-
/**
217-
* trace_fini_vcpu:
218-
* @vcpu: Removed vCPU.
219-
*
220-
* Disable dynamic event state for a hot-unplugged vCPU.
221-
*/
222-
void trace_fini_vcpu(CPUState *vcpu);
223-
224176
/**
225177
* trace_list_events:
226178
* @f: Where to send output.

0 commit comments

Comments
 (0)