Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3925621rwb; Mon, 16 Jan 2023 15:20:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXsutOszQLHFdDMrK45eMTcfhCAJxRLSfX+bKA/M4R7YHWGTcxOLOYN5nsvdAE38NTEYjhbl X-Received: by 2002:a17:907:c24b:b0:85c:f3cd:66f3 with SMTP id tj11-20020a170907c24b00b0085cf3cd66f3mr746832ejc.9.1673911239621; Mon, 16 Jan 2023 15:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673911239; cv=none; d=google.com; s=arc-20160816; b=yqg5YXtluInC7nwBsQpM53MNSRXw0jfORQU3eyXDXjbIfKghDJ1UF0jBBYiXRWDbDn uV346DesqQDAMW1S5D6L87bm3EGqen+1evzcVcTL+S2SrQT2PD59Fh9bJPmuKW/n4oOr vH8GQ/GncpW36rFsCBdsgqNL6hWS34xZwv57pp9WI5mtuw8vxTfaGbyrGaL+7pfL9k32 MGR4yejHcNffbsUTDSIT+oYnuyQMUKHsh1dalrAjjpNhltImvBlgp1rKli0v/gHEtd2y eUGGLcz4/n6+JR35aK9lmI2DDchd7pFGMUnm0aFAjKa+grdrwrdVnTludUa2iD3D9kiX iNDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=pKW7zCBLEA66mVcb3Cu7SCLLHnEA4pbfURAi0ynqeO8=; b=zqPXU3qD0K9N5mSSXAmCAs7/lpxHzeIGqIwlFGtzdndB2p3PVMv6GLzIPohhsTzI2J 3poWYMrk6ABNzD45+c+KLEb2CizznHnAt9Y5b/+IHa9yFFzsAFPG2Xi5YOjpuLvLZ0pf 2beeohW/zDpCjStBPsfPolN/gjZMazCtX8o0mnmnVDofU654BN3DR/3iFXXjz08aWJay 9XpPnFnGU1WYYDAZkA0N33Jytzkmnq2T31dfHoa3/G1DwTox222aPvm4BMbQYdkjmreV RPG3Ddq9yUY5i9iZHpRJQWgisJjSno3ACuzP/pheTl6wS+XQMJWxK3P8CEhr6WPgG77D fRXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eICz3Q0k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb21-20020a1709077e9500b008726f97fb32si881591ejc.363.2023.01.16.15.20.27; Mon, 16 Jan 2023 15:20:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eICz3Q0k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234913AbjAPWCB (ORCPT + 50 others); Mon, 16 Jan 2023 17:02:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233225AbjAPWB4 (ORCPT ); Mon, 16 Jan 2023 17:01:56 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52BE625E03 for ; Mon, 16 Jan 2023 14:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673906468; 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=pKW7zCBLEA66mVcb3Cu7SCLLHnEA4pbfURAi0ynqeO8=; b=eICz3Q0k+9JeniZ0aFLPWJYVZUbtlOrtLCVHdaOz+/W+N0MLn/zgJwXEeXIdqDAGplwLv1 ebt/dJ4VT0apowHCPiaywOq2nAY29VTviu7HT35zgW9fZVq8l8zm/NfUeS8wEz65wQd7dy 3p0dGGHOslWiVh9ARVdoPe7ZVZ1+e48= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-493-VktBD6VkPFe1XvOqPSP0-A-1; Mon, 16 Jan 2023 17:01:04 -0500 X-MC-Unique: VktBD6VkPFe1XvOqPSP0-A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28AAE85CCEF; Mon, 16 Jan 2023 22:01:03 +0000 (UTC) Received: from [10.22.18.0] (unknown [10.22.18.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A8192166B26; Mon, 16 Jan 2023 22:01:02 +0000 (UTC) Message-ID: Date: Mon, 16 Jan 2023 17:01:02 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH 2/3] rcu: Equip sleepable RCU with lockdep dependency graph checks Content-Language: en-US To: Boqun Feng , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, kvm@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Lai Jiangshan , "Paul E. McKenney" , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , David Woodhouse , Paolo Bonzini , seanjc@google.com, Joel Fernandes , Matthew Wilcox , Michal Luczaj References: <20230113065955.815667-1-boqun.feng@gmail.com> <20230113065955.815667-3-boqun.feng@gmail.com> From: Waiman Long In-Reply-To: <20230113065955.815667-3-boqun.feng@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/13/23 01:59, Boqun Feng wrote: > Although all flavors of RCU are annotated correctly with lockdep as > recursive read locks, their 'check' parameter of lock_acquire() is > unset. It means that RCU read locks are not added into the lockdep > dependency graph therefore deadlock detection based on dependency graph > won't catch deadlock caused by RCU. This is fine for "non-sleepable" RCU > flavors since wait-context detection and other context based detection > can catch these deadlocks. However for sleepable RCU, this is limited. > > Actually we can detect the deadlocks caused by SRCU by 1) making > srcu_read_lock() a 'check'ed recursive read lock and 2) making > synchronize_srcu() a empty write lock critical section. Even better, > with the newly introduced lock_sync(), we can avoid false positives > about irq-unsafe/safe. So do it. > > Note that NMI safe SRCU read side critical sections are currently not > annonated, since step-by-step approach can help us deal with > false-positives. These may be annotated in the future. > > Signed-off-by: Boqun Feng > --- > include/linux/srcu.h | 23 +++++++++++++++++++++-- > kernel/rcu/srcutiny.c | 2 ++ > kernel/rcu/srcutree.c | 2 ++ > 3 files changed, 25 insertions(+), 2 deletions(-) > > diff --git a/include/linux/srcu.h b/include/linux/srcu.h > index 9b9d0bbf1d3c..a1595f8c5155 100644 > --- a/include/linux/srcu.h > +++ b/include/linux/srcu.h > @@ -102,6 +102,21 @@ static inline int srcu_read_lock_held(const struct srcu_struct *ssp) > return lock_is_held(&ssp->dep_map); > } > > +static inline void srcu_lock_acquire(struct lockdep_map *map) > +{ > + lock_map_acquire_read(map); > +} > + > +static inline void srcu_lock_release(struct lockdep_map *map) > +{ > + lock_map_release(map); > +} > + > +static inline void srcu_lock_sync(struct lockdep_map *map) > +{ > + lock_map_sync(map); > +} > + > #else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ It would be nice if a comment is added to document the difference between the 2 sets of rcu_lock_* and srcu_lock_* functions. It is described in patch description, but it is not easy to figure that out just by looking at the source files. Cheers, Longman