RCU Archive mirror
 help / color / mirror / Atom feed
From: Zqiang <qiang.zhang1211@gmail.com>
To: paulmck@kernel.org, frederic@kernel.org, joel@joelfernandes.org,
	neeraj.upadhyay@kernel.org
Cc: qiang.zhang1211@gmail.com, rcu@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] rcu-tasks: Avoid rtp_irq_work triggering when the rcu-tasks GP is ongoing
Date: Mon, 11 Mar 2024 11:55:02 +0800	[thread overview]
Message-ID: <20240311035502.7112-1-qiang.zhang1211@gmail.com> (raw)

This commit generate rcu_task_gp_in_progress() to check whether
the rcu-tasks GP is ongoing, if is ongoing, avoid trigger
rtp_irq_work to wakeup rcu tasks kthreads in call_rcu_tasks_generic().

The test results are as follows:

echo call_rcu_tasks_iw_wakeup > /sys/kernel/debug/tracing/set_ftrace_filter
echo 1 > /sys/kernel/debug/tracing/function_profile_enabled
insmod rcutorture.ko torture_type=tasks-tracing fwd_progress=4
sleep 600
rmmod rcutorture.ko
echo 0 > /sys/kernel/debug/tracing/function_profile_enabled
echo > /sys/kernel/debug/tracing/set_ftrace_filter

head /sys/kernel/debug/tracing/trace_stat/function*

original: 56376  apply patch: 33521

Signed-off-by: Zqiang <qiang.zhang1211@gmail.com>
---
 
original:
==> /sys/kernel/debug/tracing/trace_stat/function0 <==
  Function                               Hit    Time            Avg             s^2
  --------                               ---    ----            ---             ---
  call_rcu_tasks_iw_wakeup             13217    19292.52 us     1.459 us        8.834 us    

==> /sys/kernel/debug/tracing/trace_stat/function1 <==
  Function                               Hit    Time            Avg             s^2
  --------                               ---    ----            ---             ---
  call_rcu_tasks_iw_wakeup             15146    22377.01 us     1.477 us        22.873 us   

==> /sys/kernel/debug/tracing/trace_stat/function2 <==
  Function                               Hit    Time            Avg             s^2
  --------                               ---    ----            ---             ---
  call_rcu_tasks_iw_wakeup             12561    18125.76 us     1.443 us        6.372 us    

==> /sys/kernel/debug/tracing/trace_stat/function3 <==
  Function                               Hit    Time            Avg             s^2
  --------                               ---    ----            ---             ---
  call_rcu_tasks_iw_wakeup             15452    21770.57 us     1.408 us        6.710 us

apply patch:
==> /sys/kernel/debug/tracing/trace_stat/function0 <==
  Function                               Hit    Time            Avg             s^2
  --------                               ---    ----            ---             ---
  call_rcu_tasks_iw_wakeup              8334    15121.13 us     1.814 us        4.457 us    

==> /sys/kernel/debug/tracing/trace_stat/function1 <==
  Function                               Hit    Time            Avg             s^2
  --------                               ---    ----            ---             ---
  call_rcu_tasks_iw_wakeup              8355    15760.51 us     1.886 us        14.775 us   

==> /sys/kernel/debug/tracing/trace_stat/function2 <==
  Function                               Hit    Time            Avg             s^2
  --------                               ---    ----            ---             ---
  call_rcu_tasks_iw_wakeup              7219    14194.27 us     1.966 us        42.440 us   

==> /sys/kernel/debug/tracing/trace_stat/function3 <==
  Function                               Hit    Time            Avg             s^2
  --------                               ---    ----            ---             ---
  call_rcu_tasks_iw_wakeup              9613    19850.04 us     2.064 us        91.023 us  

 kernel/rcu/tasks.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index 147b5945d67a..36c7e1d441d0 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -317,6 +317,11 @@ static void call_rcu_tasks_iw_wakeup(struct irq_work *iwp)
 	rcuwait_wake_up(&rtp->cbs_wait);
 }
 
+static int rcu_task_gp_in_progress(struct rcu_tasks *rtp)
+{
+	return rcu_seq_state(rcu_seq_current(&rtp->tasks_gp_seq));
+}
+
 // Enqueue a callback for the specified flavor of Tasks RCU.
 static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
 				   struct rcu_tasks *rtp)
@@ -375,7 +380,8 @@ static void call_rcu_tasks_generic(struct rcu_head *rhp, rcu_callback_t func,
 	}
 	rcu_read_unlock();
 	/* We can't create the thread unless interrupts are enabled. */
-	if (needwake && READ_ONCE(rtp->kthread_ptr))
+	if (needwake && READ_ONCE(rtp->kthread_ptr) &&
+			!rcu_task_gp_in_progress(rtp))
 		irq_work_queue(&rtpcp->rtp_irq_work);
 }
 
-- 
2.17.1


             reply	other threads:[~2024-03-11  3:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11  3:55 Zqiang [this message]
2024-03-11  3:57 ` [PATCH] rcu-tasks: Avoid rtp_irq_work triggering when the rcu-tasks GP is ongoing Z qiang
2024-03-17  4:55 ` Paul E. McKenney
2024-03-17  7:12   ` Z qiang
2024-03-17  7:31     ` 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=20240311035502.7112-1-qiang.zhang1211@gmail.com \
    --to=qiang.zhang1211@gmail.com \
    --cc=frederic@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).