Re: [PATCH v3 1/1] media: vivid: Fix wrong locking that causes race conditions on streaming stop

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

 



On Sat, Nov 2, 2019 at 12:03 PM Alexander Popov <alex.popov@xxxxxxxxx> wrote:
>
> -               mutex_lock(&dev->mutex);
> +               if (!mutex_trylock(&dev->mutex)) {
> +                       schedule_timeout(1);
> +                       continue;
> +               }
> +

I just realized that this too is wrong. It _works_, but because it
doesn't actually set the task state to anything particular before
scheduling, it's basically pointless. It calls the scheduler, but it
won't delay anything, because the task stays runnable.

So what you presumably want to use is either "cond_resched()" (to make
sure others get to run with no delay) or
"schedule_timeout_uninterruptible(1)" which actually sets the process
state to TASK_UNINTERRUPTIBLE.

The above works, but it's basically nonsensical. My bad for not
noticing earlier.

               Linus



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux