Skip to content

Commit 4087449

Browse files
author
Ingo Molnar
committed
Merge branches 'tracing/ftrace' and 'tracing/hw-branch-tracing' into tracing/core
2 parents d680fe4 + d072c25 commit 4087449

1 file changed

Lines changed: 28 additions & 33 deletions

File tree

‎arch/x86/kernel/ds.c‎

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -232,53 +232,45 @@ static DEFINE_PER_CPU(struct ds_context *, system_context_array);
232232

233233
#define system_context per_cpu(system_context_array, smp_processor_id())
234234

235-
static struct ds_context *ds_get_context(struct task_struct *task)
235+
236+
static inline struct ds_context *ds_get_context(struct task_struct *task)
236237
{
237238
struct ds_context **p_context =
238239
(task ? &task->thread.ds_ctx : &system_context);
239-
struct ds_context *context = *p_context;
240+
struct ds_context *context = NULL;
241+
struct ds_context *new_context = NULL;
240242
unsigned long irq;
241243

242-
if (!context) {
243-
context = kzalloc(sizeof(*context), GFP_KERNEL);
244-
if (!context)
245-
return NULL;
246-
247-
spin_lock_irqsave(&ds_lock, irq);
248-
249-
if (*p_context) {
250-
kfree(context);
244+
/* Chances are small that we already have a context. */
245+
new_context = kzalloc(sizeof(*new_context), GFP_KERNEL);
246+
if (!new_context)
247+
return NULL;
251248

252-
context = *p_context;
253-
} else {
254-
*p_context = context;
249+
spin_lock_irqsave(&ds_lock, irq);
255250

256-
context->this = p_context;
257-
context->task = task;
251+
context = *p_context;
252+
if (!context) {
253+
context = new_context;
258254

259-
if (task)
260-
set_tsk_thread_flag(task, TIF_DS_AREA_MSR);
255+
context->this = p_context;
256+
context->task = task;
257+
context->count = 0;
261258

262-
if (!task || (task == current))
263-
wrmsrl(MSR_IA32_DS_AREA,
264-
(unsigned long)context->ds);
265-
}
259+
if (task)
260+
set_tsk_thread_flag(task, TIF_DS_AREA_MSR);
266261

267-
context->count++;
262+
if (!task || (task == current))
263+
wrmsrl(MSR_IA32_DS_AREA, (unsigned long)context->ds);
268264

269-
spin_unlock_irqrestore(&ds_lock, irq);
270-
} else {
271-
spin_lock_irqsave(&ds_lock, irq);
265+
*p_context = context;
266+
}
272267

273-
context = *p_context;
274-
if (context)
275-
context->count++;
268+
context->count++;
276269

277-
spin_unlock_irqrestore(&ds_lock, irq);
270+
spin_unlock_irqrestore(&ds_lock, irq);
278271

279-
if (!context)
280-
context = ds_get_context(task);
281-
}
272+
if (context != new_context)
273+
kfree(new_context);
282274

283275
return context;
284276
}
@@ -492,6 +484,9 @@ static int bts_read(struct bts_tracer *tracer, const void *at,
492484
out->qualifier = bts_branch;
493485
out->variant.lbr.from = bts_get(at, bts_from);
494486
out->variant.lbr.to = bts_get(at, bts_to);
487+
488+
if (!out->variant.lbr.from && !out->variant.lbr.to)
489+
out->qualifier = bts_invalid;
495490
}
496491

497492
return ds_cfg.sizeof_rec[ds_bts];

0 commit comments

Comments
 (0)