cregit-Linux how code gets into the kernel

Release 4.15 kernel/locking/rtmutex-debug.c

Directory: kernel/locking
// SPDX-License-Identifier: GPL-2.0
/*
 * RT-Mutexes: blocking mutual exclusion locks with PI support
 *
 * started by Ingo Molnar and Thomas Gleixner:
 *
 *  Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
 *  Copyright (C) 2006 Timesys Corp., Thomas Gleixner <tglx@timesys.com>
 *
 * This code is based on the rt.c implementation in the preempt-rt tree.
 * Portions of said code are
 *
 *  Copyright (C) 2004  LynuxWorks, Inc., Igor Manyilov, Bill Huey
 *  Copyright (C) 2006  Esben Nielsen
 *  Copyright (C) 2006  Kihon Technologies Inc.,
 *                      Steven Rostedt <rostedt@goodmis.org>
 *
 * See rt.c in preempt-rt for proper credits and further information
 */
#include <linux/sched.h>
#include <linux/sched/rt.h>
#include <linux/sched/debug.h>
#include <linux/delay.h>
#include <linux/export.h>
#include <linux/spinlock.h>
#include <linux/kallsyms.h>
#include <linux/syscalls.h>
#include <linux/interrupt.h>
#include <linux/rbtree.h>
#include <linux/fs.h>
#include <linux/debug_locks.h>

#include "rtmutex_common.h"


static void printk_task(struct task_struct *p) { if (p) printk("%16s:%5d [%p, %3d]", p->comm, task_pid_nr(p), p, p->prio); else printk("<none>"); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar3892.68%266.67%
Pavel Emelyanov37.32%133.33%
Total41100.00%3100.00%


static void printk_lock(struct rt_mutex *lock, int print_owner) { if (lock->name) printk(" [%p] {%s}\n", lock, lock->name); else printk(" [%p] {%s:%d}\n", lock, lock->file, lock->line); if (print_owner && rt_mutex_owner(lock)) { printk(".. ->owner: %p\n", lock->owner); printk(".. held by: "); printk_task(rt_mutex_owner(lock)); printk("\n"); } }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar85100.00%2100.00%
Total85100.00%2100.00%


void rt_mutex_debug_task_free(struct task_struct *task) { DEBUG_LOCKS_WARN_ON(!RB_EMPTY_ROOT(&task->pi_waiters.rb_root)); DEBUG_LOCKS_WARN_ON(task->pi_blocked_on); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar2683.87%125.00%
Thomas Gleixner26.45%125.00%
Davidlohr Bueso A26.45%125.00%
Peter Zijlstra13.23%125.00%
Total31100.00%4100.00%

/* * We fill out the fields in the waiter to store the information about * the deadlock. We print when we return. act_waiter can be NULL in * case of a remove waiter operation. */
void debug_rt_mutex_deadlock(enum rtmutex_chainwalk chwalk, struct rt_mutex_waiter *act_waiter, struct rt_mutex *lock) { struct task_struct *task; if (!debug_locks || chwalk == RT_MUTEX_FULL_CHAINWALK || !act_waiter) return; task = rt_mutex_owner(act_waiter->lock); if (task && task != current) { act_waiter->deadlock_task_pid = get_pid(task_pid(task)); act_waiter->deadlock_lock = lock; } }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar6182.43%125.00%
Thomas Gleixner79.46%250.00%
Pavel Emelyanov68.11%125.00%
Total74100.00%4100.00%


void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter) { struct task_struct *task; if (!waiter->deadlock_lock || !debug_locks) return; rcu_read_lock(); task = pid_task(waiter->deadlock_task_pid, PIDTYPE_PID); if (!task) { rcu_read_unlock(); return; } if (!debug_locks_off()) { rcu_read_unlock(); return; } pr_warn("\n"); pr_warn("============================================\n"); pr_warn("WARNING: circular locking deadlock detected!\n"); pr_warn("%s\n", print_tainted()); pr_warn("--------------------------------------------\n"); printk("%s/%d is deadlocking current task %s/%d\n\n", task->comm, task_pid_nr(task), current->comm, task_pid_nr(current)); printk("\n1) %s/%d is trying to acquire this lock:\n", current->comm, task_pid_nr(current)); printk_lock(waiter->lock, 1); printk("\n2) %s/%d is blocked on this lock:\n", task->comm, task_pid_nr(task)); printk_lock(waiter->deadlock_lock, 1); debug_show_held_locks(current); debug_show_held_locks(task); printk("\n%s/%d's [blocked] stackdump:\n\n", task->comm, task_pid_nr(task)); show_stack(task, NULL); printk("\n%s/%d's [current] stackdump:\n\n", current->comm, task_pid_nr(current)); dump_stack(); debug_show_all_locks(); rcu_read_unlock(); printk("[ turning off deadlock detection." "Please report this trace. ]\n\n"); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar15871.82%225.00%
Pavel Emelyanov3214.55%225.00%
Thomas Gleixner125.45%225.00%
Paul E. McKenney115.00%112.50%
Ben Hutchings73.18%112.50%
Total220100.00%8100.00%


void debug_rt_mutex_lock(struct rt_mutex *lock) { }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar9100.00%2100.00%
Total9100.00%2100.00%


void debug_rt_mutex_unlock(struct rt_mutex *lock) { DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar1995.00%150.00%
Thomas Gleixner15.00%150.00%
Total20100.00%2100.00%


void debug_rt_mutex_proxy_lock(struct rt_mutex *lock, struct task_struct *powner) { }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar14100.00%2100.00%
Total14100.00%2100.00%


void debug_rt_mutex_proxy_unlock(struct rt_mutex *lock) { DEBUG_LOCKS_WARN_ON(!rt_mutex_owner(lock)); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar1894.74%266.67%
Thomas Gleixner15.26%133.33%
Total19100.00%3100.00%


void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter) { memset(waiter, 0x11, sizeof(*waiter)); waiter->deadlock_task_pid = NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar2379.31%150.00%
Pavel Emelyanov620.69%150.00%
Total29100.00%2100.00%


void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter) { put_pid(waiter->deadlock_task_pid); memset(waiter, 0x22, sizeof(*waiter)); }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar2376.67%150.00%
Pavel Emelyanov723.33%150.00%
Total30100.00%2100.00%


void debug_rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key) { /* * Make sure we are not reinitializing a held lock: */ debug_check_no_locks_freed((void *)lock, sizeof(*lock)); lock->name = name; #ifdef CONFIG_DEBUG_LOCK_ALLOC lockdep_init_map(&lock->dep_map, name, key, 0); #endif }

Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar3760.66%266.67%
Peter Zijlstra2439.34%133.33%
Total61100.00%3100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Ingo Molnar54781.04%423.53%
Pavel Emelyanov548.00%211.76%
Peter Zijlstra263.85%211.76%
Thomas Gleixner233.41%317.65%
Paul E. McKenney111.63%15.88%
Ben Hutchings71.04%15.88%
Clark Williams30.44%15.88%
Davidlohr Bueso A20.30%15.88%
Greg Kroah-Hartman10.15%15.88%
Paul Gortmaker10.15%15.88%
Total675100.00%17100.00%
Directory: kernel/locking
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.