Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1485299pxy; Mon, 2 Aug 2021 02:51:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywjoos1N74hHXrOromyBC9ckEgt0AaKzA/vMKJ22gKMnq9RsIHKXwBEYjhWQEh/rAA12wY X-Received: by 2002:a17:906:c0cd:: with SMTP id bn13mr15062781ejb.251.1627897909294; Mon, 02 Aug 2021 02:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627897909; cv=none; d=google.com; s=arc-20160816; b=pZQXW8tY8aG48Etv3C1g5SBoLBfQMvmebnEJ44R0LhZqdijPi/VxvR5WZSF/2Dfxxe DI7YTuh1E3wQjeieGG/v/7gcbm/GxmCf7mcMeCfYsJHTTksDgqAI5pkFH37RIw/7Ae4I 0QVy2MvoMKvcChXKyvxr6PX6u29myfVHLnbAHX7DKB1tAYrk3uKTYaJt/p2+gEWwohQr I7/WaAckoIrS4CEKUHxeB6Q552zeGHCbzaIdu7dcYDYEoI8xRCS3NF9/57KJvI+nMnqP 8ZXYnrp/FYu6jbaafpcnLo8hSXPFDE5HCla4VyNhlKHKr/TQgnBTYlsqe4ZnvHLhnmkD VsCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=z1yRQnrlfLdFHNrWCfQWnrSMSb2xrthZ7DD2vZ6m+iA=; b=HnyC77hyWoe9+YqbaqdRLdz3AI/vAamOjnvCIXh9yyvGGgTb9p2Y00WsQ5nK/n7h7L e6aSlgVNOVm0ILL4xSslLdkqRABobKui4EN4hXeIGNssGtmDlpxQVyZyw6B89Z4aOUUC IOMe4GAGD+oi1B+b265T9iwzjqhAkBD2tWfjMaToYWAiNiXYzv8Mr5tVcqO2LbZedPxa BRk79k2n1OOBUyXuLHltF/Uzsy7632pq/Qa65k4ZMna8UEkIJdNQWt8FAEtiX/2riMqz JX0jKCOCamGuZ3vGwjKh/N7dMSGjZQkOWRn1+j+IWXjaZobfyeCt2HXRTRns7ny7o68s uQHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz19si10700766ejb.37.2021.08.02.02.51.25; Mon, 02 Aug 2021 02:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbhHBJto (ORCPT + 99 others); Mon, 2 Aug 2021 05:49:44 -0400 Received: from mga07.intel.com ([134.134.136.100]:15489 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232871AbhHBJtn (ORCPT ); Mon, 2 Aug 2021 05:49:43 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10063"; a="277192225" X-IronPort-AV: E=Sophos;i="5.84,288,1620716400"; d="scan'208";a="277192225" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 02:49:34 -0700 X-IronPort-AV: E=Sophos;i="5.84,288,1620716400"; d="scan'208";a="520446499" Received: from mariaf7x-mobl.amr.corp.intel.com (HELO [10.252.52.214]) ([10.252.52.214]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2021 02:49:31 -0700 Subject: Re: [PATCH v2 1/2] locking/lockdep: Provide lockdep_assert{,_once}() helpers To: Desmond Cheong Zhi Xi , mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch, peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, gregkh@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org References: <20210731082458.1962043-1-desmondcheongzx@gmail.com> <20210731082458.1962043-2-desmondcheongzx@gmail.com> From: Maarten Lankhorst Message-ID: <1450737c-719f-34ec-4d0f-581d8ac853ac@linux.intel.com> Date: Mon, 2 Aug 2021 11:49:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <20210731082458.1962043-2-desmondcheongzx@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Op 31-07-2021 om 10:24 schreef Desmond Cheong Zhi Xi: > From: Peter Zijlstra > > Extract lockdep_assert{,_once}() helpers to more easily write composite > assertions like, for example: > > lockdep_assert(lockdep_is_held(&drm_device.master_mutex) || > lockdep_is_held(&drm_file.master_lookup_lock)); > > Signed-off-by: Peter Zijlstra (Intel) > Signed-off-by: Desmond Cheong Zhi Xi > Acked-by: Boqun Feng > Acked-by: Waiman Long > --- > include/linux/lockdep.h | 41 +++++++++++++++++++++-------------------- > 1 file changed, 21 insertions(+), 20 deletions(-) > > diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h > index 5cf387813754..9fe165beb0f9 100644 > --- a/include/linux/lockdep.h > +++ b/include/linux/lockdep.h > @@ -306,31 +306,29 @@ extern void lock_unpin_lock(struct lockdep_map *lock, struct pin_cookie); > > #define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0) > > -#define lockdep_assert_held(l) do { \ > - WARN_ON(debug_locks && \ > - lockdep_is_held(l) == LOCK_STATE_NOT_HELD); \ > - } while (0) > +#define lockdep_assert(cond) \ > + do { WARN_ON(debug_locks && !(cond)); } while (0) > > -#define lockdep_assert_not_held(l) do { \ > - WARN_ON(debug_locks && \ > - lockdep_is_held(l) == LOCK_STATE_HELD); \ > - } while (0) > +#define lockdep_assert_once(cond) \ > + do { WARN_ON_ONCE(debug_locks && !(cond)); } while (0) > > -#define lockdep_assert_held_write(l) do { \ > - WARN_ON(debug_locks && !lockdep_is_held_type(l, 0)); \ > - } while (0) > +#define lockdep_assert_held(l) \ > + lockdep_assert(lockdep_is_held(l) != LOCK_STATE_NOT_HELD) > > -#define lockdep_assert_held_read(l) do { \ > - WARN_ON(debug_locks && !lockdep_is_held_type(l, 1)); \ > - } while (0) > +#define lockdep_assert_not_held(l) \ > + lockdep_assert(lockdep_is_held(l) != LOCK_STATE_HELD) > > -#define lockdep_assert_held_once(l) do { \ > - WARN_ON_ONCE(debug_locks && !lockdep_is_held(l)); \ > - } while (0) > +#define lockdep_assert_held_write(l) \ > + lockdep_assert(lockdep_is_held_type(l, 0)) > > -#define lockdep_assert_none_held_once() do { \ > - WARN_ON_ONCE(debug_locks && current->lockdep_depth); \ > - } while (0) > +#define lockdep_assert_held_read(l) \ > + lockdep_assert(lockdep_is_held_type(l, 1)) > + > +#define lockdep_assert_held_once(l) \ > + lockdep_assert_once(lockdep_is_held(l) != LOCK_STATE_NOT_HELD) > + > +#define lockdep_assert_none_held_once() \ > + lockdep_assert_once(!current->lockdep_depth) > > #define lockdep_recursing(tsk) ((tsk)->lockdep_recursion) > > @@ -407,6 +405,9 @@ extern int lock_is_held(const void *); > extern int lockdep_is_held(const void *); > #define lockdep_is_held_type(l, r) (1) > > +#define lockdep_assert(c) do { } while (0) > +#define lockdep_assert_once(c) do { } while (0) > + > #define lockdep_assert_held(l) do { (void)(l); } while (0) > #define lockdep_assert_not_held(l) do { (void)(l); } while (0) > #define lockdep_assert_held_write(l) do { (void)(l); } while (0) All other macros seem to do (void)(c); in this case? Otherwise looks good.