lkml.org 
[lkml]   [2023]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/4] sched/task: Add the put_task_struct_atomic_safe function
On 01/23, Oleg Nesterov wrote:
>
> On 01/20, Wander Lairson Costa wrote:
> >
> > +static inline void put_task_struct_atomic_safe(struct task_struct *task)
> > +{
> > + if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
> > + /*
> > + * Decrement the refcount explicitly to avoid unnecessarily
> > + * calling call_rcu.
> > + */
> > + if (refcount_dec_and_test(&task->usage))
> > + /*
> > + * under PREEMPT_RT, we can't call put_task_struct
> > + * in atomic context because it will indirectly
> > + * acquire sleeping locks.
> > + */
> > + call_rcu(&task->rcu, __delayed_put_task_struct);
> ^^^^^^^^^
> I am not sure the usage of task->rcu is safe...
>
> Suppose that, before __delayed_put_task_struct() is called by RCU, this task
> does the last schedule and calls put_task_struct_rcu_user().

Ah, sorry, please forget, rcu_users != 0 implies task->usage != 0.


> And, can't we simply turn put_task_struct() into something like
>
> put_task_struct(struct task_struct *t)
> {
> if (refcount_dec_and_test(&t->usage)) {
> if (IS_ENABLED(CONFIG_PREEMPT_RT)
> && (in_atomic() || irqs_disabled()))
> call_rcu(...);
> else
> __put_task_struct(t);
> }
> }
>
> ?
>
> Oleg.

\
 
 \ /
  Last update: 2023-03-26 23:52    [W:1.059 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site