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: <20191217104519.GD2844@hirez.programming.kicks-ass.net>
Date:   Tue, 17 Dec 2019 11:45:19 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Davidlohr Bueso <dave@...olabs.net>
Cc:     mingo@...nel.org, will@...nel.org, oleg@...hat.com,
        tglx@...utronix.de, linux-kernel@...r.kernel.org,
        bigeasy@...utronix.de, juri.lelli@...hat.com, williams@...hat.com,
        bristot@...hat.com, longman@...hat.com, jack@...e.com
Subject: Re: [PATCH 5/5] locking/percpu-rwsem: Remove the embedded rwsem

On Mon, Nov 18, 2019 at 03:19:35PM -0800, Davidlohr Bueso wrote:
> Similarly, afaict we can get rid of __percpu_up_read() and put the
> slowpath all into percpu_up_read(). Also explicitly mention the
> single task nature of the writer (which is a better comment for
> the rcuwait_wake_up()).

> static inline void percpu_down_read(struct percpu_rw_semaphore *sem)
> {
> @@ -103,10 +102,23 @@ static inline void percpu_up_read(struct percpu_rw_semaphore *sem)
> 	/*
> 	 * Same as in percpu_down_read().
> 	 */
> +	if (likely(rcu_sync_is_idle(&sem->rss))) {
> 		__this_cpu_dec(*sem->read_count);
> +		goto done;
> +	}
> +
> +	/*
> +	 * slowpath; reader will only ever wake a single blocked writer.
> +	 */
> +	smp_mb(); /* B matches C */
> +	/*
> +	 * In other words, if they see our decrement (presumably to
> +	 * aggregate zero, as that is the only time it matters) they
> +	 * will also see our critical section.
> +	 */
> +	__this_cpu_dec(*sem->read_count);
> +	rcuwait_wake_up(&sem->writer);
> +done:
> 	preempt_enable();
> }

Let me write that as a normal if () { } else { }.

But yes, that's small enough I suppose.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ