Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a40ca565 authored by Waiman Long's avatar Waiman Long Committed by Ingo Molnar
Browse files

locking/mutex: Simplify some ww_mutex code in __mutex_lock_common()



This patch removes some of the redundant ww_mutex code in
__mutex_lock_common().

Tested-by: default avatarJason Low <jason.low2@hpe.com>
Signed-off-by: default avatarWaiman Long <Waiman.Long@hpe.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Ding Tianhong <dingtianhong@huawei.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul E. McKenney <paulmck@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Will Deacon <Will.Deacon@arm.com>
Link: http://lkml.kernel.org/r/1472254509-27508-1-git-send-email-Waiman.Long@hpe.com


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 5bbd7e64
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -587,10 +587,11 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
	struct mutex_waiter waiter;
	unsigned long flags;
	bool first = false;
	struct ww_mutex *ww;
	int ret;

	if (use_ww_ctx) {
		struct ww_mutex *ww = container_of(lock, struct ww_mutex, base);
		ww = container_of(lock, struct ww_mutex, base);
		if (unlikely(ww_ctx == READ_ONCE(ww->ctx)))
			return -EALREADY;
	}
@@ -602,12 +603,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
	    mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx)) {
		/* got the lock, yay! */
		lock_acquired(&lock->dep_map, ip);
		if (use_ww_ctx) {
			struct ww_mutex *ww;
			ww = container_of(lock, struct ww_mutex, base);

		if (use_ww_ctx)
			ww_mutex_set_context_fastpath(ww, ww_ctx);
		}
		preempt_enable();
		return 0;
	}
@@ -691,10 +688,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
	/* got the lock - cleanup and rejoice! */
	lock_acquired(&lock->dep_map, ip);

	if (use_ww_ctx) {
		struct ww_mutex *ww = container_of(lock, struct ww_mutex, base);
	if (use_ww_ctx)
		ww_mutex_set_context_slowpath(ww, ww_ctx);
	}

	spin_unlock_mutex(&lock->wait_lock, flags);
	preempt_enable();