Re: [PATCH 1/7] Freezer: Read PF_BORROWED_MM in a nonracy way

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/12, Rafael J. Wysocki wrote:
>
> Ah, I see.  We spawn a kernel thread from a code path that belongs to a
> user space task and we need to call deamonize() to make it become a
> 'real' kernel thread.
> 
> Still, this means that is_user_space() may return 'true' for this thread
> before it calls daemonize() and then the scenario described by me in the
> previous message may occur.  It seems.

Yes sure. Probably not so bad in practice. Most likely this fresh thread
is not "important" and could be freezed, I dunno.

> It's in freezer-fix-pf_nofreeze-vs-freezeable-race.patch (appended for
> convenience, white space may be broken).
>
> ---
> --- a/include/linux/freezer.h~freezer-fix-pf_nofreeze-vs-freezeable-race
> +++ a/include/linux/freezer.h
> @@ -63,8 +63,10 @@ static inline int thaw_process(struct ta
>   */
>  static inline void frozen_process(struct task_struct *p)
>  {
> -       p->flags |= PF_FROZEN;
> -       wmb();
> +       if (!unlikely(p->flags & PF_NOFREEZE)) {
> +               p->flags |= PF_FROZEN;
> +               wmb();
> +       }
>         clear_tsk_thread_flag(p, TIF_FREEZE);
>  }

This is OK if a kernel thread does try_to_freeze() eventually.

But what if it does not, because it marks itself as PF_NOFREEZE?
This means it may run with signal_pending() forever. That is why
I think we should clear TIF_FREEZE when we set PF_NOFREEZE.

Oleg.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux