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: <c1cd0892-9ef4-ffad-ce93-39977389071c@redhat.com>
Date:   Mon, 3 Dec 2018 11:10:58 -0500
From:   Waiman Long <longman@...hat.com>
To:     Davidlohr Bueso <dave@...olabs.net>,
        Peter Zijlstra <peterz@...radead.org>
Cc:     Yongji Xie <elohimes@...il.com>, mingo@...hat.com,
        will.deacon@....com, linux-kernel@...r.kernel.org,
        xieyongji@...du.com, zhangyu31@...du.com, liuqi16@...du.com,
        yuanlinsi01@...du.com, nixun@...du.com, lilin24@...du.com,
        andrea.parri@...rulasolutions.com
Subject: Re: [PATCH -tip] kernel/sched,wake_q: Branch predict wake_q_add()
 cmpxchg

On 12/03/2018 12:31 AM, Davidlohr Bueso wrote:
> The cmpxchg will fail when the task is already in the process
> of waking up, and as such is an extremely rare occurrence.
> Micro-optimize the call and put an unlikely() around it.
>
> To no surprise, when using CONFIG_PROFILE_ANNOTATED_BRANCHES
> under a number of workloads the incorrect rate was a mere 1-2%.
>
> Signed-off-by: Davidlohr Bueso <dbueso@...e.de>
> ---
> kernel/sched/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 091e089063be..f7747cf6e427 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -408,7 +408,7 @@ void wake_q_add(struct wake_q_head *head, struct
> task_struct *task)
>      * This cmpxchg() executes a full barrier, which pairs with the full
>      * barrier executed by the wakeup in wake_up_q().
>      */
> -    if (cmpxchg(&node->next, NULL, WAKE_Q_TAIL))
> +    if (unlikely(cmpxchg(&node->next, NULL, WAKE_Q_TAIL)))
>         return;
>
>     get_task_struct(task);

Acked-by: Waiman Long <longman@...hat.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ