linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joel Fernandes <joel@joelfernandes.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
	rushikesh.s.kadam@intel.com, urezki@gmail.com,
	neeraj.iitr10@gmail.com, frederic@kernel.org,
	rostedt@goodmis.org, vineeth@bitbyteword.org
Subject: Re: [PATCH v2 6/8] rcuscale: Add test for using call_rcu_lazy() to emulate kfree_rcu()
Date: Fri, 8 Jul 2022 04:25:09 +0000	[thread overview]
Message-ID: <YsexpcG2iaplKPIs@google.com> (raw)
In-Reply-To: <20220626041327.GN1790663@paulmck-ThinkPad-P17-Gen-1>

On Sat, Jun 25, 2022 at 09:13:27PM -0700, Paul E. McKenney wrote:
> On Wed, Jun 22, 2022 at 10:51:00PM +0000, Joel Fernandes (Google) wrote:
> > Reuse the kfree_rcu() test in order to be able to compare the memory reclaiming
> > properties of call_rcu_lazy() with kfree_rcu().
> > 
> > With this test, we find similar memory footprint and time call_rcu_lazy()
> > free'ing takes compared to kfree_rcu(). Also we confirm that call_rcu_lazy()
> > can survive OOM during extremely frequent calls.
> > 
> > If we really push it, i.e. boot system with low memory and compare
> > kfree_rcu() with call_rcu_lazy(), I find that call_rcu_lazy() is more
> > resilient and is much harder to produce OOM as compared to kfree_rcu().
> 
> Another approach would be to make rcutorture's forward-progress testing
> able to use call_rcu_lazy().  This would test lazy callback flooding.
> 
> Yet another approach would be to keep one CPU idle other than a
> kthread doing call_rcu_lazy().  Of course "idle" includes redirecting
> those pesky interrupts.
> 
> It is almost certainly necessary for rcutorture to exercise the
> call_rcu_lazy() path regularly.

Currently I added a test like the following which adds a new torture type, my
thought was to stress the new code to make sure nothing crashed or hung the
kernel. That is working well except I don't exactly understand the total-gps
print showing 0, which the other print shows 1188 GPs. I'll go dig into that
tomorrow.. thanks!

The print shows
TREE11 ------- 1474 GPs (12.2833/s) [rcu_lazy: g0 f0x0 total-gps=0]
TREE11 no success message, 7 successful version messages

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 7120165a9342..cc6b7392d801 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -872,6 +872,64 @@ static struct rcu_torture_ops tasks_rude_ops = {
 
 #endif // #else #ifdef CONFIG_TASKS_RUDE_RCU
 
+#ifdef CONFIG_RCU_LAZY
+
+/*
+ * Definitions for lazy RCU torture testing.
+ */
+unsigned long orig_jiffies_till_flush;
+
+static void rcu_sync_torture_init_lazy(void)
+{
+	rcu_sync_torture_init();
+
+	orig_jiffies_till_flush = rcu_lazy_get_jiffies_till_flush();
+	rcu_lazy_set_jiffies_till_flush(50);
+}
+
+static void rcu_lazy_cleanup(void)
+{
+	rcu_lazy_set_jiffies_till_flush(orig_jiffies_till_flush);
+}
+
+static struct rcu_torture_ops rcu_lazy_ops = {
+	.ttype			= RCU_LAZY_FLAVOR,
+	.init			= rcu_sync_torture_init_lazy,
+	.cleanup		= rcu_lazy_cleanup,
+	.readlock		= rcu_torture_read_lock,
+	.read_delay		= rcu_read_delay,
+	.readunlock		= rcu_torture_read_unlock,
+	.readlock_held		= torture_readlock_not_held,
+	.get_gp_seq		= rcu_get_gp_seq,
+	.gp_diff		= rcu_seq_diff,
+	.deferred_free		= rcu_torture_deferred_free,
+	.sync			= synchronize_rcu,
+	.exp_sync		= synchronize_rcu_expedited,
+	.get_gp_state		= get_state_synchronize_rcu,
+	.start_gp_poll		= start_poll_synchronize_rcu,
+	.poll_gp_state		= poll_state_synchronize_rcu,
+	.cond_sync		= cond_synchronize_rcu,
+	.call			= call_rcu_lazy,
+	.cb_barrier		= rcu_barrier,
+	.fqs			= rcu_force_quiescent_state,
+	.stats			= NULL,
+	.gp_kthread_dbg		= show_rcu_gp_kthreads,
+	.check_boost_failed	= rcu_check_boost_fail,
+	.stall_dur		= rcu_jiffies_till_stall_check,
+	.irq_capable		= 1,
+	.can_boost		= IS_ENABLED(CONFIG_RCU_BOOST),
+	.extendables		= RCUTORTURE_MAX_EXTEND,
+	.name			= "rcu_lazy"
+};
+
+#define LAZY_OPS &rcu_lazy_ops,
+
+#else // #ifdef CONFIG_RCU_LAZY
+
+#define LAZY_OPS
+
+#endif // #else #ifdef CONFIG_RCU_LAZY
+
 
 #ifdef CONFIG_TASKS_TRACE_RCU
 
@@ -3145,7 +3203,7 @@ rcu_torture_init(void)
 	unsigned long gp_seq = 0;
 	static struct rcu_torture_ops *torture_ops[] = {
 		&rcu_ops, &rcu_busted_ops, &srcu_ops, &srcud_ops, &busted_srcud_ops,
-		TASKS_OPS TASKS_RUDE_OPS TASKS_TRACING_OPS
+		TASKS_OPS TASKS_RUDE_OPS TASKS_TRACING_OPS LAZY_OPS
 		&trivial_ops,
 	};
 
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TREE11 b/tools/testing/selftests/rcutorture/configs/rcu/TREE11
new file mode 100644
index 000000000000..436013f3e015
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/rcu/TREE11
@@ -0,0 +1,18 @@
+CONFIG_SMP=y
+CONFIG_PREEMPT_NONE=n
+CONFIG_PREEMPT_VOLUNTARY=n
+CONFIG_PREEMPT=y
+#CHECK#CONFIG_PREEMPT_RCU=y
+CONFIG_HZ_PERIODIC=n
+CONFIG_NO_HZ_IDLE=y
+CONFIG_NO_HZ_FULL=n
+CONFIG_RCU_TRACE=y
+CONFIG_HOTPLUG_CPU=y
+CONFIG_MAXSMP=y
+CONFIG_CPUMASK_OFFSTACK=y
+CONFIG_RCU_NOCB_CPU=y
+CONFIG_DEBUG_LOCK_ALLOC=n
+CONFIG_RCU_BOOST=n
+CONFIG_DEBUG_OBJECTS_RCU_HEAD=n
+CONFIG_RCU_EXPERT=y
+CONFIG_RCU_LAZY=y
diff --git a/tools/testing/selftests/rcutorture/configs/rcu/TREE11.boot b/tools/testing/selftests/rcutorture/configs/rcu/TREE11.boot
new file mode 100644
index 000000000000..9b6f720d4ccd
--- /dev/null
+++ b/tools/testing/selftests/rcutorture/configs/rcu/TREE11.boot
@@ -0,0 +1,8 @@
+maxcpus=8 nr_cpus=43
+rcutree.gp_preinit_delay=3
+rcutree.gp_init_delay=3
+rcutree.gp_cleanup_delay=3
+rcu_nocbs=0-7
+rcutorture.torture_type=rcu_lazy
+rcutorture.nocbs_nthreads=8
+rcutorture.fwd_progress=0
-- 
2.37.0.rc0.161.g10f37bed90-goog


  reply	other threads:[~2022-07-08  4:25 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22 22:50 [PATCH v2 0/8] Implement call_rcu_lazy() and miscellaneous fixes Joel Fernandes (Google)
2022-06-22 22:50 ` [PATCH v2 1/1] context_tracking: Use arch_atomic_read() in __ct_state for KASAN Joel Fernandes (Google)
2022-06-22 22:58   ` Joel Fernandes
2022-06-22 22:50 ` [PATCH v2 1/8] rcu: Introduce call_rcu_lazy() API implementation Joel Fernandes (Google)
2022-06-22 23:18   ` Joel Fernandes
2022-06-26  4:00     ` Paul E. McKenney
2022-06-23  1:38   ` kernel test robot
2022-06-26  4:00   ` Paul E. McKenney
2022-07-08 18:43     ` Joel Fernandes
2022-07-08 23:10       ` Paul E. McKenney
2022-07-10  2:26     ` Joel Fernandes
2022-07-10 16:03       ` Paul E. McKenney
2022-07-12 20:53         ` Joel Fernandes
2022-07-12 21:04           ` Paul E. McKenney
2022-07-12 21:10             ` Joel Fernandes
2022-07-12 22:41               ` Paul E. McKenney
2022-06-29 11:53   ` Frederic Weisbecker
2022-06-29 17:05     ` Paul E. McKenney
2022-06-29 20:29     ` Joel Fernandes
2022-06-29 22:01       ` Frederic Weisbecker
2022-06-30 14:08         ` Joel Fernandes
2022-06-22 22:50 ` [PATCH v2 2/8] rcu: shrinker for lazy rcu Joel Fernandes (Google)
2022-06-22 22:50 ` [PATCH v2 3/8] fs: Move call_rcu() to call_rcu_lazy() in some paths Joel Fernandes (Google)
2022-06-22 22:50 ` [PATCH v2 4/8] rcu/nocb: Add option to force all call_rcu() to lazy Joel Fernandes (Google)
2022-06-22 22:50 ` [PATCH v2 5/8] rcu/nocb: Wake up gp thread when flushing Joel Fernandes (Google)
2022-06-26  4:06   ` Paul E. McKenney
2022-06-26 13:45     ` Joel Fernandes
2022-06-26 13:52       ` Paul E. McKenney
2022-06-26 14:37         ` Joel Fernandes
2022-06-22 22:51 ` [PATCH v2 6/8] rcuscale: Add test for using call_rcu_lazy() to emulate kfree_rcu() Joel Fernandes (Google)
2022-06-23  2:09   ` kernel test robot
2022-06-23  3:00   ` kernel test robot
2022-06-23  8:10   ` kernel test robot
2022-06-26  4:13   ` Paul E. McKenney
2022-07-08  4:25     ` Joel Fernandes [this message]
2022-07-08 23:06       ` Paul E. McKenney
2022-07-12 20:27         ` Joel Fernandes
2022-07-12 20:58           ` Paul E. McKenney
2022-07-12 21:15             ` Joel Fernandes
2022-07-12 22:41               ` Paul E. McKenney
2022-06-22 22:51 ` [PATCH v2 7/8] rcu/nocb: Rewrite deferred wake up logic to be more clean Joel Fernandes (Google)
2022-06-22 22:51 ` [PATCH v2 8/8] rcu/kfree: Fix kfree_rcu_shrink_count() return value Joel Fernandes (Google)
2022-06-26  4:17   ` Paul E. McKenney
2022-06-27 18:56   ` Uladzislau Rezki
2022-06-27 20:59     ` Paul E. McKenney
2022-06-27 21:18       ` Joel Fernandes
2022-06-27 21:43         ` Paul E. McKenney
2022-06-28 16:56           ` Joel Fernandes
2022-06-28 21:13             ` Joel Fernandes
2022-06-29 16:56               ` Paul E. McKenney
2022-06-29 19:47                 ` Joel Fernandes
2022-06-29 21:07                   ` Paul E. McKenney
2022-06-30 14:25                     ` Joel Fernandes
2022-06-30 15:29                       ` Paul E. McKenney
2022-06-29 16:52             ` Paul E. McKenney
2022-06-26  3:12 ` [PATCH v2 0/8] Implement call_rcu_lazy() and miscellaneous fixes Paul E. McKenney
2022-07-08  4:17   ` Joel Fernandes
2022-07-08 22:45     ` Paul E. McKenney
2022-07-10  1:38       ` Joel Fernandes
2022-07-10 15:47         ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YsexpcG2iaplKPIs@google.com \
    --to=joel@joelfernandes.org \
    --cc=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neeraj.iitr10@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=rushikesh.s.kadam@intel.com \
    --cc=urezki@gmail.com \
    --cc=vineeth@bitbyteword.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).