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: <20180518084122.GA14307@redhat.com>
Date:   Fri, 18 May 2018 10:41:23 +0200
From:   Oleg Nesterov <oleg@...hat.com>
To:     Ingo Molnar <mingo@...nel.org>
Cc:     Matthew Wilcox <willy@...radead.org>,
        Waiman Long <longman@...hat.com>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        Davidlohr Bueso <dave@...olabs.net>,
        "Theodore Y. Ts'o" <tytso@....edu>,
        Amir Goldstein <amir73il@...il.com>, Jan Kara <jack@...e.cz>
Subject: Re: [PATCH v4 1/2] locking/rwsem: Add a new RWSEM_ANONYMOUSLY_OWNED
 flag

On 05/18, Ingo Molnar wrote:
>
>
> * Matthew Wilcox <willy@...radead.org> wrote:
>
> > This is confusingly written.  I think you mean ...
> >
> > 	if (!owner)
> > 		goto done;
> > 	if (!is_rwsem_owner_spinnable(owner)) {
> > 		ret = false;
> > 		goto done;
> > 	}
>
> Yes, that's cleaner. Waiman, mind sending a followup patch that cleans this up?

Or simply

	static inline bool owner_on_cpu(struct task_struct *owner)
	{
		return owner->on_cpu && !vcpu_is_preempted(task_cpu(owner));
	}

	static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem)
	{
		struct task_struct *owner;
		bool ret = true;

		if (need_resched())
			return false;

		rcu_read_lock();
		owner = READ_ONCE(sem->owner);
		if (owner) {
			ret = is_rwsem_owner_spinnable(owner) &&
			      owner_on_cpu(owner);
		}
		rcu_read_unlock();
		return ret;
	}

note that rwsem_spin_on_owner() can use the new owner_on_cpu() helper too,

		if (need_resched() || !owner_on_cpu(owner)) {
			rcu_read_unlock();
			return false;
		}

looks a bit better than the current code:

		if (!owner->on_cpu || need_resched() ||
				vcpu_is_preempted(task_cpu(owner))) {
			rcu_read_unlock();
			return false;
		}

Oleg.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ