Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp7069111rdb; Fri, 15 Dec 2023 17:37:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAHshcqSJpQPqQgv66xmuvg8St4kW2AwTAs/GmpWervvwN3AdZBo5oJjLgFzkELsvQj+RU X-Received: by 2002:a05:6a20:3ca6:b0:18b:246a:d43d with SMTP id b38-20020a056a203ca600b0018b246ad43dmr16569577pzj.15.1702690660698; Fri, 15 Dec 2023 17:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702690660; cv=none; d=google.com; s=arc-20160816; b=oRWNmcdeRzwOYO8q5L9LepOPGdQ3A3dBzgcfATwcUI5Rr7VJkC3HB5xFz9pJntQRZ3 fQqkyjtK7HQ89R6l5RkQk03jtRGAQaLhjbdZ4kx83GMhdvRt1+NrJtFT9E7oSX2Zka// r/Tn6mLJyusgoX15ogPc2/KEmMAuqBW5NedL8Gs6sWVjbKC8s/v5RJdZJu8AdbtX6hgY i04WLvyvFNvP7k9zEWH47mq6yd+tLID03+aQoQbINh/IyUC/OoSnfk2/OwTbUZXX9vc9 ei01DPbTJodY5bcl4Llun88DTLTRHHBs1G3/ZwSS7TG7svUJBc7kPpYND2oKZ+frRwim WPVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=loZzHfg5cjOtTZMvCdMslIQGPsJFkjb8FLnNRMqhX5E=; fh=c25v70+ehGE+SiLl84UT2m6flxwHxsFK+3J6BVG3azM=; b=SktJOUoa4CFo8gBz39qw9DWiFTjYCJqOuXuik2V1CS4hlmxfw5EIzKkb5BqLFDuOw+ E50GfrCWyRLphIrKszmcXsuXjgEaE7AOx+EMwFKHQwRAV8sqxur6o5k5Gb+UkD6Sqlc9 eNzGwhzG+5pgKFqbKQAy1DQ4ClR5TkP9q3z0vTeKWhIuJUFrtgwInXrGB/aaErnynkJ7 DhLjEuImJuM1EciDEMyaEhCx1882Qfql0owlo/+RdCjtzXiIOLS0ULTDj+B2Rc5+zMSr aoSc9gibC2Ly8YjbnL6hLbU3BvRiMWpKuoqN9v8RvMLk+SUly7G69eNh61ig9hJuYX5v /jfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gstNuOwp; spf=pass (google.com: domain of linux-kernel+bounces-1931-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l3-20020a056a00140300b006cd989cfe42si13904270pfu.7.2023.12.15.17.37.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 17:37:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1931-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gstNuOwp; spf=pass (google.com: domain of linux-kernel+bounces-1931-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5E6EB2877A6 for ; Sat, 16 Dec 2023 01:37:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A89A29B4; Sat, 16 Dec 2023 01:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gstNuOwp" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2572923C9 for ; Sat, 16 Dec 2023 01:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702690640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=loZzHfg5cjOtTZMvCdMslIQGPsJFkjb8FLnNRMqhX5E=; b=gstNuOwpAGPgfFUhgqjZsbeO8DHdAIc+TA0qa6dyv8OvukFQbgAdgu56Tpf2/wBokodDAM dWz6/TD0pIFW37sQ0sy1iGmTbJH1fYZ6a4SI2sRVcrTS/lzmYE0rZG6ujj7ieqyMAVewmK OZvLjiUDzEIkEeyNN+bnOjus3hmfQBQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-AiBJfIo7OBykckdORScFAQ-1; Fri, 15 Dec 2023 20:37:17 -0500 X-MC-Unique: AiBJfIo7OBykckdORScFAQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4956185A780; Sat, 16 Dec 2023 01:37:16 +0000 (UTC) Received: from llong.com (unknown [10.22.9.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48D58C15968; Sat, 16 Dec 2023 01:37:16 +0000 (UTC) From: Waiman Long To: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Andrew Morton Cc: linux-kernel@vger.kernel.org, George Stark , Waiman Long Subject: [PATCH 1/2] locking/mutex: Clean up mutex.h Date: Fri, 15 Dec 2023 20:36:55 -0500 Message-Id: <20231216013656.1382213-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 CONFIG_DEBUG_MUTEXES and CONFIG_PREEMPT_RT are mutually exclusive. They can't be both set at the same time. Move down the mutex_destroy() function declaration to the bottom of mutex.h to eliminate duplicated mutex_destroy() declaration. Also remove the duplicated mutex_trylock() function declaration in the CONFIG_PREEMPT_RT section. Signed-off-by: Waiman Long --- include/linux/mutex.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/include/linux/mutex.h b/include/linux/mutex.h index a33aa9eb9fc3..f3ae911580bf 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -77,18 +77,10 @@ struct mutex { }; #ifdef CONFIG_DEBUG_MUTEXES - -#define __DEBUG_MUTEX_INITIALIZER(lockname) \ +# define __DEBUG_MUTEX_INITIALIZER(lockname) \ , .magic = &lockname - -extern void mutex_destroy(struct mutex *lock); - #else - # define __DEBUG_MUTEX_INITIALIZER(lockname) - -static inline void mutex_destroy(struct mutex *lock) {} - #endif /** @@ -151,9 +143,6 @@ struct mutex { extern void __mutex_rt_init(struct mutex *lock, const char *name, struct lock_class_key *key); -extern int mutex_trylock(struct mutex *lock); - -static inline void mutex_destroy(struct mutex *lock) { } #define mutex_is_locked(l) rt_mutex_base_is_locked(&(l)->rtmutex) @@ -220,6 +209,16 @@ extern void mutex_unlock(struct mutex *lock); extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock); +#ifdef CONFIG_DEBUG_MUTEXES + +extern void mutex_destroy(struct mutex *lock); + +#else + +static inline void mutex_destroy(struct mutex *lock) {} + +#endif + DEFINE_GUARD(mutex, struct mutex *, mutex_lock(_T), mutex_unlock(_T)) DEFINE_FREE(mutex, struct mutex *, if (_T) mutex_unlock(_T)) -- 2.39.3