public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Waiman Long <longman@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
	linux-kernel@vger.kernel.org,
	Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH v3 1/8] locking/lockdep: Decrement irq context counters when removing lock chain
Date: Thu, 16 Jan 2020 16:32:12 +0100	[thread overview]
Message-ID: <20200116153212.GS2827@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200115214313.13253-2-longman@redhat.com>

On Wed, Jan 15, 2020 at 04:43:06PM -0500, Waiman Long wrote:
> There are currently three counters to track the irq context of a lock
> chain - nr_hardirq_chains, nr_softirq_chains and nr_process_chains.
> They are incremented when a new lock chain is added, but they are
> not decremented when a lock chain is removed. That causes some of the
> statistic counts reported by /proc/lockdep_stats to be incorrect.
> 
> Fix that by decrementing the right counter when a lock chain is removed.
> 
> Fixes: a0b0fd53e1e6 ("locking/lockdep: Free lock classes that are no longer in use")
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
>  kernel/locking/lockdep.c           | 36 +++++++++++++++++++++---------
>  kernel/locking/lockdep_internals.h |  6 +++++
>  2 files changed, 32 insertions(+), 10 deletions(-)
> 
> diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
> index 32282e7112d3..b20fa6236b2a 100644
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -2299,16 +2299,24 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,
>  	return 0;
>  }
>  
> -static void inc_chains(void)
> +static void inc_chains(int irq_context)
>  {
> -	if (current->hardirq_context)
> +	if (irq_context & LOCK_CHAIN_HARDIRQ_CONTEXT)
>  		nr_hardirq_chains++;
> -	else {
> -		if (current->softirq_context)
> -			nr_softirq_chains++;
> -		else
> -			nr_process_chains++;
> -	}
> +	else if (irq_context & LOCK_CHAIN_SOFTIRQ_CONTEXT)
> +		nr_softirq_chains++;
> +	else
> +		nr_process_chains++;
> +}
> +
> +static void dec_chains(int irq_context)
> +{
> +	if (irq_context & LOCK_CHAIN_HARDIRQ_CONTEXT)
> +		nr_hardirq_chains--;
> +	else if (irq_context & LOCK_CHAIN_SOFTIRQ_CONTEXT)
> +		nr_softirq_chains--;
> +	else
> +		nr_process_chains--;
>  }
>  
>  #else
> @@ -2324,6 +2332,10 @@ static inline void inc_chains(void)
>  	nr_process_chains++;
>  }
>  
> +static void dec_chains(int irq_context)
> +{
> +	nr_process_chains--;
> +}
>  #endif /* CONFIG_TRACE_IRQFLAGS */
>  

Is there really need for two versions of those functions? Would the
@irq_context argument not always be 0 in the CONFIG_TRACE_IRQFLAGS=n
case?

  reply	other threads:[~2020-01-16 15:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-15 21:43 [PATCH v3 0/8] locking/lockdep: Reuse zapped chain_hlocks entries Waiman Long
2020-01-15 21:43 ` [PATCH v3 1/8] locking/lockdep: Decrement irq context counters when removing lock chain Waiman Long
2020-01-16 15:32   ` Peter Zijlstra [this message]
2020-01-16 15:50     ` Waiman Long
2020-01-17 18:14   ` kbuild test robot
2020-01-15 21:43 ` [PATCH v3 2/8] locking/lockdep: Display irq_context names in /proc/lockdep_chains Waiman Long
2020-01-17 22:12   ` kbuild test robot
2020-01-15 21:43 ` [PATCH v3 3/8] locking/lockdep: Track number of zapped classes Waiman Long
2020-01-15 21:43 ` [PATCH v3 4/8] locking/lockdep: Throw away all lock chains with zapped class Waiman Long
2020-01-15 21:43 ` [PATCH v3 5/8] locking/lockdep: Track number of zapped lock chains Waiman Long
2020-01-15 21:43 ` [PATCH v3 6/8] locking/lockdep: Reuse freed chain_hlocks entries Waiman Long
2020-01-16 21:13   ` Peter Zijlstra
2020-01-20  4:22     ` Waiman Long
2020-01-17  5:51   ` kbuild test robot
2020-01-15 21:43 ` [PATCH v3 7/8] locking/lockdep: Add lockdep_early_init() before any lock is taken Waiman Long
2020-01-15 21:43 ` [PATCH v3 8/8] locking/lockdep: Enable chain block splitting as last resort Waiman Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200116153212.GS2827@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox