Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp190547rwb; Wed, 9 Nov 2022 00:43:56 -0800 (PST) X-Google-Smtp-Source: AMsMyM72hQVinhuRRAVXkXtncP/psf/8Trn/EZXG8AkVJ/fNYSL+mzGW3ng7BiHViaBpC15o+/0C X-Received: by 2002:a17:906:fe45:b0:791:9624:9ea5 with SMTP id wz5-20020a170906fe4500b0079196249ea5mr57769993ejb.282.1667983435773; Wed, 09 Nov 2022 00:43:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667983435; cv=none; d=google.com; s=arc-20160816; b=vFj3ZymmlK7LXurg5aOrZ5UJZNaVyudpnncmgTEsFnfyycq3RKsOp4mwi+ZU188L/c PTYcNe/bxLpYDurBiVQA9xeHzd/siCvbKM3335Dh/VpU2LJtCkDIEeXIoltg6Gg/vMD9 dVzfeAqYYlZXeTwmyNB2/Rg8PE9XViu0CQd2Oh9H4zDaS+8MNyMmURYKZ9as5Tbi1dhN KB/T1KzuweQlerQU4oM/y9LckwriaXKO5eWBBwIzxePEmElCp6CnPUWnz/zp2UFQWHhr uz2DqwEZ0fQy8TCYqdwS6MG1u4J2hMEmDlUQEiy3sIDv9Lq0bq5MeU99sOaBxXV5/gqE aIJw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd14-20020a1709069b8e00b007ae545e330csi15611045ejc.218.2022.11.09.00.43.33; Wed, 09 Nov 2022 00:43:55 -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 + 93 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 Content-Transfer-Encoding: 8bit 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 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); -- 2.25.1