[PATCH 4/4] powerpc/pseries: warn if recursing into the hcall tracing code

Naveen N. Rao naveen.n.rao at linux.vnet.ibm.com
Tue May 4 20:25:42 AEST 2021

Nicholas Piggin wrote:
> Excerpts from Naveen N. Rao's message of April 27, 2021 11:59 pm:
>> Nicholas Piggin wrote:
>>> + *
>>> + * H_CONFER from spin locks must be treated separately though and use _notrace
>>> + * plpar_hcall variants, see yield_to_preempted().
>>>   */
>>>  static DEFINE_PER_CPU(unsigned int, hcall_trace_depth);
>>> @@ -1843,7 +1846,7 @@ notrace void __trace_hcall_entry(unsigned long opcode, unsigned long *args)
>>>  	depth = this_cpu_ptr(&hcall_trace_depth);
>>> -	if (*depth)
>>> +	if (WARN_ON_ONCE(*depth))
>>>  		goto out;
>> I don't think this will be helpful. The hcall trace depth tracking is 
>> for the tracepoint and I suspect that this warning will be triggered 
>> quite easily. Since we have recursion protection, I don't think we 
>> should warn here.
> What would trigger recursion?

The trace code that this protects: trace_hcall_entry(). The tracing code 
itself can end up doing a hcall as we see in the first patch in this 
  plpar_hcall_norets_trace+0x34/0x8c (unreliable)

There is also a comment aroung hcall_trace_depth that mentions this:

   * 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.


More information about the Linuxppc-dev mailing list