Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6771197rdb; Fri, 15 Dec 2023 07:59:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+TEHoV0ii/RRYnHiqLFVq3mZ3GCTbfyuwxwV45eY0PZSto8uX+yVi/C70Tlye1i52vRC1 X-Received: by 2002:a05:622a:490:b0:425:4043:18b3 with SMTP id p16-20020a05622a049000b00425404318b3mr17461065qtx.102.1702655977746; Fri, 15 Dec 2023 07:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702655977; cv=none; d=google.com; s=arc-20160816; b=N7Do52QEK8G6vGcLVLqYoqrCNyClMB3kQ8XOQpwrVGxHt4aBFMWM0zzi/O9PwbQRt/ kfJf03/o6q4xFe0IHHgT/ON6gMpN9ygmimYuOOmYLjarJCJCoDgK+tg5s6owQUltrs8Y 3X96lqW4bgWAvYbEgFa5cd3HsZrI8ilHcafsxCpukdfJ22yZLuajM5oW8t9td1oS3TSQ cXMnh625TWYBR04AkC/RDgCGFJ3Hbw+XCaKMWTSn2ATLzmTHSDgpCRGOYPd+bermvfzi JPZOAGhlSMz6z4Ed7FZpa7PoEUExxxLeX3ogREoc0gArJOKIc0wGdnksVOPPFeOoSZvL Fzfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=MG9yAVm50lR8ICiHnRNf31I38rZ2htO3wSzdsU8ztZ4=; fh=/690AiFCPftrY/Y8HDEHS5zesfXpuJxVI8+0uH4VooI=; b=fE+GX65LUkx35DR9D+PrPS/yDw1MvoRRwEYWLY6aQGjxvbPWfBJ5WXrySoWuxD5Sy6 cZlO/GLIXGiOrvvjvGUVFWfVeIaArjDGpTE5v38HoTta2Z3I28tGq7AgD9In0wBGrC5K IQb1vUweHsMlc0I8IxEtncCIrGVeLweLVuvHyKm0bLhNaxs+gs4NlxcllAvnoA6EtQor 8KkwgUsmNX1bJSK1KTrNmTlasAGNKImI4LISybd4a+iqZPGadNIUF4q/X1N8+K/Ijq8O bYZDY0NDd/t1F7smUp3IZ1kUMZtzyN8bG9jSHZsu5YGRIi1OlDDWp+09qG2Mp56C/feg e2Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bYfocM7G; spf=pass (google.com: domain of linux-kernel+bounces-1241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1241-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 eo15-20020a05622a544f00b004254ac3f2c0si19859282qtb.211.2023.12.15.07.59.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 07:59:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1241-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=bYfocM7G; spf=pass (google.com: domain of linux-kernel+bounces-1241-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1241-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 3A18D1C20E24 for ; Fri, 15 Dec 2023 15:59:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 274A739FE4; Fri, 15 Dec 2023 15:59:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bYfocM7G" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (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 1B8F836AE0; Fri, 15 Dec 2023 15:59:21 +0000 (UTC) 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-oa1-f49.google.com with SMTP id 586e51a60fabf-20335dcec64so541010fac.3; Fri, 15 Dec 2023 07:59:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702655961; x=1703260761; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MG9yAVm50lR8ICiHnRNf31I38rZ2htO3wSzdsU8ztZ4=; b=bYfocM7GSsVJZf+EwNVkKSYt/oXyb8nGzid2gsTO2283SPe3R37/mMjljASE/+Rb9q XvX3xL+W91GJraaTBWTpLe1x8lUgf0OzQOMur+vrCr17d9qRTOighCn7q7XmsTe9M0Wg M6Xngw2hBRYjHYDSVZ2QtiBFHBuRghiuQX21on0ZpPh7zRxu/GcQxh/eV/32FeLmaAxq AJSP3U/uX9DrMqJNPjPphQhp/y0NTdsYSn2gIQQfPXkmyKpy5XHByF29odBuRSqI7Xqj HYzSzCcHx7mnfjiu2Sbb+0P8u1aDopCLsbx2GKaXBjpLB4aQtAQm5ZdDuUMPdM3qzBWY s8LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702655961; x=1703260761; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MG9yAVm50lR8ICiHnRNf31I38rZ2htO3wSzdsU8ztZ4=; b=JDefa4x2zHAypvm+VMptdNqEQuq6cJpvx0VoclmhB6TLTugDUNg40Rtg29mD0V99Yl n39HtJIueoGdllDM4piGasJ9m/2VHWc1Z+HGivP2sPCi9CU0HgN1wZ9W1+pPJzIabOIk X6VIjhUoJCIXE9mqFdb4CwXYY/Bm8J1wJnfR8PPxsJ5QOTB1RgSIkihPh/OicxrzMTsU mMIPpE+UTdA6I2FCTuvJlAnr3LDAg9CiCYLqkBmR2aQaIi9ZOpdn83WvY5LiPxyl4JRE 8gs7XHUzyezoeTw5xafb/zUL2MnDx8E9lG3yvuCs1Ss2bVhoSKINmddTNDjnfAxfqyQI hgFQ== X-Gm-Message-State: AOJu0YwLYKSEom2S2R9Gq1zcEqN11uilEkUc9fdtcGl0geLixr8Y3YzS 2wb7SgK8s7rBPz1gTfOgD2II7L1mlfyRMUH5wtoV+CI6GW7tzg== X-Received: by 2002:a05:6870:9383:b0:1f9:e6cb:7eb5 with SMTP id b3-20020a056870938300b001f9e6cb7eb5mr13635905oal.18.1702655961087; Fri, 15 Dec 2023 07:59:21 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231214173614.2820929-3-gnstark@salutedevices.com> In-Reply-To: From: Andy Shevchenko Date: Fri, 15 Dec 2023 17:58:44 +0200 Message-ID: Subject: Re: [PATCH RFC v4-bis] locking: introduce devm_mutex_init To: Christophe Leroy Cc: pavel@ucw.cz, lee@kernel.org, vadimp@nvidia.com, mpe@ellerman.id.au, npiggin@gmail.com, hdegoede@redhat.com, mazziesaccount@gmail.com, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, nikitos.tr@gmail.com, George Stark , kernel@salutedevices.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 15, 2023 at 8:23=E2=80=AFAM Christophe Leroy wrote: > > From: George Stark > > Using of devm API leads to a certain order of releasing resources. > So all dependent resources which are not devm-wrapped should be deleted > with respect to devm-release order. Mutex is one of such objects that > often is bound to other resources and has no own devm wrapping. > Since mutex_destroy() actually does nothing in non-debug builds > frequently calling mutex_destroy() is just ignored which is safe for now > but wrong formally and can lead to a problem if mutex_destroy() will be > extended so introduce devm_mutex_init() Missing period. ... > } while (0) > #endif /* CONFIG_PREEMPT_RT */ ^^^ (1) > +struct device; > + > +/* > + * devm_mutex_init() registers a function that calls mutex_destroy() > + * when the ressource is released. > + * > + * When mutex_destroy() is a not, there is no need to register that > + * function. > + */ > +#ifdef CONFIG_DEBUG_MUTEXES Shouldn't this be #if defined(CONFIG_DEBUG_MUTEXES) && !defined(CONFIG_PREEMPT_RT) (see (1) as well)? > +void mutex_destroy(struct mutex *lock); > +int devm_mutex_init(struct device *dev, struct mutex *lock); > +#else > +static inline void mutex_destroy(struct mutex *lock) {} > + > +static inline int devm_mutex_init(struct device *dev, struct mutex *lock= ) > +{ > + mutex_init(lock); > + return 0; > +} > +#endif --=20 With Best Regards, Andy Shevchenko