From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755429AbcIEMoF (ORCPT ); Mon, 5 Sep 2016 08:44:05 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:45618 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754689AbcIEMoD (ORCPT ); Mon, 5 Sep 2016 08:44:03 -0400 Message-Id: <20160905124027.678433729@infradead.org> User-Agent: quilt/0.61-1 Date: Mon, 05 Sep 2016 14:36:44 +0200 From: Peter Zijlstra To: Linus Torvalds , Waiman Long , Jason Low , Ding Tianhong , Thomas Gleixner , Will Deacon , Ingo Molnar , Imre Deak , Linux Kernel Mailing List , Davidlohr Bueso , Tim Chen , Terry Rudd , "Paul E. McKenney" , Jason Low , Peter Zijlstra Cc: Waiman Long Subject: [PATCH -v3 08/10] locking/mutex: Simplify some ww_mutex code in __mutex_lock_common() References: <20160905123636.450529224@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=waiman_long-locking_mutex-simplify_some_ww_mutex_code_in___mutex_lock_common.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch removes some of the redundant ww_mutex code in __mutex_lock_common(). Cc: Ingo Molnar Cc: Linus Torvalds Cc: Tim Chen Cc: Thomas Gleixner Cc: Imre Deak Cc: Jason Low Cc: "Paul E. McKenney" Cc: Ding Tianhong Cc: Davidlohr Bueso Cc: Will Deacon Signed-off-by: Waiman Long Signed-off-by: Peter Zijlstra (Intel) Link: http://lkml.kernel.org/r/1472254509-27508-1-git-send-email-Waiman.Long@hpe.com --- kernel/locking/mutex.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -580,10 +580,11 @@ __mutex_lock_common(struct mutex *lock, 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; } @@ -595,12 +596,8 @@ __mutex_lock_common(struct mutex *lock, 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; } @@ -680,10 +677,8 @@ __mutex_lock_common(struct mutex *lock, /* 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();