lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGQ1y=6DOs0hcdV+NvOdA9hxf6kwu-R0M-c6R2iUK4ufr=pwEg@mail.gmail.com>
Date:	Tue, 27 May 2014 15:49:21 -0700
From:	Jason Low <jason.low2@...com>
To:	Thomas Gleixner <tglx@...utronix.de>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Ingo Molnar <mingo@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Lai Jiangshan <laijs@...fujitsu.com>
Subject: Re: [patch 6/6] rtmutex: Avoid pointless requeueing in the deadlock
 detection chain walk

On Wed, May 21, 2014 at 8:25 PM, Thomas Gleixner <tglx@...utronix.de> wrote:

> @@ -440,32 +452,41 @@ static int rt_mutex_adjust_prio_chain(st
>         get_task_struct(task);
>         raw_spin_lock_irqsave(&task->pi_lock, flags);
>
> -       if (waiter == rt_mutex_top_waiter(lock)) {
> -               /*
> -                * The waiter became the top waiter on the
> -                * lock. Remove the previous top waiter from the tasks
> -                * pi waiters list and add waiter to it.
> -                */
> -               rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
> -               rt_mutex_enqueue_pi(task, waiter);
> -               __rt_mutex_adjust_prio(task);
> -
> -       } else if (prerequeue_top_waiter == waiter) {
> -               /*
> -                * The waiter was the top waiter on the lock. Remove
> -                * waiter from the tasks pi waiters list and add the
> -                * new top waiter to it.
> -                */
> -               rt_mutex_dequeue_pi(task, waiter);
> -               waiter = rt_mutex_top_waiter(lock);
> -               rt_mutex_enqueue_pi(task, waiter);
> -               __rt_mutex_adjust_prio(task);
> -
> -       } else {
> -               /*
> -                * Nothing changed. No need to do any priority
> -                * adjustment.
> -                */
> +       /*
> +        * In case we are just following the lock chain for deadlock
> +        * detection we can avoid the whole requeue and priority
> +        * adjustment business.
> +        */
> +       if (requeue) {
> +               if (waiter == rt_mutex_top_waiter(lock)) {
> +                       /*
> +                        * The waiter became the top waiter on the
> +                        * lock. Remove the previous top waiter from
> +                        * the tasks pi waiters list and add waiter to
> +                        * it.
> +                        */
> +                       rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
> +                       rt_mutex_enqueue_pi(task, waiter);
> +                       __rt_mutex_adjust_prio(task);
> +
> +               } else if (prerequeue_top_waiter == waiter) {
> +                       /*
> +                        * The waiter was the top waiter on the
> +                        * lock. Remove waiter from the tasks pi
> +                        * waiters list and add the new top waiter to
> +                        * it.
> +                        */
> +                       rt_mutex_dequeue_pi(task, waiter);
> +                       waiter = rt_mutex_top_waiter(lock);
> +                       rt_mutex_enqueue_pi(task, waiter);
> +                       __rt_mutex_adjust_prio(task);
> +
> +               } else {
> +                       /*
> +                        * Nothing changed. No need to do any priority
> +                        * adjustment.
> +                        */
> +               }
>         }
>
>         raw_spin_unlock_irqrestore(&task->pi_lock, flags);

In the above case, could we go 1 step further and avoid taking the pi
lock as well?

        if (requeue) {
                raw_spin_lock_irqsave(&task->pi_lock, flags);

                if (waiter == rt_mutex_top_waiter(lock)) {
                        /*
                         * The waiter became the top waiter on the
                         * lock. Remove the previous top waiter from
                         * the tasks pi waiters list and add waiter to
                         * it.
                         */
                        rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
                        rt_mutex_enqueue_pi(task, waiter);
                        __rt_mutex_adjust_prio(task);

                } else if (prerequeue_top_waiter == waiter) {
                        /*
                         * The waiter was the top waiter on the
                         * lock. Remove waiter from the tasks pi
                         * waiters list and add the new top waiter to
                         * it.
                         */
                        rt_mutex_dequeue_pi(task, waiter);
                        waiter = rt_mutex_top_waiter(lock);
                        rt_mutex_enqueue_pi(task, waiter);
                        __rt_mutex_adjust_prio(task);

                } else {
                        /*
                         * Nothing changed. No need to do any priority
                         * adjustment.
                         */
                }

                raw_spin_unlock_irqrestore(&task->pi_lock, flags);
        }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ