From patchwork Wed Nov 9 07:36:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zqiang X-Patchwork-Id: 17371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp198426wru; Tue, 8 Nov 2022 23:35:53 -0800 (PST) X-Google-Smtp-Source: AMsMyM4/qnGpqV8d2S9Y1hL2zScRS7ddWPeglOeWIsa9Inx/DDYtRkQegBQO82Z9rzD/1DU9442E X-Received: by 2002:a17:902:ec92:b0:186:de89:7f67 with SMTP id x18-20020a170902ec9200b00186de897f67mr61473317plg.166.1667979353530; Tue, 08 Nov 2022 23:35:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667979353; cv=none; d=google.com; s=arc-20160816; b=X9UwJAiVq5k/WBSp9/uWDuIcv/x0O7i5SEW2P1+peKlEKU8Br2x7YaJaRUzYfo4u7O OXG+Dy592IILUlGBFGK/kgCyOXiAVdyitrkM83m21gbGrHgKsqmAzJnXfAtLl6xcgrXf p6E1mlV4OS9fu8M9ungcx08XZxMtIRJfTJiFL3k63xnUazKqzdhjmigII0CmAz8sxWHb zxdx9MiQC2vXG2VxZnV9wQvw0PiM8Z9Hky4+Sgdp/ecLa+cMnI9cJa1RSTtRO9kNsBJS fpc0rMmlmU5fS/jODNgJF4JWeEYTm99sLJWz9AivBqdVwciDQoa5MoFswT8Ed2qimcVp IEXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=gaXVuZvVjasY8Ide5IlgkBP6rIzudZeKBRPWr1h5Qrs=; b=J35LW2OsdODjLoy5+gaBSaywNz5Wiw2D2s9Uwuhq/JpwJzlsuaZw78jLxrTeN0RrPq Ia1xzBQQeu9UXqth95wgXKSykI1eHyb1c6Grmpty6ABYFo7gbCuva+LMTXgqdBFAClFO 5a/5P2CJa/+7LHqOZejN8/muBJ+EarxQlj9PcSe2RpZ7ESQWKTPBQejZPUTGYGHEXetF gkL/ZaC7e9Lph5tSc7FjROdDJfe7L81C7LODWsVeCHcFPyZXcVK16yqDDhrWqmhIeaki I1pzksW4eWY9lkP9BmtLmrmfQ2ucbmBdavkpVPsfgJaK2+65OzoStZGBCHQi9IZUv8Ge Lp/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Wp/6K3ni"; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a63790e000000b0046eecbac482si17432845pgc.415.2022.11.08.23.35.39; Tue, 08 Nov 2022 23:35:53 -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=@intel.com header.s=Intel header.b="Wp/6K3ni"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbiKIHa5 (ORCPT + 99 others); Wed, 9 Nov 2022 02:30:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbiKIHap (ORCPT ); Wed, 9 Nov 2022 02:30:45 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54CC1193D8; Tue, 8 Nov 2022 23:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667979038; x=1699515038; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PMzlzdz0ybzMH3t3AqOhxfPPE3vzhr6WZmccqfoaki8=; b=Wp/6K3ni/Q6hVN0lWj8Nlc1COWXhRmS3uGLjP2jsB9xTye5/z/ncfgcO 8h9xvemQG+BJdJyytBUsL7SPwZLVc/DvqMZ+dZtXaBFzv7PFK1z41vR4u vS9r6Tc78HWKsNJvhYaicumEDuk8haVRLpg6QIyE1YqEx2xGtP7Fk7FZI ZbD7TRX1zemKjF2LriIncnAvUvlhBIerrHB6xrYJc6tsj7Mb6kRwz5kPJ TVDvvQeuZM1UxskyO7T97jSOXIFBrzrCF1jj/rSm9EoiQfPsDQPlF3zbM G8o/SObGg2pBev6QCKNBGD+v73d3loOvqbAnRq1FT/X6nQtoGchjodVkR g==; X-IronPort-AV: E=McAfee;i="6500,9779,10525"; a="337642947" X-IronPort-AV: E=Sophos;i="5.96,149,1665471600"; d="scan'208";a="337642947" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2022 23:30:38 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10525"; a="881827031" X-IronPort-AV: E=Sophos;i="5.96,149,1665471600"; d="scan'208";a="881827031" Received: from zq-optiplex-7090.bj.intel.com ([10.238.156.129]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2022 23:30:36 -0800 From: Zqiang To: paulmck@kernel.org, frederic@kernel.org, joel@joelfernandes.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] srcu: Make Tiny SRCU synchronize_srcu() more complete Date: Wed, 9 Nov 2022 15:36:38 +0800 Message-Id: <20221109073638.935473-1-qiang1.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749003118671963619?= X-GMAIL-MSGID: =?utf-8?q?1749003118671963619?= This commit add lockdep detection for illegal use synchronize_srcu() in same-type SRCU (or in RCU) read-side critical section and support early boot operations. Signed-off-by: Zqiang --- kernel/rcu/srcutiny.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c index 33adafdad261..b12fb0cec44d 100644 --- a/kernel/rcu/srcutiny.c +++ b/kernel/rcu/srcutiny.c @@ -197,6 +197,16 @@ void synchronize_srcu(struct srcu_struct *ssp) { struct rcu_synchronize rs; + RCU_LOCKDEP_WARN(lockdep_is_held(ssp) || + lock_is_held(&rcu_bh_lock_map) || + lock_is_held(&rcu_lock_map) || + lock_is_held(&rcu_sched_lock_map), + "Illegal synchronize_srcu() in same-type SRCU (or in RCU) read-side critical section"); + + if (rcu_scheduler_active == RCU_SCHEDULER_INACTIVE) + return; + + might_sleep(); init_rcu_head_on_stack(&rs.head); init_completion(&rs.completion); call_srcu(ssp, &rs.head, wakeme_after_rcu);