Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5952943rwl; Wed, 22 Mar 2023 04:46:01 -0700 (PDT) X-Google-Smtp-Source: AK7set8jZX/lfUvdL0FG/5BHJwlBkYsGu7EOcft5cwTJsTf8r9GqGJL3nwUUiQhhRvp0p3BreMw1 X-Received: by 2002:a05:6a20:bf20:b0:d8:f082:437e with SMTP id gc32-20020a056a20bf2000b000d8f082437emr5653416pzb.12.1679485560888; Wed, 22 Mar 2023 04:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679485560; cv=none; d=google.com; s=arc-20160816; b=s0M2cFTNDFig8G1TKJRsEMkvPJWei7MjvtRW+bLPU+wDUAqCNaKEHO+uKUhvh3s/FX 7ann3kTUJx0BEE5WeOngmmHH5ltbBsGZ87HO0iG4ufDm1ywe8c4SlrOHwQXWZ5CBqUnX OsPCoH/1mM+Z63hgPGzpAID3/Gg4cQqbQ8vtCR+pt4/A7rtx6LHMOQy8Ifh5tqgCAa8e Mk/pRgE+wivGVD5ZzTdbC2o8bw0dT2pOWH/OfiURbWmIcECNM4+bBopOIc5yiEBzAWpH xIl4m2fHQ6stTsxeinuxMfrc9kfB6ywgxmtdYeOS8oyg0AnLqtHUWevEoLjhQ/R8L76J xaLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=uNPFY3lOgfy+h+FkxNyiMUOMTBRdaqai4BBDcn+XXDY=; b=Sit5kkPkVPU2nrkjTmhj5f96pstjKA9TikNbzqKBgQxUtGsin2nHCZ3cKlTI1XoL4p AyBEm8ZbUW8jIDiDB5o/mBNwnkBwoCXfD1PvSyHgSE/EwopcPrPcmNgJA6S4xxm3oQWX WfVLfkie1pYyGVBUetTs2E2e4ShPGsGVU23BOKMYPuKCsZlOIGRzrP4Zsuhpe03ELbzi SQI7qrD5FIeucPZUyyQsJonOlUjqVVFMssjGS5yqTxOKy6/qtvDUjEmTwGig82piYwdE UmUF217Vm/krsu2OHLi5HDZnOuNbI10iDBt09NgeS3NTxmv3vACopGq7EcGG44C6zt9p 7A1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q2fRkiHr; 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 u11-20020a63d34b000000b00507681e1281si15892106pgi.525.2023.03.22.04.45.49; Wed, 22 Mar 2023 04:46:00 -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=Q2fRkiHr; 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 S230000AbjCVLnm (ORCPT + 99 others); Wed, 22 Mar 2023 07:43:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229992AbjCVLnk (ORCPT ); Wed, 22 Mar 2023 07:43:40 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33DB92366E; Wed, 22 Mar 2023 04:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679485414; x=1711021414; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LlPOp44vMbZlXXRjC/hMy2A7JKamX/O8HwHRRLj6X+0=; b=Q2fRkiHrkVi0uNfDQ3IDMXS2rWQrlpEToDchYWpmNH+56EyJh/0rARa6 XItWFIvvNh0Pc7NebYOtc5vQuaZQ2bixWI0ArQ9c4ERehELurAYdJa5By MO2C+Rjhr8N6m+U1g7Sw/4zNUDYJF+6NF9vPp+bhWxBZE/pHBKEllxaBD jPkIehMteIBkDs1wpeXb1L0NS/Z10o4TjUbIuIMQymZxOTSRJJYODkOW2 10k8xZ8mIQDennJzjcXfuNmWjhiUzXMq+8HWtHmxbnoUigO5jQQd3P2db byE3asfOejpKLQURenT+mkYKttR1j9KMMscLNFHGzPztb+0ShPD6zjOdU g==; X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="327570469" X-IronPort-AV: E=Sophos;i="5.98,281,1673942400"; d="scan'208";a="327570469" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 04:43:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="746261287" X-IronPort-AV: E=Sophos;i="5.98,281,1673942400"; d="scan'208";a="746261287" Received: from qiuxu-clx.sh.intel.com ([10.239.53.109]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 04:43:30 -0700 From: Qiuxu Zhuo To: paulmck@kernel.org Cc: dave@stgolabs.net, frederic@kernel.org, jiangshanlai@gmail.com, joel@joelfernandes.org, josh@joshtriplett.org, linux-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, qiuxu.zhuo@intel.com, quic_neeraju@quicinc.com, rcu@vger.kernel.org, rostedt@goodmis.org Subject: [PATCH v4 2/2] rcu/rcuscale: Stop kfree_scale_thread thread(s) after unloading rcuscale Date: Wed, 22 Mar 2023 19:42:41 +0800 Message-Id: <20230322114241.88118-3-qiuxu.zhuo@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230322114241.88118-1-qiuxu.zhuo@intel.com> References: <20230322114241.88118-1-qiuxu.zhuo@intel.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=unavailable 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 When running the 'kfree_rcu_test' test case with commands [1] the call trace [2] was thrown. This was because the kfree_scale_thread thread(s) still run after unloading rcuscale and torture modules. Fix the call trace by invoking kfree_scale_cleanup() from rcu_scale_cleanup() when removing the rcuscale module. [1] modprobe rcuscale kfree_rcu_test=1 // After some time rmmod rcuscale rmmod torture [2] BUG: unable to handle page fault for address: ffffffffc0601a87 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page PGD 11de4f067 P4D 11de4f067 PUD 11de51067 PMD 112f4d067 PTE 0 Oops: 0010 [#1] PREEMPT SMP NOPTI CPU: 1 PID: 1798 Comm: kfree_scale_thr Not tainted 6.3.0-rc1-rcu+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 RIP: 0010:0xffffffffc0601a87 Code: Unable to access opcode bytes at 0xffffffffc0601a5d. RSP: 0018:ffffb25bc2e57e18 EFLAGS: 00010297 RAX: 0000000000000000 RBX: ffffffffc061f0b6 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffffffff962fd0de RDI: ffffffff962fd0de RBP: ffffb25bc2e57ea8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000000 R13: 0000000000000000 R14: 000000000000000a R15: 00000000001c1dbe FS: 0000000000000000(0000) GS:ffff921fa2200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffc0601a5d CR3: 000000011de4c006 CR4: 0000000000370ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? kvfree_call_rcu+0xf0/0x3a0 ? kthread+0xf3/0x120 ? kthread_complete_and_exit+0x20/0x20 ? ret_from_fork+0x1f/0x30 Modules linked in: rfkill sunrpc ... [last unloaded: torture] CR2: ffffffffc0601a87 ---[ end trace 0000000000000000 ]--- Fixes: e6e78b004fa7 ("rcuperf: Add kfree_rcu() performance Tests") Reviewed-by: Davidlohr Bueso Reviewed-by: Joel Fernandes (Google) Signed-off-by: Qiuxu Zhuo --- kernel/rcu/rcuscale.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c index 7e8965b0827a..d1221731c7cf 100644 --- a/kernel/rcu/rcuscale.c +++ b/kernel/rcu/rcuscale.c @@ -797,6 +797,11 @@ rcu_scale_cleanup(void) if (gp_exp && gp_async) SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!"); + if (kfree_rcu_test) { + kfree_scale_cleanup(); + return; + } + if (torture_cleanup_begin()) return; if (!cur_ops) { -- 2.17.1