Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp671528rwp; Wed, 12 Jul 2023 21:53:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlEY8Tz3tGTIkGSTKEjp4A/LuQfFwjP1MDMXc7sfC6IisDWvTo1QxhCa3xCN8vyVgHFTDdd6 X-Received: by 2002:a05:6a21:788d:b0:12e:3394:e2c5 with SMTP id bf13-20020a056a21788d00b0012e3394e2c5mr739918pzc.2.1689224029157; Wed, 12 Jul 2023 21:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689224029; cv=none; d=google.com; s=arc-20160816; b=iata1dleGqrKRYRWk3Dp0ZFo6uLEnCO47Hk3vuZEi+9VuMYqHR+cstcckaU/HvsIAt GTCv517s1F0GReyqCxMJ/LwyS5ROgFX+Jk14UccfbzvCxR/iKIGw3L0XLDygBE4l5pIj 2tF5YTbUzlsY1yLJs0ECYnzXr8l4J4AlvD0nXzeZD4bGXvOlXgcxCZzAov4A3ryIPoys W6rnqjomorNnPN9dvE7zWJMPb48Le2MxdLeHyrmANRKYsUBwTJWKS/wL4fVExmZoTIHi eVfymYqp+6iFCbMjP2Anh7qN4ulUlnB8sUWPaFys2JnF74CaOYyeUzoyQltUT1CpXLTf Ap8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=hGHJO2DeVN2TYkh77c6m+mrcE7tc67kZg+OOqbWNcw8=; fh=lAHuGEpyZZbk+MGyslbzNqTThhYRQ0pOf7mnQLNx3WI=; b=mM8t6pN7bjSq5Q+8A21Do4oV4gG4CTlKZTA1qlvjaP0H8pHctsNVHdYhLORk9lc+gP Zt2UxJFrtomPMzL+pwfTBf3EsDa5llQdjT34zz1D9V+4/qqwUUEqbUzbTqkzZ4Kaikec TSuaH7gGsBA5z1GRqu8857/o/+XZM02qOkM67TjQtBW/Z/Gn+p3aanjpu+RbZ5ROJVB+ 0jJxfEQdZDjGjOMKKWwMOxRwZzvY7qqy3nN6yh61JEbkBvWax0usGdaljK9tLjYJ8vq/ hC5oWQepdyV/lpYqE4nNe0O2DoqZ6QXQSB228tUhr17F1onOvjsFR/NAae/C8n4EtvqK xSzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XE+GxSa7; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a63ed15000000b00543cc95d776si373550pgi.660.2023.07.12.21.53.35; Wed, 12 Jul 2023 21:53:49 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=XE+GxSa7; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233804AbjGME2q (ORCPT + 99 others); Thu, 13 Jul 2023 00:28:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234021AbjGME2K (ORCPT ); Thu, 13 Jul 2023 00:28:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EFDD272C; Wed, 12 Jul 2023 21:27:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 161FF619F4; Thu, 13 Jul 2023 04:27:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FAF1C433C7; Thu, 13 Jul 2023 04:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689222446; bh=CVxQG65MLrWANkYPe3SdWCOKqSZqvIhIFt2IUuuAIYA=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=XE+GxSa7Aqutcx0J0aBnaewBQ5svGQdYzuAI7pmkBsNkKri87aanAfeb3IQXv9aOv umlmT0M216J0kZMy53hlN+SET1lJOnGJIUxu7YmDfKzDP74iTmu3OUStboDGYUfsge CZ7osqLzJaMM11vdd1IWyn1k11AbPdOBrtFURjx4GqyHiFWpdLD8fCF5O77Qd1WyjY 20QRekqvtWFbzBIFGZ3FChfn03QTR7fPMA+qTvQXYgFm2f0qeEAVxBMcYy/yBxZwhp JOcvl8PIl9HYj7IIPszTp0h8AWh5OiFWAH3gJQ2x02Pv39nX6b7vPmHKsMbsjQqHSl qJgzRdwmDTXcQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 02DBFCE00AB; Wed, 12 Jul 2023 21:27:25 -0700 (PDT) Date: Wed, 12 Jul 2023 21:27:25 -0700 From: "Paul E. McKenney" To: Gao Xiang Cc: Joel Fernandes , Sandeep Dhavale , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Matthias Brugger , AngeloGioacchino Del Regno , linux-erofs@lists.ozlabs.org, xiang@kernel.org, Will Shiu , kernel-team@android.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH v1] rcu: Fix and improve RCU read lock checks when !CONFIG_DEBUG_LOCK_ALLOC Message-ID: <0d9e7b4d-6477-47a6-b3d2-2c9d9b64903d@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20230711233816.2187577-1-dhavale@google.com> <20230713003201.GA469376@google.com> <161f1615-3d85-cf47-d2d5-695adf1ca7d4@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <161f1615-3d85-cf47-d2d5-695adf1ca7d4@linux.alibaba.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Thu, Jul 13, 2023 at 10:02:17AM +0800, Gao Xiang wrote: > > > On 2023/7/13 08:32, Joel Fernandes wrote: > > On Wed, Jul 12, 2023 at 02:20:56PM -0700, Sandeep Dhavale wrote: > > [..] > > > > As such this patch looks correct to me, one thing I noticed is that > > > > you can check rcu_is_watching() like the lockdep-enabled code does. > > > > That will tell you also if a reader-section is possible because in > > > > extended-quiescent-states, RCU readers should be non-existent or > > > > that's a bug. > > > > > > > Please correct me if I am wrong, reading from the comment in > > > kernel/rcu/update.c rcu_read_lock_held_common() > > > .. > > > * The reason for this is that RCU ignores CPUs that are > > > * in such a section, considering these as in extended quiescent state, > > > * so such a CPU is effectively never in an RCU read-side critical section > > > * regardless of what RCU primitives it invokes. > > > > > > It seems rcu will treat this as lock not held rather than a fact that > > > lock is not held. Is my understanding correct? > > > > If RCU treats it as a lock not held, that is a fact for RCU ;-). Maybe you > > mean it is not a fact for erofs? > > I'm not sure if I get what you mean, EROFS doesn't take any RCU read lock > here: The key point is that we need lockdep to report errors when rcu_read_lock(), rcu_dereference(), and friends are used when RCU is not watching. We also need lockdep to report an error when someone uses rcu_dereference() when RCU is not watching, but also forgets the rcu_read_lock(). And this is the job of rcu_read_lock_held(), which is one reason why that rcu_is_watching() is needed. > z_erofs_decompressqueue_endio() is actually a "bio->bi_end_io", previously > which can be called under two scenarios: > > 1) under softirq context, which is actually part of device I/O compleltion; > > 2) under threaded context, like what dm-verity or likewise calls. > > But EROFS needs to decompress in a threaded context anyway, so we trigger > a workqueue to resolve the case 1). > > Recently, someone reported there could be some case 3) [I think it was > introduced recently but I have no time to dig into it]: > > case 3: under RCU read lock context, which is shown by this: > https://lore.kernel.org/r/4a8254eb-ac39-1e19-3d82-417d3a7b9f94@linux.alibaba.com/T/#u > > and such RCU read lock is taken in __blk_mq_run_dispatch_ops(). > > But as the commit shown, we only need to trigger a workqueue for case 1) > and 3) due to performance reasons. Just out of curiosity, exactly how much is it costing to trigger the workqueue? > Hopefully I show it more clear. One additional question... What is your plan for kernels built with CONFIG_PREEMPT_COUNT=n? After all, in such kernels, there is no way that I know of for code to determine whether it is in an RCU read-side critical section, holding a spinlock, or running with preemption disabled. Thanx, Paul