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]
Date:	Mon, 19 Nov 2012 16:10:50 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Ivo Sieben <meltedpianoman@...il.com>
Cc:	linux-kernel@...r.kernel.org, Andi Kleen <andi@...stfloor.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>, linux-serial@...r.kernel.org,
	Alan Cox <alan@...ux.intel.com>,
	Greg KH <gregkh@...uxfoundation.org>
Subject: Re: [REPOST-v2] sched: Prevent wakeup to enter critical section
	needlessly

On 11/19, Ivo Sieben wrote:
>
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3090,9 +3090,22 @@ void __wake_up(wait_queue_head_t *q, unsigned int mode,
>  {
>  	unsigned long flags;
>
> -	spin_lock_irqsave(&q->lock, flags);
> -	__wake_up_common(q, mode, nr_exclusive, 0, key);
> -	spin_unlock_irqrestore(&q->lock, flags);
> +	/*
> +	 * We check for list emptiness outside the lock. This prevents the wake
> +	 * up to enter the critical section needlessly when the task list is
> +	 * empty.
> +	 *
> +	 * Placed a full memory barrier before checking list emptiness to make
> +	 * 100% sure this function sees an up-to-date list administration.
> +	 * Note that other code that manipulates the list uses a spin_lock and
> +	 * therefore doesn't need additional memory barriers.
> +	 */
> +	smp_mb();
> +	if (!list_empty(&q->task_list)) {

waitqueue_active() ?

> +		spin_lock_irqsave(&q->lock, flags);
> +		__wake_up_common(q, mode, nr_exclusive, 0, key);
> +		spin_unlock_irqrestore(&q->lock, flags);
> +	}

I am wondering if it makes sense unconditionally. A lot of callers do

	if (waitqueue_active(q))
		wake_up(...);

this patch makes the optimization above pointless and adds mb().


But I won't argue.

Oleg.

--
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