lkml.org 
[lkml]   [2008]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] Exiting queue and task might race to free cic
Date
Hi Jens

On Thursday 20 November 2008 10:27:06 Nikanth Karthikesan wrote:
> On Wednesday 19 November 2008 19:45:31 Jens Axboe wrote:
> > On Wed, Nov 19 2008, Nikanth Karthikesan wrote:
> >
> > Not sure this is enough, we probably need to copy the key to ensure that
> > we get a fresh value. How does this look?
>
> Agreed. Read barrier required. But the compiler hint, "likely" can stay?
>
> diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
> index 6a062ee..4504b94 100644
> --- a/block/cfq-iosched.c
> +++ b/block/cfq-iosched.c
> @@ -1318,7 +1318,15 @@ static void cfq_exit_single_io_context(struct
> io_context *ioc,
> unsigned long flags;
>
> spin_lock_irqsave(q->queue_lock, flags);
> - __cfq_exit_single_io_context(cfqd, cic);
> +
> + /*
> + * Ensure we get a fresh copy of the ->key to prevent
> + * race between exiting task and queue
> + */
> + smp_read_barrier_depends();
> + if (likely(cic->key))
> + __cfq_exit_single_io_context(cfqd, cic);
> +
> spin_unlock_irqrestore(q->queue_lock, flags);
> }
> }
>
> > Did you actually trigger this, or is it just from code inspection?
>
> No. But I am looking at another bug report on Suse Kernel where the bug is
> triggered during reboot when the kernel thread usb_stor_scan_thread exits.
>

This patch seems to solve the above said bug report on Suse kernel. So, yes it
is reproducible! Can this be merged?

Thanks
Nikanth



\
 
 \ /
  Last update: 2008-11-22 08:19    [from the cache]
©2003-2011 Jasper Spaans. Advertise on this site