From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 031F9C4338F for ; Wed, 11 Aug 2021 12:25:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF1A261019 for ; Wed, 11 Aug 2021 12:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237904AbhHKM0J (ORCPT ); Wed, 11 Aug 2021 08:26:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238241AbhHKMX6 (ORCPT ); Wed, 11 Aug 2021 08:23:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA2DAC0617A0 for ; Wed, 11 Aug 2021 05:23:21 -0700 (PDT) Message-ID: <20210811121416.537798951@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628684600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=WKUD652qEqq/h2PfUER+Dah0Y3gklh6mO5qTzyZc3oY=; b=JeHo40hNSivWgzgA9/EjyGV+pRVLrxfP3hXy5FDlxiXbwK0YoZTizajVkTwFcjMwsxqaWa 3SnmFYJUAn/SVxH+1x/Nw8l8NdlSbIGSUgekMcxflasyOcG+WsOelWijjX4x00PsLdH4As jGOJR+h28cDXUVUqQVmQE+63a2j30ToltRNCZUv4kv7dX+v/Kyx9otmGz1lfhTy3RllfIN 4BMJ6CLD4mq3qrADv8XueZUimaRDuzr+xDRgtqAEInhYfCqTGrsP9GT/FWj6QDqy9+My66 jilmTav4kBwdjeAahxysXfMSVfa0XAoJi+06BduVWYDq/qh2V7Zmk0ERqyszWw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628684600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=WKUD652qEqq/h2PfUER+Dah0Y3gklh6mO5qTzyZc3oY=; b=P0Jh+yT+jbRKiqg6tPlILSdswcJPrKsjjWJmIyAfGvSLuYiSl+TQcrV0Is68hFjIc3Mj2A YFqkiNUPhOmmN3Dg== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Steven Rostedt , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , Sebastian Andrzej Siewior , Davidlohr Bueso , Mike Galbraith Subject: [patch V4 40/68] locking/ww_mutex: Split up ww_mutex_unlock() References: <20210811120348.855823694@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit Date: Wed, 11 Aug 2021 14:23:20 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra Split the ww related part out into a helper function so it can be reused for a rtmutex based ww_mutex implementation. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner --- kernel/locking/mutex.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) --- --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -750,19 +750,7 @@ EXPORT_SYMBOL(mutex_unlock); */ void __sched ww_mutex_unlock(struct ww_mutex *lock) { - /* - * The unlocking fastpath is the 0->1 transition from 'locked' - * into 'unlocked' state: - */ - if (lock->ctx) { -#ifdef CONFIG_DEBUG_MUTEXES - DEBUG_LOCKS_WARN_ON(!lock->ctx->acquired); -#endif - if (lock->ctx->acquired > 0) - lock->ctx->acquired--; - lock->ctx = NULL; - } - + __ww_mutex_unlock(lock); mutex_unlock(&lock->base); } EXPORT_SYMBOL(ww_mutex_unlock); @@ -915,6 +903,18 @@ static inline int __sched return 0; } +static void __ww_mutex_unlock(struct ww_mutex *lock) +{ + if (lock->ctx) { +#ifdef CONFIG_DEBUG_MUTEXES + DEBUG_LOCKS_WARN_ON(!lock->ctx->acquired); +#endif + if (lock->ctx->acquired > 0) + lock->ctx->acquired--; + lock->ctx = NULL; + } +} + /* * Lock a mutex (possibly interruptible), slowpath: */