Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efed792d authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

tracing: add lockdep tracepoints for lock acquire/release



Augment the traces with lock names when lockdep is available:

 1)               |  down_read_trylock() {
 1)               |    _spin_lock_irqsave() {
 1)               |      /* lock_acquire: &sem->wait_lock */
 1)   4.201 us    |    }
 1)               |    _spin_unlock_irqrestore() {
 1)               |      /* lock_release: &sem->wait_lock */
 1)   3.523 us    |    }
 1)               |  /* lock_acquire: try read &mm->mmap_sem */
 1) + 13.386 us   |  }
 1)   1.635 us    |  find_vma();
 1)               |  handle_mm_fault() {
 1)               |    __do_fault() {
 1)               |      filemap_fault() {
 1)               |        find_lock_page() {
 1)               |          find_get_page() {
 1)               |            /* lock_acquire: read rcu_read_lock */
 1)               |            /* lock_release: rcu_read_lock */
 1)   5.697 us    |          }
 1)   8.158 us    |        }
 1) + 11.079 us   |      }
 1)               |      _spin_lock() {
 1)               |        /* lock_acquire: __pte_lockptr(page) */
 1)   3.949 us    |      }
 1)   1.460 us    |      page_add_file_rmap();
 1)               |      _spin_unlock() {
 1)               |        /* lock_release: __pte_lockptr(page) */
 1)   3.115 us    |      }
 1)               |      unlock_page() {
 1)   1.421 us    |        page_waitqueue();
 1)   1.220 us    |        __wake_up_bit();
 1)   6.519 us    |      }
 1) + 34.328 us   |    }
 1) + 37.452 us   |  }
 1)               |  up_read() {
 1)               |  /* lock_release: &mm->mmap_sem */
 1)               |    _spin_lock_irqsave() {
 1)               |      /* lock_acquire: &sem->wait_lock */
 1)   3.865 us    |    }
 1)               |    _spin_unlock_irqrestore() {
 1)               |      /* lock_release: &sem->wait_lock */
 1)   8.562 us    |    }
 1) + 17.370 us   |  }

Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: =?ISO-8859-1?Q?T=F6r=F6k?= Edwin <edwintorok@gmail.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <1236166375.5330.7209.camel@laptop>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 28b1bd1c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
#ifndef _TRACE_LOCKDEP_H
#define _TRACE_LOCKDEP_H

#include <linux/lockdep.h>
#include <linux/tracepoint.h>

#include <trace/lockdep_event_types.h>

#endif
+44 −0
Original line number Diff line number Diff line

#ifndef TRACE_EVENT_FORMAT
# error Do not include this file directly.
# error Unless you know what you are doing.
#endif

#undef TRACE_SYSTEM
#define TRACE_SYSTEM lock

#ifdef CONFIG_LOCKDEP

TRACE_FORMAT(lock_acquire,
	TPPROTO(struct lockdep_map *lock, unsigned int subclass,
		int trylock, int read, int check,
		struct lockdep_map *next_lock, unsigned long ip),
	TPARGS(lock, subclass, trylock, read, check, next_lock, ip),
	TPFMT("%s%s%s", trylock ? "try " : "",
		read ? "read " : "", lock->name)
	);

TRACE_FORMAT(lock_release,
	TPPROTO(struct lockdep_map *lock, int nested, unsigned long ip),
	TPARGS(lock, nested, ip),
	TPFMT("%s", lock->name)
	);

#ifdef CONFIG_LOCK_STAT

TRACE_FORMAT(lock_contended,
	TPPROTO(struct lockdep_map *lock, unsigned long ip),
	TPARGS(lock, ip),
	TPFMT("%s", lock->name)
	);

TRACE_FORMAT(lock_acquired,
	TPPROTO(struct lockdep_map *lock, unsigned long ip),
	TPARGS(lock, ip),
	TPFMT("%s", lock->name)
	);

#endif
#endif

#undef TRACE_SYSTEM
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@

#include <trace/sched_event_types.h>
#include <trace/irq_event_types.h>
#include <trace/lockdep_event_types.h>
+1 −0
Original line number Diff line number Diff line
@@ -2,3 +2,4 @@

#include <trace/sched.h>
#include <trace/irq.h>
#include <trace/lockdep.h>
+17 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include <linux/hash.h>
#include <linux/ftrace.h>
#include <linux/stringify.h>
#include <trace/lockdep.h>

#include <asm/sections.h>

@@ -2913,6 +2914,8 @@ void lock_set_class(struct lockdep_map *lock, const char *name,
}
EXPORT_SYMBOL_GPL(lock_set_class);

DEFINE_TRACE(lock_acquire);

/*
 * We are not always called with irqs disabled - do that here,
 * and also avoid lockdep recursion:
@@ -2923,6 +2926,8 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
{
	unsigned long flags;

	trace_lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip);

	if (unlikely(current->lockdep_recursion))
		return;

@@ -2937,11 +2942,15 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
}
EXPORT_SYMBOL_GPL(lock_acquire);

DEFINE_TRACE(lock_release);

void lock_release(struct lockdep_map *lock, int nested,
			  unsigned long ip)
{
	unsigned long flags;

	trace_lock_release(lock, nested, ip);

	if (unlikely(current->lockdep_recursion))
		return;

@@ -3090,10 +3099,14 @@ __lock_acquired(struct lockdep_map *lock, unsigned long ip)
	lock->ip = ip;
}

DEFINE_TRACE(lock_contended);

void lock_contended(struct lockdep_map *lock, unsigned long ip)
{
	unsigned long flags;

	trace_lock_contended(lock, ip);

	if (unlikely(!lock_stat))
		return;

@@ -3109,10 +3122,14 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
}
EXPORT_SYMBOL_GPL(lock_contended);

DEFINE_TRACE(lock_acquired);

void lock_acquired(struct lockdep_map *lock, unsigned long ip)
{
	unsigned long flags;

	trace_lock_acquired(lock, ip);

	if (unlikely(!lock_stat))
		return;

Loading