mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neeraj Upadhyay <quic_neeraju@quicinc.com>
To: "Paul E. McKenney" <paulmck@kernel.org>, <rcu@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <kernel-team@fb.com>,
	<rostedt@goodmis.org>,
	"Joel Fernandes (Google)" <joel@joelfernandes.org>,
	Uladzislau Rezki <urezki@gmail.com>
Subject: Re: [PATCH rcu 09/12] rcu/kvfree: Remove useless monitor_todo flag
Date: Tue, 21 Jun 2022 15:32:36 +0530	[thread overview]
Message-ID: <e70c457c-0ac6-174d-fa0f-807d8e563f40@quicinc.com> (raw)
In-Reply-To: <20220620222032.3839547-9-paulmck@kernel.org>



On 6/21/2022 3:50 AM, Paul E. McKenney wrote:
> From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
> 
> monitor_todo is not needed as the work struct already tracks
> if work is pending. Just use that to know if work is pending
> using schedule_delayed_work() helper.
> 
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
> ---

Reviewed-by: Neeraj Upadhyay <quic_neeraju@quicinc.com>


Thanks
Neeraj

>   kernel/rcu/tree.c | 33 ++++++++++++++++-----------------
>   1 file changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> index 5445b19b48408..7919d7b48fa6a 100644
> --- a/kernel/rcu/tree.c
> +++ b/kernel/rcu/tree.c
> @@ -3216,7 +3216,6 @@ struct kfree_rcu_cpu_work {
>    * @krw_arr: Array of batches of kfree_rcu() objects waiting for a grace period
>    * @lock: Synchronize access to this structure
>    * @monitor_work: Promote @head to @head_free after KFREE_DRAIN_JIFFIES
> - * @monitor_todo: Tracks whether a @monitor_work delayed work is pending
>    * @initialized: The @rcu_work fields have been initialized
>    * @count: Number of objects for which GP not started
>    * @bkvcache:
> @@ -3241,7 +3240,6 @@ struct kfree_rcu_cpu {
>   	struct kfree_rcu_cpu_work krw_arr[KFREE_N_BATCHES];
>   	raw_spinlock_t lock;
>   	struct delayed_work monitor_work;
> -	bool monitor_todo;
>   	bool initialized;
>   	int count;
>   
> @@ -3421,6 +3419,18 @@ static void kfree_rcu_work(struct work_struct *work)
>   	}
>   }
>   
> +static bool
> +need_offload_krc(struct kfree_rcu_cpu *krcp)
> +{
> +	int i;
> +
> +	for (i = 0; i < FREE_N_CHANNELS; i++)
> +		if (krcp->bkvhead[i])
> +			return true;
> +
> +	return !!krcp->head;
> +}
> +
>   /*
>    * This function is invoked after the KFREE_DRAIN_JIFFIES timeout.
>    */
> @@ -3477,9 +3487,7 @@ static void kfree_rcu_monitor(struct work_struct *work)
>   	// of the channels that is still busy we should rearm the
>   	// work to repeat an attempt. Because previous batches are
>   	// still in progress.
> -	if (!krcp->bkvhead[0] && !krcp->bkvhead[1] && !krcp->head)
> -		krcp->monitor_todo = false;
> -	else
> +	if (need_offload_krc(krcp))
>   		schedule_delayed_work(&krcp->monitor_work, KFREE_DRAIN_JIFFIES);
>   
>   	raw_spin_unlock_irqrestore(&krcp->lock, flags);
> @@ -3667,11 +3675,8 @@ void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
>   	WRITE_ONCE(krcp->count, krcp->count + 1);
>   
>   	// Set timer to drain after KFREE_DRAIN_JIFFIES.
> -	if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING &&
> -	    !krcp->monitor_todo) {
> -		krcp->monitor_todo = true;
> +	if (rcu_scheduler_active == RCU_SCHEDULER_RUNNING)
>   		schedule_delayed_work(&krcp->monitor_work, KFREE_DRAIN_JIFFIES);
> -	}
>   
>   unlock_return:
>   	krc_this_cpu_unlock(krcp, flags);
> @@ -3746,14 +3751,8 @@ void __init kfree_rcu_scheduler_running(void)
>   		struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu);
>   
>   		raw_spin_lock_irqsave(&krcp->lock, flags);
> -		if ((!krcp->bkvhead[0] && !krcp->bkvhead[1] && !krcp->head) ||
> -				krcp->monitor_todo) {
> -			raw_spin_unlock_irqrestore(&krcp->lock, flags);
> -			continue;
> -		}
> -		krcp->monitor_todo = true;
> -		schedule_delayed_work_on(cpu, &krcp->monitor_work,
> -					 KFREE_DRAIN_JIFFIES);
> +		if (need_offload_krc(krcp))
> +			schedule_delayed_work_on(cpu, &krcp->monitor_work, KFREE_DRAIN_JIFFIES);
>   		raw_spin_unlock_irqrestore(&krcp->lock, flags);
>   	}
>   }

  reply	other threads:[~2022-06-21 10:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 22:20 [PATCH rcu 0/12] Miscellaneous fixes for v5.20 Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 01/12] rcu: Decrease FQS scan wait time in case of callback overloading Paul E. McKenney
2022-06-21  5:29   ` Neeraj Upadhyay
2022-06-21 22:19     ` Paul E. McKenney
2022-06-22 11:46       ` Neeraj Upadhyay
2022-06-20 22:20 ` [PATCH rcu 02/12] rcu: Avoid tracing a few functions executed in stop machine Paul E. McKenney
2022-06-21  5:47   ` Neeraj Upadhyay
2022-06-21 22:21     ` Paul E. McKenney
2022-06-22 11:50       ` Neeraj Upadhyay
2022-06-22 15:35         ` Paul E. McKenney
2022-06-22 15:49           ` Neeraj Upadhyay
2022-06-23  0:29             ` Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 03/12] rcu: Add rnp->cbovldmask check in rcutree_migrate_callbacks() Paul E. McKenney
2022-06-21  5:57   ` Neeraj Upadhyay
2022-06-21 22:22     ` Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 04/12] rcu: Immediately boost preempted readers for strict grace periods Paul E. McKenney
2022-06-21  6:00   ` Neeraj Upadhyay
2022-06-20 22:20 ` [PATCH rcu 05/12] rcu: Forbid RCU_STRICT_GRACE_PERIOD in TINY_RCU kernels Paul E. McKenney
2022-06-21  6:02   ` Neeraj Upadhyay
2022-06-20 22:20 ` [PATCH rcu 06/12] locking/csd_lock: Change csdlock_debug from early_param to __setup Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 07/12] rcu: tiny: Record kvfree_call_rcu() call stack for KASAN Paul E. McKenney
2022-06-21  6:31   ` Neeraj Upadhyay
2022-06-21 19:31     ` Paul E. McKenney
2022-06-21 21:14       ` Marco Elver
2022-06-21 22:17         ` Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 08/12] rcu: Cleanup RCU urgency state for offline CPU Paul E. McKenney
2022-06-21  7:03   ` Neeraj Upadhyay
2022-06-21 22:24     ` Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 09/12] rcu/kvfree: Remove useless monitor_todo flag Paul E. McKenney
2022-06-21 10:02   ` Neeraj Upadhyay [this message]
2022-06-20 22:20 ` [PATCH rcu 10/12] rcu: Initialize first_gp_fqs at declaration in rcu_gp_fqs() Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 11/12] rcu/tree: Add comment to describe GP-done condition in fqs loop Paul E. McKenney
2022-06-20 22:20 ` [PATCH rcu 12/12] srcu: Block less aggressively for expedited grace periods Paul E. McKenney
2022-06-21  2:00   ` Zhangfei Gao
2022-06-21  3:15     ` Paul E. McKenney
2022-06-21  7:43   ` Shameerali Kolothum Thodi
2022-06-21 19:36     ` Paul E. McKenney
2022-06-21 10:13   ` Neeraj Upadhyay
2022-06-21 22:25     ` 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=e70c457c-0ac6-174d-fa0f-807d8e563f40@quicinc.com \
    --to=quic_neeraju@quicinc.com \
    --cc=joel@joelfernandes.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=urezki@gmail.com \
    /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

all inboxes | Powered by JetHome®