From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941587AbcJYKaG (ORCPT ); Tue, 25 Oct 2016 06:30:06 -0400 Received: from terminus.zytor.com ([198.137.202.10]:60864 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933652AbcJYKaE (ORCPT ); Tue, 25 Oct 2016 06:30:04 -0400 Date: Tue, 25 Oct 2016 03:29:10 -0700 From: tip-bot for Waiman Long Message-ID: Cc: dingtianhong@huawei.com, tglx@linutronix.de, jason.low2@hpe.com, paulmck@linux.vnet.ibm.com, tim.c.chen@linux.intel.com, paulmck@us.ibm.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, dave@stgolabs.net, hpa@zytor.com, imre.deak@intel.com, torvalds@linux-foundation.org, Will.Deacon@arm.com, mingo@kernel.org, peterz@infradead.org, Waiman.Long@hpe.com Reply-To: paulmck@linux.vnet.ibm.com, paulmck@us.ibm.com, tim.c.chen@linux.intel.com, dingtianhong@huawei.com, jason.low2@hpe.com, tglx@linutronix.de, Will.Deacon@arm.com, torvalds@linux-foundation.org, imre.deak@intel.com, Waiman.Long@hpe.com, peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, dave@stgolabs.net, hpa@zytor.com In-Reply-To: <1472254509-27508-1-git-send-email-Waiman.Long@hpe.com> References: <1472254509-27508-1-git-send-email-Waiman.Long@hpe.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/mutex: Simplify some ww_mutex code in __mutex_lock_common() Git-Commit-ID: a40ca56577f628eb3f7af22b484e95edfdd047a2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a40ca56577f628eb3f7af22b484e95edfdd047a2 Gitweb: http://git.kernel.org/tip/a40ca56577f628eb3f7af22b484e95edfdd047a2 Author: Waiman Long AuthorDate: Fri, 26 Aug 2016 19:35:08 -0400 Committer: Ingo Molnar CommitDate: Tue, 25 Oct 2016 11:31:53 +0200 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: Jason Low Signed-off-by: Waiman Long Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Davidlohr Bueso Cc: Ding Tianhong Cc: Imre Deak Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tim Chen Cc: Will Deacon Link: http://lkml.kernel.org/r/1472254509-27508-1-git-send-email-Waiman.Long@hpe.com Signed-off-by: Ingo Molnar --- kernel/locking/mutex.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index 8bb2304..6c0d304 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -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 @@ skip_wait: /* 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();