mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joel Fernandes <joel@joelfernandes.org>
To: paulmck@kernel.org
Cc: linux-kernel@vger.kernel.org,
	Josh Triplett <josh@joshtriplett.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	rcu@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>,
	fweisbec@gmail.com, urezki@gmail.com
Subject: Re: [PATCH v2 rcu/dev 1/2] rcu: Track laziness during boot and suspend
Date: Wed, 11 Jan 2023 20:56:57 -0500	[thread overview]
Message-ID: <CED4D47F-BEA3-4F53-9934-939454DDEE2B@joelfernandes.org> (raw)
In-Reply-To: <20230112012950.GE4028633@paulmck-ThinkPad-P17-Gen-1>



> On Jan 11, 2023, at 8:29 PM, Paul E. McKenney <paulmck@kernel.org> wrote:
> 
> On Thu, Jan 12, 2023 at 12:52:22AM +0000, Joel Fernandes (Google) wrote:
>> During boot and suspend/resume, it is desired to prevent RCU laziness from
>> effecting performance and in some cases failures like with suspend.
>> 
>> Track whether RCU laziness is to be ignored or not, in kernels with
>> CONFIG_RCU_LAZY enabled. We do such tracking for expedited-RCU already, however
>> since Android currently expedites synchronous_rcu() always, we cannot rely on
>> that. The next patch ignores laziness hints based on this tracking.
>> 
>> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
>> ---
>> Paul, could we take this and the next one for 6.2 -rc cycle?
> 
> Given how late it is in v6.2, I would need you to make it all depend on
> CONFIG_RCU_LAZY, so that it is blindingly and immediately obvious that
> there is no change in behavior for kernels built with CONFIG_RCU_LAZY=n.
> 
> If you are OK with the v6.3 merge window and backports, what you have
> likely suffices, modulo review and testing.
> 
> So, how would you like to proceed?

Yes that is fine with me. Though, it is right now fully compile-time dependent on the lazy config, except the definition of the integer which I can’t put behind a config because of ugly ifdefs. I would expect LTO to remove the integer definition automatically. But it has no effect otherwise.

I do worry a bit about users who are not using stable and have their own kernel versions with backports. But maybe a fixes tag will get their attention?

Android and ChromeOS should both be fine though, given they swear by stable.

Thanks,

 - Joel 


> 
>                            Thanx, Paul
> 
>> I also booted debian Linux and verified the flag is reset correctly after boot
>> completes. Thanks.
>> 
>> kernel/rcu/rcu.h    |  6 ++++++
>> kernel/rcu/tree.c   |  2 ++
>> kernel/rcu/update.c | 40 +++++++++++++++++++++++++++++++++++++++-
>> 5 files changed, 55 insertions(+), 1 deletion(-)
>> create mode 100644 cc_list
>> create mode 100644 to_list
>> 
>> diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
>> index 5c8013f7085f..115616ac3bfa 100644
>> --- a/kernel/rcu/rcu.h
>> +++ b/kernel/rcu/rcu.h
>> @@ -449,14 +449,20 @@ do {                                    \
>> /* Tiny RCU doesn't expedite, as its purpose in life is instead to be tiny. */
>> static inline bool rcu_gp_is_normal(void) { return true; }
>> static inline bool rcu_gp_is_expedited(void) { return false; }
>> +static inline bool rcu_async_should_hurry(void) { return false; }
>> static inline void rcu_expedite_gp(void) { }
>> static inline void rcu_unexpedite_gp(void) { }
>> +static inline void rcu_async_hurry(void) { }
>> +static inline void rcu_async_relax(void) { }
>> static inline void rcu_request_urgent_qs_task(struct task_struct *t) { }
>> #else /* #ifdef CONFIG_TINY_RCU */
>> bool rcu_gp_is_normal(void);     /* Internal RCU use. */
>> bool rcu_gp_is_expedited(void);  /* Internal RCU use. */
>> +bool rcu_async_should_hurry(void);  /* Internal RCU use. */
>> void rcu_expedite_gp(void);
>> void rcu_unexpedite_gp(void);
>> +void rcu_async_hurry(void);
>> +void rcu_async_relax(void);
>> void rcupdate_announce_bootup_oddness(void);
>> #ifdef CONFIG_TASKS_RCU_GENERIC
>> void show_rcu_tasks_gp_kthreads(void);
>> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
>> index 63545d79da51..78b2e999c904 100644
>> --- a/kernel/rcu/tree.c
>> +++ b/kernel/rcu/tree.c
>> @@ -4504,11 +4504,13 @@ static int rcu_pm_notify(struct notifier_block *self,
>>    switch (action) {
>>    case PM_HIBERNATION_PREPARE:
>>    case PM_SUSPEND_PREPARE:
>> +        rcu_async_hurry();
>>        rcu_expedite_gp();
>>        break;
>>    case PM_POST_HIBERNATION:
>>    case PM_POST_SUSPEND:
>>        rcu_unexpedite_gp();
>> +        rcu_async_relax();
>>        break;
>>    default:
>>        break;
>> diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
>> index 3893022f8ed8..19bf6fa3ee6a 100644
>> --- a/kernel/rcu/update.c
>> +++ b/kernel/rcu/update.c
>> @@ -144,8 +144,45 @@ bool rcu_gp_is_normal(void)
>> }
>> EXPORT_SYMBOL_GPL(rcu_gp_is_normal);
>> 
>> -static atomic_t rcu_expedited_nesting = ATOMIC_INIT(1);
>> +static atomic_t rcu_async_hurry_nesting = ATOMIC_INIT(1);
>> +/*
>> + * Should call_rcu() callbacks be processed with urgency or are
>> + * they OK being executed with arbitrary delays?
>> + */
>> +bool rcu_async_should_hurry(void)
>> +{
>> +    return !IS_ENABLED(CONFIG_RCU_LAZY) ||
>> +           atomic_read(&rcu_async_hurry_nesting);
>> +}
>> +EXPORT_SYMBOL_GPL(rcu_async_should_hurry);
>> +
>> +/**
>> + * rcu_async_hurry - Make future async RCU callbacks not lazy.
>> + *
>> + * After a call to this function, future calls to call_rcu()
>> + * will be processed in a timely fashion.
>> + */
>> +void rcu_async_hurry(void)
>> +{
>> +    if (IS_ENABLED(CONFIG_RCU_LAZY))
>> +        atomic_inc(&rcu_async_hurry_nesting);
>> +}
>> +EXPORT_SYMBOL_GPL(rcu_async_hurry);
>> 
>> +/**
>> + * rcu_async_relax - Make future async RCU callbacks lazy.
>> + *
>> + * After a call to this function, future calls to call_rcu()
>> + * will be processed in a lazy fashion.
>> + */
>> +void rcu_async_relax(void)
>> +{
>> +    if (IS_ENABLED(CONFIG_RCU_LAZY))
>> +        atomic_dec(&rcu_async_hurry_nesting);
>> +}
>> +EXPORT_SYMBOL_GPL(rcu_async_relax);
>> +
>> +static atomic_t rcu_expedited_nesting = ATOMIC_INIT(1);
>> /*
>>  * Should normal grace-period primitives be expedited?  Intended for
>>  * use within RCU.  Note that this function takes the rcu_expedited
>> @@ -195,6 +232,7 @@ static bool rcu_boot_ended __read_mostly;
>> void rcu_end_inkernel_boot(void)
>> {
>>    rcu_unexpedite_gp();
>> +    rcu_async_relax();
>>    if (rcu_normal_after_boot)
>>        WRITE_ONCE(rcu_normal, 1);
>>    rcu_boot_ended = true;
>> -- 
>> 2.39.0.314.g84b9a713c41-goog

  reply	other threads:[~2023-01-12  1:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12  0:52 Joel Fernandes (Google)
2023-01-12  0:52 ` [PATCH v2 rcu/dev 2/2] rcu: Disable laziness if lazy-tracking says so Joel Fernandes (Google)
2023-01-15 20:54   ` Steven Rostedt
2023-01-15 21:29     ` Joel Fernandes
2023-01-12  1:29 ` [PATCH v2 rcu/dev 1/2] rcu: Track laziness during boot and suspend Paul E. McKenney
2023-01-12  1:56   ` Joel Fernandes [this message]
2023-01-12 19:27 ` Paul E. McKenney
2023-01-12 22:25   ` Joel Fernandes
2023-01-12 23:50     ` Paul E. McKenney
2023-01-15 21:25 ` Steven Rostedt
2023-01-15 21:34   ` Joel Fernandes
2023-01-16  4:26     ` Paul E. McKenney
2023-01-17 19:32     ` Steven Rostedt
2023-01-17 19:37       ` Paul E. McKenney
2023-01-17 19:45         ` Joel Fernandes
2023-01-17 21:40         ` Steven Rostedt
2023-01-18  3:51           ` 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=CED4D47F-BEA3-4F53-9934-939454DDEE2B@joelfernandes.org \
    --to=joel@joelfernandes.org \
    --cc=fweisbec@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --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®