Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp125261rdb; Wed, 21 Feb 2024 20:34:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVB1YNvwd+b2TEXlf53OYh6dDo0OLyJ0P59ER5wwQelVhRNmHmlk41dt2yKt832DacqMDCQETMQhnI60q5hXCUU3fTok8iO5BVElhFQrA== X-Google-Smtp-Source: AGHT+IGTauyUw7DJF/IOjnoCNHVx7Gx5o9HgufSu1yWEmJ2nWWkMEn1KYymJvJFXD+zwkSPZ/pMN X-Received: by 2002:a05:622a:446:b0:42c:3c63:d3dd with SMTP id o6-20020a05622a044600b0042c3c63d3ddmr21365074qtx.10.1708576446430; Wed, 21 Feb 2024 20:34:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708576446; cv=pass; d=google.com; s=arc-20160816; b=nXTYNiDtjWaVjlD6H9hdcZ7hqBbXNVPA6EQmG0DnWI3va4jQJcX/SsFbwgHK8ERVQi 8Q00j2lMTUFLkTPRg8rrllXcPnv5bVs4VIqMqrSazMX5Dag/8UWS5ZhzRBn3KB0kHqQ2 8IB3Yf9UzmmMkWZp5/DXuqqSQMrjJljU8tuE7tH7TfHrdqOBFZ2Eoxdh+jNUcnYp+t55 IGs0SWTZLFO6bVV399YsFsYmfHRFz1rHWn3QIMfnlvPBh3mLcVLCPONUEPN6NDYVc+2b 6K/g07XVTfbfKqJRSHvWuCLlQUKAX5DVb5D+buInauln2EZcfDbtG+keLkixMK5WOetM MNiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature; bh=W3tpSfmR2x5ajWcVpUjqxqmwx2Kltpoj+DQ1nUuQVkw=; fh=GRPm3VpIfFRb24pk1b5Qv2wQbsO6KL4lmfaEQHakNfo=; b=CuRYNmnTnVqxjG18FuuzKd/oh1G2dTwg+O9fuUoQPeZj5nt+vInvCskqpzYODQSYxZ jVii3t5yj5BF3HzUaN4YYUkpPxFP4ImZ8H2XfkaMFSky8RLgkCsKjhILxNh207WKAq8B ZUSstsf0E4t0L0rWH5A6X1qgzFNkuMo8W0jn34T+2cknw4px3GHekbJ/hsQG3Sqhw53b djCZUCB4l/7X/WuWKg1cKYxidOCscBZ6sP3x1OSwzzrrBPVPa/2fRKjyjU6pAJEH90vn tcbXwau0l8pGNp2CnxhNQ1y4DTloO7V1ufjqSqPU4TiIG0ROoVjm8pdRSQFFJBfDYBIP IczQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lvTeefyT; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-75900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c20-20020ac87d94000000b0042e12acefdesi8734223qtd.757.2024.02.21.20.34.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 20:34:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-75900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lvTeefyT; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-75900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-75900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 279A01C21BBA for ; Thu, 22 Feb 2024 04:34:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAFC71C14; Thu, 22 Feb 2024 04:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lvTeefyT" Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56DBA10E5 for ; Thu, 22 Feb 2024 04:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708576440; cv=none; b=pVRtG0msYen6HRQyWlM3/oIpN+isUeJDVvZgMueOc53F/x+NXRnb9bULfiPbTR40mbVlMDt+jWNuYSPEN/cZ5G3B61v7cvtmTGHYLRW+TAngaxbDOoGKIoQzxNPs8DcNPCVkotWnfzK+UqcV2+uRN4Zis4rWidnjP28YemPp4FE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708576440; c=relaxed/simple; bh=sVXz+f++d53qtpGRQym7t+k0uOPY55Nm6vRJJjr/34s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S+AcvGnAXmyS+Pbw/b567NjmbWNKJ9pq1XuwP6wt651EYIN/8dGqey8dkG16IznjPyyEu19O6fLKIWeUnlUiFvQZGJAV+b6r8T08FTP5cl4R8/3GQtrSlDLGg4n+iCXH6TSOaQpC8WlQspGebOMRfiNEu1jsH4VRKrlAYeK7WPA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lvTeefyT; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-42dd9dfe170so27109891cf.1 for ; Wed, 21 Feb 2024 20:33:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708576438; x=1709181238; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=W3tpSfmR2x5ajWcVpUjqxqmwx2Kltpoj+DQ1nUuQVkw=; b=lvTeefyTUikmN06rH26k2UPF2ua/d3TcxZmK1OVhQcLSHPX2YsAVrHG+YHETuhOGTm 6gpqrJ3pHYeX7fHZJ6cqBMWb01L7xxsK3hQetcSFgXNdZ1ZQnUVEUDnh1JswXbhEWVaC KKqdz323fSFsnkfvsbF3xuJvuWP/+NhM4OhIDgnmSQo62/5oZvxuT8yq+W5KTGPVHGLZ UH/FrZgGsYmpbFG+g7iH8ENKrhBIpj1VSWEvmJiaPx6unVLv6uIwPpXGsgTUXxN09Pm8 lpv4whM77fWd8a2HvaEKeFxz4Y7wB3o1vzGrAUouTLKAgWv1n6ZdAV5OybBglxirMQpV LFxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708576438; x=1709181238; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W3tpSfmR2x5ajWcVpUjqxqmwx2Kltpoj+DQ1nUuQVkw=; b=jogQTNPijDubvpgwsOaopgSrU9+ofCK7JHUtdckWTGTUpiugLS6orIcxOU6u4/e03H 3AwOCzmgp+Yx1ro3RPOZCl7gE3pZDMf0mHkdsw6EHVvg70BNCqcG7sZryyTe+Qo6YmcL O+ZN+3iIewca5VI9bS/LkVEwiT37RCxBgR2VBzLM1GWiJHcjL+jztq1+5T2orQwzgTpo BBxorI+Owpk1RC2f2RNQ67wRPDjSgRZX7XkCkviLRBZHmCxyayj5JjVXP73t37OW4lRq IT9oz0jHixsjbWx345FPCecHPWPH4pb4hRV6ut9UQVroLDRlOBdqzo5qER+H4atC38i/ WJKQ== X-Forwarded-Encrypted: i=1; AJvYcCU11/JrXFLD2HhDYj4nNl9BypWRZP/Q+Lttg9lOfSboCUbyoGvNN+GAvKe6qmblYdBCzcu7Lv0rQJNi7btyL18ffgasVwYc9JJ5gciI X-Gm-Message-State: AOJu0YwRzxQDj2aD5y32qX5cH3SDY8itNZtPmmhvWjL81XpJnMM+GfF0 CdpHbedokh2QpjM/S/MMF3v0aUMkdxpO1S0i75lxMgW68irI3T00 X-Received: by 2002:ac8:5ad3:0:b0:42d:b5fd:3fca with SMTP id d19-20020ac85ad3000000b0042db5fd3fcamr19867293qtd.31.1708576438140; Wed, 21 Feb 2024 20:33:58 -0800 (PST) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id a8-20020a05622a064800b0042994b3c20dsm5012742qtb.29.2024.02.21.20.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 20:33:57 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id EF1B227C005B; Wed, 21 Feb 2024 23:33:56 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 21 Feb 2024 23:33:56 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefgdejudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedugfduffffteeutddvheeuveelvdfhleelieevtdeguefhgeeuveeiudff iedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsg hoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieeg qddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigi hmvgdrnhgrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Feb 2024 23:33:55 -0500 (EST) Date: Wed, 21 Feb 2024 20:33:32 -0800 From: Boqun Feng To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Andrew Morton , linux-kernel@vger.kernel.org, George Stark Subject: Re: [PATCH 2/4] locking/mutex: Clean up mutex.h Message-ID: References: <20240213031656.1375951-1-longman@redhat.com> <20240213031656.1375951-3-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240213031656.1375951-3-longman@redhat.com> On Mon, Feb 12, 2024 at 10:16:54PM -0500, Waiman Long wrote: > 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 Reviewed-by: Boqun Feng Although, can you move the first "#ifdef CONFIG_DEBUG_MUTEXES" out of the "#ifndef CONFIG_PREEMPT_RT" and combine it with the second one, i.e. #ifdef CONFIG_DEBUG_MUTEXES # define __DEBUG_MUTEX_INITIALIZER(lockname) ... extern void mutex_destroy(struct mutex *lock); #else # define __DEBUG_MUTEX_INITIALIZER(lockname) .. static inline void mutex_destroy(struct mutex *lock) {} #endif #ifndef CONFIG_PREEMPT_RT ... Thoughts? Regards, Boqun > --- > 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 7e208d46ba5b..bad383713db2 100644 > --- a/include/linux/mutex.h > +++ b/include/linux/mutex.h > @@ -35,18 +35,10 @@ > #ifndef CONFIG_PREEMPT_RT > > #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 > > /** > @@ -101,9 +93,6 @@ extern bool mutex_is_locked(struct mutex *lock); > > 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) > > @@ -170,6 +159,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_GUARD_COND(mutex, _try, mutex_trylock(_T)) > DEFINE_GUARD_COND(mutex, _intr, mutex_lock_interruptible(_T) == 0) > -- > 2.39.3 >