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: <20190417140527.GJ4038@hirez.programming.kicks-ass.net>
Date:   Wed, 17 Apr 2019 16:05:27 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Waiman Long <longman@...hat.com>
Cc:     Ingo Molnar <mingo@...hat.com>, Will Deacon <will.deacon@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org, x86@...nel.org,
        Davidlohr Bueso <dave@...olabs.net>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Tim Chen <tim.c.chen@...ux.intel.com>,
        huang ying <huang.ying.caritas@...il.com>
Subject: Re: [PATCH v4 11/16] locking/rwsem: Enable readers spinning on writer

On Sat, Apr 13, 2019 at 01:22:54PM -0400, Waiman Long wrote:
> @@ -650,6 +686,33 @@ __rwsem_down_read_failed_common(struct rw_semaphore *sem, int state)
>  	struct rwsem_waiter waiter;
>  	DEFINE_WAKE_Q(wake_q);
>  
> +	if (!rwsem_can_spin_on_owner(sem))
> +		goto queue;
> +
> +	/*
> +	 * Undo read bias from down_read() and do optimistic spinning.
> +	 */
> +	atomic_long_add(-RWSEM_READER_BIAS, &sem->count);
> +	adjustment = 0;
> +	if (rwsem_optimistic_spin(sem, false)) {
> +		unsigned long flags;
> +
> +		/*
> +		 * Opportunistically wake up other readers in the wait queue.
> +		 * It has another chance of wakeup at unlock time.
> +		 */
> +		if ((atomic_long_read(&sem->count) & RWSEM_FLAG_WAITERS) &&
> +		    raw_spin_trylock_irqsave(&sem->wait_lock, flags)) {

why trylock? Also the rest of this function uses _irq(). Having had to
define @flags should've been a clue.

You simply cnanot do down_*() with IRQs disabled.

> +			if (!list_empty(&sem->wait_list))
> +				__rwsem_mark_wake(sem, RWSEM_WAKE_READ_OWNED,
> +						  &wake_q);
> +			raw_spin_unlock_irqrestore(&sem->wait_lock, flags);
> +			wake_up_q(&wake_q);
> +		}
> +		return sem;
> +	}
> +
> +queue:
>  	waiter.task = current;
>  	waiter.type = RWSEM_WAITING_FOR_READ;
>  	waiter.timeout = jiffies + RWSEM_WAIT_TIMEOUT;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ