Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5953167rwl; Wed, 22 Mar 2023 04:46:13 -0700 (PDT) X-Google-Smtp-Source: AK7set+fegwQuv1E5znDNDgY4I2TLabovo1Iv6VrQcxEC6Khg9YQLCkY1p8U7tyYCFqruedtR6YT X-Received: by 2002:a17:90a:3:b0:237:b64c:6bb3 with SMTP id 3-20020a17090a000300b00237b64c6bb3mr3693054pja.11.1679485573523; Wed, 22 Mar 2023 04:46:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679485573; cv=none; d=google.com; s=arc-20160816; b=mSeiHZu8bO0I+7huKh9Kb2Y1IwN5jh8KLYn06rW75989w10WZ1OCWCtI+8Uv1FKRR/ 5JYAYwU0/E16bwYNB1NWP/PNR41n4Gf3QfeyNqI+jlCmhArzp5/BEnJZ2fDd1dQlyyiN Tv0QRiANaysvzZ4cbWSdhSSO6e96Dt7dvr0GV7Hk2t3DFf9seglfZxxaEjhu731WzMpi aWtD4s+DpIJIGqTyJmDIKgDmEfAv8zoO0j4qqNRK9CaHKYoWvdLPf6ioEYzUEym5yTgB JVWwbCejpYXZ4KY39uLAabOIBKxoGy+E7UNYswA9HRzYPxatTJOc3l7f/0Q0sqYJlH7T 5L3w== 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=MpkCpD7JfOEECVj5luAZYR3dXujyZ/NrHmev+Mad9Xw=; b=l8b43tVJkbMBipSvNhWpXVcPLGpbCQ2/BDYK+2G23lcdMNDW58Qpnpnu1xVxH/HV7d VLnzc2zvr9tJDSRLOspgaraZizNFAkth1797c7MW8/LIHRjpKw6gTdq3mDoGtmeDNfPy glXtc/yD66BpfvCa1qFqBVo0d3EACFyV71gg1SqeOd1SCKfdioqu7joc16Pc3VMu6UZ6 LkJEVYj26SQpGL1m6FHSSPoyi0FbbQBZVH/aF2szfW+EBlWIpKuCiAuHO/To2jClbSQG 9jWPeXL8zkjOLssuXOwelCxPbVH9hN9SHS5HDQHX6EGJA47sKUU2sq4wCNR00+VhXMNo NoxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JTHvqAGZ; 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 mq8-20020a17090b380800b0023a6ea894a0si19099251pjb.88.2023.03.22.04.45.51; Wed, 22 Mar 2023 04:46:13 -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=JTHvqAGZ; 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 S229922AbjCVLnp (ORCPT + 99 others); Wed, 22 Mar 2023 07:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbjCVLnj (ORCPT ); Wed, 22 Mar 2023 07:43:39 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B10651C7E7; Wed, 22 Mar 2023 04:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679485410; x=1711021410; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=l/W/OP4xOvbuhb1dmkS29exhzLjwY175O3nDeJBAAsw=; b=JTHvqAGZbKrtsf/1Es1ZoSRdVtYIU9OlfAUG1R1dGC9f/pTj0F312ELb 6eZ23sSby4KuD3qDSlIS+9FFXDZQm4Whg1vpIimGZkrz49VGCHzFELZ5I 6nsgGEIhxSdY+uvrQN+PdHmYGuKZ0+05G3sWvWrB+owxsS3rhp4OaOfuM Ib9mzIFb38burOF38YKLDbwc0y39ImyShP/ejxEEE97W1H30I7oX1tTsT UL0ttI0VTL0a+PyI+RNYXX/ebB0djpUsQkqt2xE1YglL+eArFJHSbn+z1 aZGhccZ2A9RzMLaTpEr3FnKWY0vBA04ae2/8TtFWr2ttCZi6ZAwnQ4sx2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="327570457" X-IronPort-AV: E=Sophos;i="5.98,281,1673942400"; d="scan'208";a="327570457" 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:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="746261284" X-IronPort-AV: E=Sophos;i="5.98,281,1673942400"; d="scan'208";a="746261284" 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:27 -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 1/2] rcu/rcuscale: Move rcu_scale_*() after kfree_scale_cleanup() Date: Wed, 22 Mar 2023 19:42:40 +0800 Message-Id: <20230322114241.88118-2-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 Move rcu_scale_cleanup() and rcu_scale_shutdown() functions after kfree_scale_cleanup(). There are no function changes. The intention of this moving is a preparation for a subsequent patch that will fix a call-trace bug by invoking kfree_scale_cleanup() from rcu_scale_cleanup() without the declaration of kfree_scale_cleanup(). Signed-off-by: Qiuxu Zhuo --- kernel/rcu/rcuscale.c | 194 +++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c index e82ec9f9a5d8..7e8965b0827a 100644 --- a/kernel/rcu/rcuscale.c +++ b/kernel/rcu/rcuscale.c @@ -522,89 +522,6 @@ rcu_scale_print_module_parms(struct rcu_scale_ops *cur_ops, const char *tag) scale_type, tag, nrealreaders, nrealwriters, verbose, shutdown); } -static void -rcu_scale_cleanup(void) -{ - int i; - int j; - int ngps = 0; - u64 *wdp; - u64 *wdpp; - - /* - * Would like warning at start, but everything is expedited - * during the mid-boot phase, so have to wait till the end. - */ - if (rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp) - SCALEOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!"); - if (rcu_gp_is_normal() && gp_exp) - SCALEOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!"); - if (gp_exp && gp_async) - SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!"); - - if (torture_cleanup_begin()) - return; - if (!cur_ops) { - torture_cleanup_end(); - return; - } - - if (reader_tasks) { - for (i = 0; i < nrealreaders; i++) - torture_stop_kthread(rcu_scale_reader, - reader_tasks[i]); - kfree(reader_tasks); - } - - if (writer_tasks) { - for (i = 0; i < nrealwriters; i++) { - torture_stop_kthread(rcu_scale_writer, - writer_tasks[i]); - if (!writer_n_durations) - continue; - j = writer_n_durations[i]; - pr_alert("%s%s writer %d gps: %d\n", - scale_type, SCALE_FLAG, i, j); - ngps += j; - } - pr_alert("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n", - scale_type, SCALE_FLAG, - t_rcu_scale_writer_started, t_rcu_scale_writer_finished, - t_rcu_scale_writer_finished - - t_rcu_scale_writer_started, - ngps, - rcuscale_seq_diff(b_rcu_gp_test_finished, - b_rcu_gp_test_started)); - for (i = 0; i < nrealwriters; i++) { - if (!writer_durations) - break; - if (!writer_n_durations) - continue; - wdpp = writer_durations[i]; - if (!wdpp) - continue; - for (j = 0; j < writer_n_durations[i]; j++) { - wdp = &wdpp[j]; - pr_alert("%s%s %4d writer-duration: %5d %llu\n", - scale_type, SCALE_FLAG, - i, j, *wdp); - if (j % 100 == 0) - schedule_timeout_uninterruptible(1); - } - kfree(writer_durations[i]); - } - kfree(writer_tasks); - kfree(writer_durations); - kfree(writer_n_durations); - } - - /* Do torture-type-specific cleanup operations. */ - if (cur_ops->cleanup != NULL) - cur_ops->cleanup(); - - torture_cleanup_end(); -} - /* * Return the number if non-negative. If -1, the number of CPUs. * If less than -1, that much less than the number of CPUs, but @@ -624,20 +541,6 @@ static int compute_real(int n) return nr; } -/* - * RCU scalability shutdown kthread. Just waits to be awakened, then shuts - * down system. - */ -static int -rcu_scale_shutdown(void *arg) -{ - wait_event_idle(shutdown_wq, atomic_read(&n_rcu_scale_writer_finished) >= nrealwriters); - smp_mb(); /* Wake before output. */ - rcu_scale_cleanup(); - kernel_power_off(); - return -EINVAL; -} - /* * kfree_rcu() scalability tests: Start a kfree_rcu() loop on all CPUs for number * of iterations and measure total time and number of GP for all iterations to complete. @@ -874,6 +777,103 @@ kfree_scale_init(void) return firsterr; } +static void +rcu_scale_cleanup(void) +{ + int i; + int j; + int ngps = 0; + u64 *wdp; + u64 *wdpp; + + /* + * Would like warning at start, but everything is expedited + * during the mid-boot phase, so have to wait till the end. + */ + if (rcu_gp_is_expedited() && !rcu_gp_is_normal() && !gp_exp) + SCALEOUT_ERRSTRING("All grace periods expedited, no normal ones to measure!"); + if (rcu_gp_is_normal() && gp_exp) + SCALEOUT_ERRSTRING("All grace periods normal, no expedited ones to measure!"); + if (gp_exp && gp_async) + SCALEOUT_ERRSTRING("No expedited async GPs, so went with async!"); + + if (torture_cleanup_begin()) + return; + if (!cur_ops) { + torture_cleanup_end(); + return; + } + + if (reader_tasks) { + for (i = 0; i < nrealreaders; i++) + torture_stop_kthread(rcu_scale_reader, + reader_tasks[i]); + kfree(reader_tasks); + } + + if (writer_tasks) { + for (i = 0; i < nrealwriters; i++) { + torture_stop_kthread(rcu_scale_writer, + writer_tasks[i]); + if (!writer_n_durations) + continue; + j = writer_n_durations[i]; + pr_alert("%s%s writer %d gps: %d\n", + scale_type, SCALE_FLAG, i, j); + ngps += j; + } + pr_alert("%s%s start: %llu end: %llu duration: %llu gps: %d batches: %ld\n", + scale_type, SCALE_FLAG, + t_rcu_scale_writer_started, t_rcu_scale_writer_finished, + t_rcu_scale_writer_finished - + t_rcu_scale_writer_started, + ngps, + rcuscale_seq_diff(b_rcu_gp_test_finished, + b_rcu_gp_test_started)); + for (i = 0; i < nrealwriters; i++) { + if (!writer_durations) + break; + if (!writer_n_durations) + continue; + wdpp = writer_durations[i]; + if (!wdpp) + continue; + for (j = 0; j < writer_n_durations[i]; j++) { + wdp = &wdpp[j]; + pr_alert("%s%s %4d writer-duration: %5d %llu\n", + scale_type, SCALE_FLAG, + i, j, *wdp); + if (j % 100 == 0) + schedule_timeout_uninterruptible(1); + } + kfree(writer_durations[i]); + } + kfree(writer_tasks); + kfree(writer_durations); + kfree(writer_n_durations); + } + + /* Do torture-type-specific cleanup operations. */ + if (cur_ops->cleanup != NULL) + cur_ops->cleanup(); + + torture_cleanup_end(); +} + +/* + * RCU scalability shutdown kthread. Just waits to be awakened, then shuts + * down system. + */ +static int +rcu_scale_shutdown(void *arg) +{ + wait_event_idle(shutdown_wq, atomic_read(&n_rcu_scale_writer_finished) >= nrealwriters); + smp_mb(); /* Wake before output. */ + rcu_scale_cleanup(); + kernel_power_off(); + return -EINVAL; +} + static int __init rcu_scale_init(void) { -- 2.17.1