Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1508365

Re: [PATCH 1/1] kthread: fix possible infinite wait for parking when kthread exits meanwhile

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/1] kthread: fix possible infinite wait for parking when kthread exits meanwhile
Date 2016-10-25 17:20 +0200
Message-ID <swbGa-7lz-17@gated-at.bofh.it> (permalink)
References <sw7Md-4N9-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Well. I was going to ignore this patch, I will leave this to Thomas
anyway...

But can't resist, because I have to admit I dislike this one too ;)

On 10/25, Roman Pen wrote:
>
>  int kthread_park(struct task_struct *k)
>  {
> -	struct kthread *kthread = to_live_kthread_and_get(k);
> +	struct kthread *kthread;
>  	int ret = -ENOSYS;
>  
> -	if (kthread) {
> -		if (!test_bit(KTHREAD_IS_PARKED, &kthread->flags)) {
> +	/*
> +	 * Here we try to be careful and handle the case, when kthread
> +	 * is going to die and will never park.

But why?

IMO we should not complicate this code for the case when the kernel
thread crashes.

> +	do {
> +		kthread = to_live_kthread_and_get(k);
> +		if (!kthread)
> +			break;
> +		if (!__kthread_isparked(kthread)) {
>  			set_bit(KTHREAD_SHOULD_PARK, &kthread->flags);
>  			if (k != current) {
>  				wake_up_process(k);
>  				wait_for_completion(&kthread->parked);
>  			}
>  		}
> +		if (k == current || __kthread_isparked(kthread))
> +			/* The way out */
> +			ret = 0;

And why do we need to restart if __kthread_isparked() is false? In this
case we know that we were woken up by the exiting kthread which won't
park anyway.

Oleg.

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/1] kthread: fix possible infinite wait for parking when kthread exits meanwhile Roman Pen <roman.penyaev@profitbricks.com> - 2016-10-25 13:10 +0200
  Re: [PATCH 1/1] kthread: fix possible infinite wait for parking         when kthread exits meanwhile Oleg Nesterov <oleg@redhat.com> - 2016-10-25 17:20 +0200
    Re: [PATCH 1/1] kthread: fix possible infinite wait for parking when  kthread exits meanwhile Roman Penyaev <roman.penyaev@profitbricks.com> - 2016-10-25 19:40 +0200

csiph-web