Skip to content

Commit

Permalink
powerpc: Fix hcall tracepoint recursion
Browse files Browse the repository at this point in the history
Spinlocks on shared processor partitions use H_YIELD to notify the
hypervisor we are waiting on another virtual CPU. Unfortunately this means
the hcall tracepoints can recurse.

The patch below adds a percpu depth and checks it on both the entry and
exit hcall tracepoints.

Signed-off-by: Anton Blanchard <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
Signed-off-by: Benjamin Herrenschmidt <[email protected]>
CC: [email protected]
  • Loading branch information
antonblanchard authored and ozbenh committed Feb 7, 2011
1 parent 429f4d8 commit 57cdfdf
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions arch/powerpc/platforms/pseries/lpar.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,13 @@ EXPORT_SYMBOL(arch_free_page);
/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
extern long hcall_tracepoint_refcount;

/*
* Since the tracing code might execute hcalls we need to guard against
* recursion. One example of this are spinlocks calling H_YIELD on
* shared processor partitions.
*/
static DEFINE_PER_CPU(unsigned int, hcall_trace_depth);

void hcall_tracepoint_regfunc(void)
{
hcall_tracepoint_refcount++;
Expand All @@ -725,12 +732,42 @@ void hcall_tracepoint_unregfunc(void)

void __trace_hcall_entry(unsigned long opcode, unsigned long *args)
{
unsigned long flags;
unsigned int *depth;

local_irq_save(flags);

depth = &__get_cpu_var(hcall_trace_depth);

if (*depth)
goto out;

(*depth)++;
trace_hcall_entry(opcode, args);
(*depth)--;

out:
local_irq_restore(flags);
}

void __trace_hcall_exit(long opcode, unsigned long retval,
unsigned long *retbuf)
{
unsigned long flags;
unsigned int *depth;

local_irq_save(flags);

depth = &__get_cpu_var(hcall_trace_depth);

if (*depth)
goto out;

(*depth)++;
trace_hcall_exit(opcode, retval, retbuf);
(*depth)--;

out:
local_irq_restore(flags);
}
#endif

0 comments on commit 57cdfdf

Please sign in to comment.