rcu: Fix opposite might_sleep() check in rcu_blocking_is_gp()
PATCH 1/1 rcu: Fix opposite might_sleep() check in rcu_blocking_is_gp()
Currently, if the system is in the RCU_SCHEDULER_INACTIVE state, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but this might_sleep() check is the opposite. therefore, this commit puts might_sleep() check in the correct palce.
--- kernel/rcu/tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/rcu/tree.c +3 -2
@@ -3379,9 +3379,10 @@ void __init kfree_rcu_scheduler_running(void)*/ static int rcu_blocking_is_gp (void ) { -if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) +if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) { +might_sleep ();return false; -might_sleep ();/* Check for RCU read-side critical section. */ + }return true; }
Signature · 1 line
2.25.1
Paul E. McKenney
maintainerQuoted 7 lines · Zqiang
Currently, if the system is in the
RCU_SCHEDULER_INACTIVEstate, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but thismight_sleep()check is the opposite. therefore, this commit putsmight_sleep()check in the correct palce.Signed-off-by Zqiang <[email protected]>
Queued for testing and review, thank you!
I was under the impression that might_sleep() did some lockdep-based checking, but I am unable to find it. If there really is such checking, that would be a potential argument for leaving this code as it is.
But in the meantime, full speed ahead! ;-)
Thanx, Paul
Quoted 24 lines
--- kernel/rcu/tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/rcu/tree.c +3
-2@@ -3379,9 +3379,10 @@ void __init kfree_rcu_scheduler_running(void)*/ static int rcu_blocking_is_gp (void ) { -if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) +if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) { +might_sleep ();return false; -might_sleep ();/* Check for RCU read-side critical section. */ + }return true; }Signature · 1 line
2.25.1
Quoted 6 lines · Zqiang
Currently, if the system is in the
RCU_SCHEDULER_INACTIVEstate, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but thismight_sleep()check is the opposite. therefore, this commit putsmight_sleep()check in the correct palce.
Quoted 8 lines
Signed-off-by Zqiang <[email protected]>Queued for testing and review, thank you!
I was under the impression that
might_sleep()did some lockdep-based checking, but I am unable to find it. If there really is such checking, that would be a potential argument for leaving this code as it is.
__might_sleep
__might_resched(file, line, 0)
rcu_sleep_check()
Does it refer to this rcu_sleep_check() ?
If so, when in the RCU_SCHEDULER_INACTIVE state, the debug_lockdep_rcu_enabled() is always return false, so the RCU_LOCKDEP_WARN() also does not produce an actual warning.
Thanks
Zqiang
Quoted 28 lines
But in the meantime, full speed ahead! ;-)
Thanx, Paul
--- kernel/rcu/tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/rcu/tree.c +3
-2@@ -3379,9 +3379,10 @@ void __init kfree_rcu_scheduler_running(void)*/ static int rcu_blocking_is_gp (void ) { -if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) +if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) { +might_sleep ();return false; -might_sleep ();/* Check for RCU read-side critical section. */ + }return true; }Signature · 1 line
2.25.1
Quoted 15 lines · Zqiang
Currently, if the system is in the
RCU_SCHEDULER_INACTIVEstate, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but thismight_sleep()check is the opposite. therefore, this commit putsmight_sleep()check in the correct palce.Signed-off-by Zqiang <[email protected]>Queued for testing and review, thank you!
I was under the impression that
might_sleep()did some lockdep-based checking, but I am unable to find it. If there really is such checking, that would be a potential argument for leaving this code as it is.
Quoted 9 lines
__might_sleep
__might_resched(file, line, 0)
rcu_sleep_check()Does it refer to this
rcu_sleep_check()?If so, when in the
RCU_SCHEDULER_INACTIVEstate, thedebug_lockdep_rcu_enabled()is always return false, so theRCU_LOCKDEP_WARN()also does not produce an actual warning.
and when the system_state == SYSTEM_BOOTING, we just did rcu_sleep_check() and then return.
Thanks
Zqiang
Quoted 32 lines
Thanks
ZqiangBut in the meantime, full speed ahead! ;-)
Thanx, Paul
--- kernel/rcu/tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/rcu/tree.c +3
-2@@ -3379,9 +3379,10 @@ void __init kfree_rcu_scheduler_running(void)*/ static int rcu_blocking_is_gp (void ) { -if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) +if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) { +might_sleep ();return false; -might_sleep ();/* Check for RCU read-side critical section. */ + }return true; }Signature · 1 line
2.25.1
Paul E. McKenney
maintainerQuoted 21 lines · On Sat, Dec 17, 2022 at 02:44:47AM +0000, Zhang, Qiang1 wrote:
Quoted 19 lines · Zqiang
Currently, if the system is in the
RCU_SCHEDULER_INACTIVEstate, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but thismight_sleep()check is the opposite. therefore, this commit putsmight_sleep()check in the correct palce.Signed-off-by Zqiang <[email protected]>Queued for testing and review, thank you!
I was under the impression that
might_sleep()did some lockdep-based checking, but I am unable to find it. If there really is such checking, that would be a potential argument for leaving this code as it is.
__might_sleep
__might_resched(file, line, 0)
rcu_sleep_check()
Quoted 6 lines
Quoted 4 lines
Does it refer to this
rcu_sleep_check()?If so, when in the
RCU_SCHEDULER_INACTIVEstate, thedebug_lockdep_rcu_enabled()is always return false, so theRCU_LOCKDEP_WARN()also does not produce an actual warning.and when the
system_state==SYSTEM_BOOTING, we just didrcu_sleep_check()and then return.
Very good, thank you!
Thoughts from others?
Thanx, Paul
Quoted 35 lines
Thanks
ZqiangQuoted 32 lines
Thanks
ZqiangBut in the meantime, full speed ahead! ;-)
Thanx, Paul
--- kernel/rcu/tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)kernel/rcu/tree.c +3
-2@@ -3379,9 +3379,10 @@ void __init kfree_rcu_scheduler_running(void)*/ static int rcu_blocking_is_gp (void ) { -if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) +if (rcu_scheduler_active !=RCU_SCHEDULER_INACTIVE ) { +might_sleep ();return false; -might_sleep ();/* Check for RCU read-side critical section. */ + }return true; }Signature · 1 line
2.25.1
Quoted 24 lines · Paul E. McKenney
Quoted 23 lines · On Sat, Dec 17, 2022 at 02:44:47AM +0000, Zhang, Qiang1 wrote:
Quoted 21 lines · Zqiang
Currently, if the system is in the
RCU_SCHEDULER_INACTIVEstate, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but thismight_sleep()check is the opposite. therefore, this commit putsmight_sleep()check in the correct palce.Signed-off-by Zqiang <[email protected]>Queued for testing and review, thank you!
I was under the impression that
might_sleep()did some lockdep-based checking, but I am unable to find it. If there really is such checking, that would be a potential argument for leaving this code as it is.
__might_sleep
__might_resched(file, line, 0)
rcu_sleep_check()Does it refer to this
rcu_sleep_check()?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If so, when in the
RCU_SCHEDULER_INACTIVEstate, thedebug_lockdep_rcu_enabled()is always return false, so theRCU_LOCKDEP_WARN()also does not produce an actual warning.and when the
system_state==SYSTEM_BOOTING, we just didrcu_sleep_check()and then return.Very good, thank you!
Thoughts from others?
Please consider this as a best-effort comment that might be missing details:
The might_sleep() was added in 18fec7d8758d ("rcu: Improve synchronize_rcu() diagnostics")
Since it is illegal to call a blocking API like synchronize_rcu() in a non-preemptible section, is there any harm in just calling might_sleep() uncomditionally in rcu_block_is_gp() ? I think it is a bit irrelevant if synchronize_rcu() is called from a call path, before scheduler is initialized, or after. The fact that it was even called from a non-preemptible section is a red-flag, considering if such non-preemptible section may call synchronize_rcu() API in the future, after full boot up, even if rarely.
For this reason, IMHO there is still value in doing the might_sleep() check unconditionally. Say if a common code path is invoked both before RCU_SCHEDULER_INIT and *very rarely* after RCU_SCHEDULER_INIT.
Or is there more of a point in doing this check if scheduler is initialized from RCU perspective ?
If not, I would do something like this:
---8<-----------------------
kernel/rcu/tree.c +2 -1
@@ -3435,11 +3435,12 @@ static int rcu_blocking_is_gp(void) {int ret; +might_sleep ();/* Check for RCU read-side critical section. */ +// Invoking preempt_model_*() too early gets a splat. if (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ||preempt_model_full () ||preempt_model_rt ())return rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ; -might_sleep ();/* Check for RCU read-side critical section. */ preempt_disable ();/* * If the rcu_state.n_online_cpus counter is equal to one,
Paul E. McKenney
maintainerQuoted 48 lines · Joel Fernandes
Quoted 24 lines · Paul E. McKenney
Quoted 23 lines · On Sat, Dec 17, 2022 at 02:44:47AM +0000, Zhang, Qiang1 wrote:
Quoted 21 lines · Zqiang
Currently, if the system is in the
RCU_SCHEDULER_INACTIVEstate, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but thismight_sleep()check is the opposite. therefore, this commit putsmight_sleep()check in the correct palce.Signed-off-by Zqiang <[email protected]>Queued for testing and review, thank you!
I was under the impression that
might_sleep()did some lockdep-based checking, but I am unable to find it. If there really is such checking, that would be a potential argument for leaving this code as it is.
__might_sleep
__might_resched(file, line, 0)
rcu_sleep_check()Does it refer to this
rcu_sleep_check()?Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If so, when in the
RCU_SCHEDULER_INACTIVEstate, thedebug_lockdep_rcu_enabled()is always return false, so theRCU_LOCKDEP_WARN()also does not produce an actual warning.and when the
system_state==SYSTEM_BOOTING, we just didrcu_sleep_check()and then return.Very good, thank you!
Thoughts from others?
Please consider this as a best-effort comment that might be missing details:
The
might_sleep()was added in18fec7d8758d("rcu: Improvesynchronize_rcu()diagnostics")Since it is illegal to call a blocking API like
synchronize_rcu()in a non-preemptible section, is there any harm in just callingmight_sleep()uncomditionally inrcu_block_is_gp()? I think it is a bit irrelevant ifsynchronize_rcu()is called from a call path, before scheduler is initialized, or after. The fact that it was even called from a non-preemptible section is a red-flag, considering if such non-preemptible section may callsynchronize_rcu()API in the future, after full boot up, even if rarely.
Quoted 6 lines
For this reason, IMHO there is still value in doing the
might_sleep()check unconditionally. Say if a common code path is invoked both beforeRCU_SCHEDULER_INITand *very rarely* afterRCU_SCHEDULER_INIT.Or is there more of a point in doing this check if scheduler is initialized from RCU perspective ?
One advantage of its current placement would be if might_sleep() ever unconditionally checks for interrupts being disabled.
I don't believe that might_sleep() will do that any time soon given the likely fallout from code invoked at early boot as well as from runtime, but why be in the way of that additional diagnostic check?
Thanx, Paul
Quoted 22 lines
If not, I would do something like this:
---8<-----------------------
kernel/rcu/tree.c +2
-1@@ -3435,11 +3435,12 @@ static int rcu_blocking_is_gp(void) {int ret; +might_sleep ();/* Check for RCU read-side critical section. */ +// Invoking preempt_model_*() too early gets a splat. if (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ||preempt_model_full () ||preempt_model_rt ())return rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ; -might_sleep ();/* Check for RCU read-side critical section. */ preempt_disable ();/* * If the rcu_state.n_online_cpus counter is equal to one,
Quoted 57 lines · Paul E. McKenney
Quoted 48 lines · Joel Fernandes
Quoted 24 lines · Paul E. McKenney
Quoted 23 lines · On Sat, Dec 17, 2022 at 02:44:47AM +0000, Zhang, Qiang1 wrote:
Quoted 21 lines · Zqiang
Currently, if the system is in the
RCU_SCHEDULER_INACTIVEstate, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but thismight_sleep()check is the opposite. therefore, this commit putsmight_sleep()check in the correct palce.Signed-off-by Zqiang <[email protected]>Queued for testing and review, thank you!
I was under the impression that
might_sleep()did some lockdep-based checking, but I am unable to find it. If there really is such checking, that would be a potential argument for leaving this code as it is.
__might_sleep
__might_resched(file, line, 0)
rcu_sleep_check()Does it refer to this
rcu_sleep_check()?Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If so, when in the
RCU_SCHEDULER_INACTIVEstate, thedebug_lockdep_rcu_enabled()is always return false, so theRCU_LOCKDEP_WARN()also does not produce an actual warning.and when the
system_state==SYSTEM_BOOTING, we just didrcu_sleep_check()and then return.Very good, thank you!
Thoughts from others?
Please consider this as a best-effort comment that might be missing details:
The
might_sleep()was added in18fec7d8758d("rcu: Improvesynchronize_rcu()diagnostics")Since it is illegal to call a blocking API like
synchronize_rcu()in a non-preemptible section, is there any harm in just callingmight_sleep()uncomditionally inrcu_block_is_gp()? I think it is a bit irrelevant ifsynchronize_rcu()is called from a call path, before scheduler is initialized, or after. The fact that it was even called from a non-preemptible section is a red-flag, considering if such non-preemptible section may callsynchronize_rcu()API in the future, after full boot up, even if rarely.Quoted 6 lines
For this reason, IMHO there is still value in doing the
might_sleep()check unconditionally. Say if a common code path is invoked both beforeRCU_SCHEDULER_INITand *very rarely* afterRCU_SCHEDULER_INIT.Or is there more of a point in doing this check if scheduler is initialized from RCU perspective ?
Quoted 6 lines
One advantage of its current placement would be if
might_sleep()ever unconditionally checks for interrupts being disabled.I don't believe that
might_sleep()will do that any time soon given the likely fallout from code invoked at early boot as well as from runtime, but why be in the way of that additional diagnostic check?
If I understand the current code, might_sleep() is invoked only if the scheduler is INACTIVE from RCU perspective, and I don't think here are reports of fall out. That is current code behavior.
Situation right now is: might_sleep() only if the state is INACTIVE. Qiang's patch: might_sleep() only if the state is NOT INACTIVE. My suggestion: might_sleep() regardless of the state.
Is there a reason my suggestion will not work? Apologies if I misunderstood something.
thanks,
- Joel
Quoted 25 lines
Thanx, Paul
Quoted 22 lines
If not, I would do something like this:
---8<-----------------------
kernel/rcu/tree.c +2
-1@@ -3435,11 +3435,12 @@ static int rcu_blocking_is_gp(void) {int ret; +might_sleep ();/* Check for RCU read-side critical section. */ +// Invoking preempt_model_*() too early gets a splat. if (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ||preempt_model_full () ||preempt_model_rt ())return rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ; -might_sleep ();/* Check for RCU read-side critical section. */ preempt_disable ();/* * If the rcu_state.n_online_cpus counter is equal to one,
Paul E. McKenney
maintainerQuoted 96 lines · Joel Fernandes
Quoted 57 lines · Paul E. McKenney
Quoted 48 lines · Joel Fernandes
Quoted 24 lines · Paul E. McKenney
Quoted 23 lines · On Sat, Dec 17, 2022 at 02:44:47AM +0000, Zhang, Qiang1 wrote:
Quoted 21 lines · Zqiang
Currently, if the system is in the
RCU_SCHEDULER_INACTIVEstate, invoke synchronize_rcu_*() will implies a grace period and return directly, so there is no sleep action due to waiting for a grace period to end, but thismight_sleep()check is the opposite. therefore, this commit putsmight_sleep()check in the correct palce.Signed-off-by Zqiang <[email protected]>Queued for testing and review, thank you!
I was under the impression that
might_sleep()did some lockdep-based checking, but I am unable to find it. If there really is such checking, that would be a potential argument for leaving this code as it is.
__might_sleep
__might_resched(file, line, 0)
rcu_sleep_check()Does it refer to this
rcu_sleep_check()?Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If so, when in the
RCU_SCHEDULER_INACTIVEstate, thedebug_lockdep_rcu_enabled()is always return false, so theRCU_LOCKDEP_WARN()also does not produce an actual warning.and when the
system_state==SYSTEM_BOOTING, we just didrcu_sleep_check()and then return.Very good, thank you!
Thoughts from others?
Please consider this as a best-effort comment that might be missing details:
The
might_sleep()was added in18fec7d8758d("rcu: Improvesynchronize_rcu()diagnostics")Since it is illegal to call a blocking API like
synchronize_rcu()in a non-preemptible section, is there any harm in just callingmight_sleep()uncomditionally inrcu_block_is_gp()? I think it is a bit irrelevant ifsynchronize_rcu()is called from a call path, before scheduler is initialized, or after. The fact that it was even called from a non-preemptible section is a red-flag, considering if such non-preemptible section may callsynchronize_rcu()API in the future, after full boot up, even if rarely.Quoted 6 lines
For this reason, IMHO there is still value in doing the
might_sleep()check unconditionally. Say if a common code path is invoked both beforeRCU_SCHEDULER_INITand *very rarely* afterRCU_SCHEDULER_INIT.Or is there more of a point in doing this check if scheduler is initialized from RCU perspective ?
Quoted 6 lines
One advantage of its current placement would be if
might_sleep()ever unconditionally checks for interrupts being disabled.I don't believe that
might_sleep()will do that any time soon given the likely fallout from code invoked at early boot as well as from runtime, but why be in the way of that additional diagnostic check?If I understand the current code,
might_sleep()is invoked only if the scheduler is INACTIVE from RCU perspective, and I don't think here are reports of fall out. That is current code behavior.Situation right now is:
might_sleep()only if the state is INACTIVE. Qiang's patch:might_sleep()only if the state is NOT INACTIVE. My suggestion:might_sleep()regardless of the state.Is there a reason my suggestion will not work? Apologies if I misunderstood something.
thanks,
- Joel
Quoted 15 lines
Thanx, Paul
Quoted 12 lines
If not, I would do something like this:
---8<-----------------------
kernel/rcu/tree.c +0
-0@@ -3435,11 +3435,12 @@ static int rcu_blocking_is_gp(void) {int ret;
Quoted 6 lines
Quoted 6 lines
kernel/rcu/tree.c static int rcu_blocking_is_gp(void) · line 3443
Quoted 6 lines
kernel/rcu/tree.c +2
-0+might_sleep ();/* Check for RCU read-side critical section. */ +// Invoking preempt_model_*() too early gets a splat. if (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ||preempt_model_full () ||preempt_model_rt ())return rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ;
If the scheduler is inactive (early boot with interrupts disabled), we return here.
Quoted 1 line
Quoted 1 line
kernel/rcu/tree.c static int rcu_blocking_is_gp(void) · line 3442
Quoted 1 line
kernel/rcu/tree.c +0
-1-might_sleep ();/* Check for RCU read-side critical section. */
We get here only if the scheduler has started, and even then only in preemption-disabled kernels.
Or is you concern that the might_sleep() never gets invoked in kernels with preemption enabled? Fixing that would require a slightly different patch, though.
Or should I have waited until tomorrow to respond to this email? ;-)
Thanx, Paul
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
kernel/rcu/tree.c +0
-0preempt_disable ();/* * If the rcu_state.n_online_cpus counter is equal to one,
On Sun, Dec 18, 2022 at 2:44 PM Paul E. McKenney <[email protected]> wrote:
[...]
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
If not, I would do something like this:
---8<-----------------------
kernel/rcu/tree.c +0
-0@@ -3435,11 +3435,12 @@ static int rcu_blocking_is_gp(void) {int ret;Quoted 6 lines
Quoted 6 lines
kernel/rcu/tree.c static int rcu_blocking_is_gp(void) · line 3443
Quoted 6 lines
kernel/rcu/tree.c +2
-0+might_sleep ();/* Check for RCU read-side critical section. */ +// Invoking preempt_model_*() too early gets a splat. if (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ||preempt_model_full () ||preempt_model_rt ())return rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ;If the scheduler is inactive (early boot with interrupts disabled), we return here.
Quoted 1 line
Quoted 1 line
kernel/rcu/tree.c static int rcu_blocking_is_gp(void) · line 3442
Quoted 1 line
kernel/rcu/tree.c +0
-1-might_sleep ();/* Check for RCU read-side critical section. */
Quoted 8 lines
We get here only if the scheduler has started, and even then only in preemption-disabled kernels.
Or is you concern that the
might_sleep()never gets invoked in kernels with preemption enabled? Fixing that would require a slightly different patch, though.Or should I have waited until tomorrow to respond to this email? ;-)
No, I think you are quite right. I was not referring to rcu_sleep_check(), but rather the following prints in might_sleep(). I see an unconditional call to might_sleep() from kvfree_call_rcu() but not one from synchronize_rcu() which can also sleep.
But I see your point, early boot code has interrupts disabled, but can still totally call synchronize_rcu() when the scheduler is INACTIVE. And might_sleep() might bitterly complain. Thanks for the clarification.
pr_err("BUG: sleeping function called from invalid context at %s:%d\n",
file, line);
pr_err("in_atomic(): %d, irqs_disabled(): %d, non_block: %d, pid: %d,
name: %s\n",
in_atomic(), irqs_disabled(), current->non_block_count,
current->pid, current->comm);
pr_err("preempt_count: %x, expected: %x\n", preempt_count(),
offsets & MIGHT_RESCHED_PREEMPT_MASK);Thanks,
- Joel
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
kernel/rcu/tree.c +0
-0/* * If the rcu_state.n_online_cpus counter is equal to one,
Paul E. McKenney
maintainerQuoted 45 lines · Joel Fernandes
On Sun, Dec 18, 2022 at 2:44 PM Paul E. McKenney <[email protected]> wrote:
[...]Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
If not, I would do something like this:
---8<-----------------------
kernel/rcu/tree.c +0
-0@@ -3435,11 +3435,12 @@ static int rcu_blocking_is_gp(void) {int ret;Quoted 6 lines
Quoted 6 lines
kernel/rcu/tree.c static int rcu_blocking_is_gp(void) · line 3443
Quoted 6 lines
kernel/rcu/tree.c +2
-0+might_sleep ();/* Check for RCU read-side critical section. */ +// Invoking preempt_model_*() too early gets a splat. if (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ||preempt_model_full () ||preempt_model_rt ())return rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE ;If the scheduler is inactive (early boot with interrupts disabled), we return here.
Quoted 1 line
Quoted 1 line
kernel/rcu/tree.c static int rcu_blocking_is_gp(void) · line 3442
Quoted 1 line
kernel/rcu/tree.c +0
-1-might_sleep ();/* Check for RCU read-side critical section. */ Quoted 8 lines
We get here only if the scheduler has started, and even then only in preemption-disabled kernels.
Or is you concern that the
might_sleep()never gets invoked in kernels with preemption enabled? Fixing that would require a slightly different patch, though.Or should I have waited until tomorrow to respond to this email? ;-)
No, I think you are quite right. I was not referring to
rcu_sleep_check(), but rather the following prints inmight_sleep(). I see an unconditional call tomight_sleep()fromkvfree_call_rcu()but not one fromsynchronize_rcu()which can also sleep.But I see your point, early boot code has interrupts disabled, but can still totally call
synchronize_rcu()when the scheduler is INACTIVE. Andmight_sleep()might bitterly complain. Thanks for the clarification.
Quoted 8 lines
pr_err("BUG: sleeping function called from invalid context at %s:%d\n",
file, line); pr_err("in_atomic(): %d, irqs_disabled(): %d, non_block: %d, pid: %d, name: %s\n", in_atomic(), irqs_disabled(), current->non_block_count, current->pid, current->comm); pr_err("preempt_count: %x, expected: %x\n", preempt_count(), offsets & MIGHT_RESCHED_PREEMPT_MASK);
And I do not believe that we have defined whether or not it is OK to invoke single-argument kvfree_rcu() before the scheduler has started. ;-)
Thanx, Paul