lkml.org 
[lkml]   [2020]   [Mar]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH RFC] ext4: fix potential race between online resizing and write operations
> > > So in CONFIG_PREEMPT kernel we can identify if we are in atomic or not by
> > > using rcu_preempt_depth() and in_atomic(). When it comes to !CONFIG_PREEMPT
> > > then we skip it and consider as atomic. Something like:
> > >
> > > <snip>
> > > static bool is_current_in_atomic()
> >
> > Would be good to change this to is_current_in_rcu_reader() since
> > rcu_preempt_depth() does not imply atomicity.
> >
> can_current_synchronize_rcu()? If can we just call:
>
> <snip>
> synchronize_rcu() or synchronize_rcu_expedited();
> kvfree();
> <snip>
>
> > > {
> > > #ifdef CONFIG_PREEMPT_RCU
> > > if (!rcu_preempt_depth() && !in_atomic())
> > > return false;
> >
> > I think use if (!rcu_preempt_depth() && preemptible()) here.
> >
> > preemptible() checks for IRQ disabled section as well.
> >
> Yes but in_atomic() does it as well, it also checks other atomic
> contexts like softirq handlers and NMI ones. So calling there
> synchronize_rcu() is not allowed.
>
Ahh. Right you are. We also have to check if irqs are disabled
or not. preemptible() has to be added as well.

<snip>
can_current_synchronize_rcu()
{
if (IS_ENABLED(CONFIG_PREEMPT_RCU)) {
if (!rcu_preempt_depth() && !in_atomic() && preemptible()) {
might_sleep();
return true;
}
}

return false;
}
<snip>

if we can synchronize:
- we can directly inline kvfree() to current context;
- we can attached the head using GFP_KERNEL | __GFP_RETRY_MAYFAIL.

Otherwise attached the rcu_head under atomic or as we are in RCU reader section.

Thoughts?

--
Vlad Rezki

\
 
 \ /
  Last update: 2020-03-01 13:07    [W:0.067 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site