Sungju's Slow Life

Personal journal


Meaning of the ‘sysctl.max_lock_depth’

This tunable limits the amount of deadlock-checking the kernel will do. The default value is 1024.

You can see those codes in the following snippet.

 146/*
 147 * Max number of times we'll walk the boosting chain:
 148 */
 149int max_lock_depth = 1024;
 150
 151/*
 152 * Adjust the priority chain. Also used for deadlock detection.
 153 * Decreases task's usage by one - may thus free the task.
 154 * Returns 0 or -EDEADLK.
 155 */
 156static int rt_mutex_adjust_prio_chain(struct task_struct *task,
 157                                      int deadlock_detect,
 158                                      struct rt_mutex *orig_lock,
 159                                      struct rt_mutex_waiter *orig_waiter,
 160                                      struct task_struct *top_task)
 161{
 162        struct rt_mutex *lock;
 163        struct rt_mutex_waiter *waiter, *top_waiter = orig_waiter;
 164        int detect_deadlock, ret = 0, depth = 0;
 165        unsigned long flags;
 166
 167        detect_deadlock = debug_rt_mutex_detect_deadlock(orig_waiter,
 168                                                         deadlock_detect);
 169
 170        /*
 171         * The (de)boosting is a step by step approach with a lot of
 172         * pitfalls. We want this to be preemptible and we want hold a
 173         * maximum of two locks per step. So we have to check
 174         * carefully whether things change under us.
 175         */
 176 again:
 177        if (++depth > max_lock_depth) {
 178                static int prev_max;
 179
 180                /*
 181                 * Print this only once. If the admin changes the limit,
 182                 * print a new message when reaching the limit again.
 183                 */
 184                if (prev_max != max_lock_depth) {
 185                        prev_max = max_lock_depth;
 186                        printk(KERN_WARNING "Maximum lock depth %d reached "
 187                               "task: %s (%d)n", max_lock_depth,
 188                               top_task->comm, task_pid_nr(top_task));
 189                }
 190                put_task_struct(task);
 191
 192                return deadlock_detect ? -EDEADLK : 0;
 193        }
 194 retry:
 195        /*


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: