Re: please revert kthread from loop.c

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

 



Quoting Andrew Morton ([email protected]):
> "Serge E. Hallyn" <[email protected]> wrote:
> >
> > Convert loop.c from the deprecated kernel_thread to kthread.
> >
> 
> I think you have a racelet here:
> 
> > +		}
> >  		spin_unlock_irq(&lo->lo_lock);
> >  
> > -		BUG_ON(!bio);
> > -		loop_handle_bio(lo, bio);
> > -
> > -		/*
> > -		 * upped both for pending work and tear-down, lo_pending
> > -		 * will hit zero then
> > -		 */
> > -		if (unlikely(!pending))
> > -			break;
> > +		__set_current_state(TASK_INTERRUPTIBLE);
> > +		schedule();
> >  	}
> >  
> > -	complete(&lo->lo_done);
> >  	return 0;
> >  }
> 
> 
> :		if (kthread_should_stop()) {
> :			spin_unlock_irq(&lo->lo_lock);
> :			break;
> :		}
> :		spin_unlock_irq(&lo->lo_lock);
> :
> :		__set_current_state(TASK_INTERRUPTIBLE);
> :		schedule();
> :
> 
> If the wake_up_process() is delivered before the __set_current_state(),
> we'll miss the wakeup.

Makes sense, and the patched kernel passes the parallel tests.

Thanks for the patch.

> If so, this should plug it.  The same race is not possible against the
> loop_set_fd() wakeup because the thread isn't running at that stage, yes?

Right, it's not yet running at loop_set_fd().  However what about
kthread_stop() called from loop_clr_fd()?  Unfortunately fixing
that seems hairy.  Need to think about it...

thanks,
-serge
-
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