Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1211456iog; Thu, 30 Jun 2022 20:23:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t2DpMM0mGy4idXI/iwcPVk4O3+TwLzNcKpPGrFulp9kU/myGPkf6Dx4p/QkYSy4He5NCkN X-Received: by 2002:a05:6402:5409:b0:42a:a643:4eb8 with SMTP id ev9-20020a056402540900b0042aa6434eb8mr15825697edb.71.1656645828228; Thu, 30 Jun 2022 20:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656645828; cv=none; d=google.com; s=arc-20160816; b=nTLWvjcYJvaaw2RxF/NzOKJEiwgJUVDvx0QY3exUxW3JcPPHAvmtiC9DdgP09YxKjX sQLBG8v+fLiCCBH4nZwFYWIxhkdQVqLAM2hcNiTEsV2i07aDdeacsDLi+apExQRn1gpg wo8RdMoAr+tfc6JJc0/F4cJFHLedloPzUQC0GeE2wiY3Sre6kk3YaUWekPJBlrDgGlOf HVnsbxSuwc1GVRGGiCA1TWJB3vONBXJCMFpR6S9PCZR8OwT2dCly1y0xH34AeJ7ODllK VPw9LyBFIt85FF0Pjp6m8c2yjQoKB4agWkVIZ8SfLsEkyXAfh57xIG3HnJH7pWFKZ9Hu xReg== 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=oWfevGq1blZht0/AHr52LyJ7EO7IbNkYh1P++F30/TI=; b=po8zRilh+WCLHzmPiNlOt3lRH/Vpu9MR8De1iLarU0XymjTtG7H6ktKVnkeuCiz7VN WuesdjjkZn+uvDhA3by6rd7h6TrjNFMEq8l0vVz9nGrceZc1n9b+Arl+4nnmPiXoq2e6 C4bx8KDq3+R5nlNZDp45tGCij7HWwmDLpE49SDxGXlnz+YKfoO1LngpBF+y2y+ouTp+g ep4haY07h9cnJH0TGieJhwHrfbwnG5yFKjxqp7JX9lBbW74P46S6NKBjaN9Hs+ZF+20I FdLJmbC78GD5ORApORJFZZGSevLjEAhuSexfqxvmXqe6BEsDO7VCEZuS2VzxGPPggRUs iOcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="E/v0rQhS"; 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 gt35-20020a1709072da300b00726b031a475si16974373ejc.758.2022.06.30.20.23.22; Thu, 30 Jun 2022 20:23:48 -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=@intel.com header.s=Intel header.b="E/v0rQhS"; 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 S233006AbiGACog (ORCPT + 99 others); Thu, 30 Jun 2022 22:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232303AbiGACoe (ORCPT ); Thu, 30 Jun 2022 22:44:34 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D9961D6A; Thu, 30 Jun 2022 19:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656643473; x=1688179473; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BjgkEyb8DVDy7CizbBh3O5uttPdIgmm+44rcF2fwhuM=; b=E/v0rQhSjdx6FLYVkBOP/UV6d9fkdFEZfeSKhFfPCo0ok0egc5vISdyU mbrqg1Mrm0CuaqNAWJqFmDXrp8FK0yBVMVu2AIxXm/BpknkpdL17SFBzH 6owtTN++izIGSiKnZYQcBLAnJdo3eQjRU4a/26fYIs1dOHzx86su5dypM EOMZKtFIzyfucwonHyW/36+hBBriXjvNSJ9mxyag94W7R27YIBa8da9kb WDRxYaMxn6eVcn4nve7QuhrNu7sxZleXiKnYmH1uwD+rKYrRjNF/bOLPt xBFBokilUZun6TB9mGfuSOgUhI8MpIfV82eYA0oYaLw6KMDi3JyoRbU7T A==; X-IronPort-AV: E=McAfee;i="6400,9594,10394"; a="283633709" X-IronPort-AV: E=Sophos;i="5.92,236,1650956400"; d="scan'208";a="283633709" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2022 19:44:32 -0700 X-IronPort-AV: E=Sophos;i="5.92,236,1650956400"; d="scan'208";a="648156130" Received: from zq-optiplex-7090.bj.intel.com ([10.238.156.125]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2022 19:44:30 -0700 From: Zqiang To: paulmck@kernel.org, frederic@kernel.org, quic_neeraju@quicinc.com Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] rcu: Make tiny RCU support leak callbacks for debug-object errors Date: Fri, 1 Jul 2022 10:44:04 +0800 Message-Id: <20220701024404.2228367-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=-4.8 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_NONE,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 Currently, only tree RCU support leak callbacks setting when do duplicate call_rcu(). this commit add leak callbacks setting when fo duplicate call_rcu() for tiny RCU. Signed-off-by: Zqiang --- v1->v2: for do duplicate kvfree_call_rcu(), not set leak callbacks. kernel/rcu/tiny.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c index f0561ee16b9c..943d431b908f 100644 --- a/kernel/rcu/tiny.c +++ b/kernel/rcu/tiny.c @@ -158,6 +158,10 @@ void synchronize_rcu(void) } EXPORT_SYMBOL_GPL(synchronize_rcu); +static void tiny_rcu_leak_callback(struct rcu_head *rhp) +{ +} + /* * Post an RCU callback to be invoked after the end of an RCU grace * period. But since we have but one CPU, that would be after any @@ -165,9 +169,20 @@ EXPORT_SYMBOL_GPL(synchronize_rcu); */ void call_rcu(struct rcu_head *head, rcu_callback_t func) { + static atomic_t doublefrees; unsigned long flags; - debug_rcu_head_queue(head); + if (debug_rcu_head_queue(head)) { + if (atomic_inc_return(&doublefrees) < 4) { + pr_err("%s(): Double-freed CB %p->%pS()!!! ", __func__, head, head->func); + mem_dump_obj(head); + } + + if (!__is_kvfree_rcu_offset((unsigned long)head->func)) + WRITE_ONCE(head->func, tiny_rcu_leak_callback); + return; + } + head->func = func; head->next = NULL; -- 2.25.1