Re: [PATCH] sched: Add preempt checks in preempt_schedule() code

From: Peter Zijlstra
Date: Mon Mar 21 2016 - 05:29:21 EST


On Fri, Mar 18, 2016 at 01:06:02PM -0400, Steven Rostedt wrote:
> Now by breaking out the preempt off/on tracing into their own code:
> preempt_disable_check() and preempt_enable_check(), we can add these to
> the preempt_schedule() code. As preemption would then be disabled, even
> if they were to be traced by the function tracer, the disabled
> preemption would prevent the recursion.

> +static inline void preempt_disable_check(int val)
> +{
> + if (preempt_count() == val) {
> + unsigned long ip = get_parent_ip(CALLER_ADDR1);
> +#ifdef CONFIG_DEBUG_PREEMPT
> + current->preempt_disable_ip = ip;
> +#endif
> + trace_preempt_off(CALLER_ADDR0, ip);
> + }
> +}

> +static inline void preempt_enable_check(int val)
> +{
> + if (preempt_count() == val)
> + trace_preempt_on(CALLER_ADDR0, get_parent_ip(CALLER_ADDR1));
> +}

So no real objection to the patch except this naming.

It doesn't 'check', it does preempt-latency tracing. So could we rename
this to something like:

preempt_{dis,en}able_latency()

or somesuch?