Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp7066977rdb; Fri, 15 Dec 2023 17:31:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQT++QmZm/mmBvqUOW5b3mQIsbfcC1NKpYDNsdu+vb/EjDBBDq35aw+rK9GH4h6SNdnoNK X-Received: by 2002:a05:6808:1295:b0:3b8:b063:5d70 with SMTP id a21-20020a056808129500b003b8b0635d70mr17542047oiw.87.1702690274287; Fri, 15 Dec 2023 17:31:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702690274; cv=none; d=google.com; s=arc-20160816; b=gnqEicYmlgaij3bmJK7mT9NtMG2aIGqm9lSpRpCWlxd+kHo8sAq5LMLDqGhrnNjlZE XWxcVhsUGB4QvapVttjMyRhBgQVIVvP3u9laIISon3Ls+d0bEphj4Dg3xGrsUJuruJXp YSfMQt76tV6hJ0voyPLgA9Eadevf6yubDpqtrwHk3VUGyN9FGnvhiXVulK9Yjn1r9wHJ 6wEXqZc7VM9qAv0Zb/BoEdYC0+adn7Az0K5nve9Mt5to1vhAg81nIlUU/6SsWo5gOshA NBlr5cS257yM3jdbFj/aNBTPwNS0jo9PYNs0kFKdn2M1WnQ+IZZohWswKRFlrspGW2Pl o6CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=mVlrB+oQEuOU8B0i3W32kFhArbOa2dYtoStKRM7GlpY=; fh=OiU6zsrZ50E0N2PZQK6CP1V59/yIBEkoGMAvdRK1wfs=; b=m5xp4svF5lEVq+RCnKrU30uYBP5lPBAJxngQdl6a7pUMHRSk+iNbMLtwe5CXX9q0n2 7JQiKLp4xe4z+46XwBck4q8RG1vSWkBQP0nC+u2T6O4P+6+F9/564wWbzvdqmM2ewc7k Ka6xzBgruCI8JSJOFL9ArtRD+6q8qpfiWUh2pc6zPOxqT+EqylJ1stD7R+QNRi0Mchm6 gxrBHgrPlBjEroAaUdVsooJmSI8YH9ydwruOOI+pIf29UFFsCbIPxFAbdAHa25eT1A0n 659N5VRWdKuQSIPEjGimH13/5Xl0TrcbGtkPTybQT6vdaxkRlcusK6XdrOCI/TOOeSxZ 8wLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W9WJRJFn; spf=pass (google.com: domain of linux-kernel+bounces-1927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c11-20020aa78c0b000000b006cd8567235bsi13504898pfd.237.2023.12.15.17.31.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 17:31:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W9WJRJFn; spf=pass (google.com: domain of linux-kernel+bounces-1927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1927-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A0B4DB240B3 for ; Sat, 16 Dec 2023 01:31:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53B041116; Sat, 16 Dec 2023 01:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="W9WJRJFn" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 0E23C10F1 for ; Sat, 16 Dec 2023 01:30:59 +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=1702690258; 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: in-reply-to:in-reply-to:references:references; bh=mVlrB+oQEuOU8B0i3W32kFhArbOa2dYtoStKRM7GlpY=; b=W9WJRJFnuUiWd+DO7n661VgqGVaZ0ynLPydF4uwu3fjtFgeUiNluigUn8AQV+ravQuj1Zm l+WVq0+Tt/6q+6vUj22Mzz6lnD5GouimIMLuvbaKaqWndMK29BPvJXRQBncHpaQlbyWbBg eX7+Cq82kxVJNiPLDNq4RPNMFRS9iN8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-swiyUIjUOvCYb61XDJkKDw-1; Fri, 15 Dec 2023 20:30:54 -0500 X-MC-Unique: swiyUIjUOvCYb61XDJkKDw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 66A9329AB3E0; Sat, 16 Dec 2023 01:30:53 +0000 (UTC) Received: from [10.22.9.217] (unknown [10.22.9.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2B942166B31; Sat, 16 Dec 2023 01:30:51 +0000 (UTC) Message-ID: <550a22b0-dfc9-427f-bbf0-3c6854e9867d@redhat.com> Date: Fri, 15 Dec 2023 20:30:51 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC v4-bis] locking: introduce devm_mutex_init Content-Language: en-US To: Andy Shevchenko , 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, 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 References: <20231214173614.2820929-3-gnstark@salutedevices.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 On 12/15/23 10:58, Andy Shevchenko wrote: > On Fri, Dec 15, 2023 at 8:23 AM 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)? CONFIG_DEBUG_MUTEXES and CONFIG_PREEMPT_RT are mutually exclusive. At most one of them can be set. Cheers, Longman