Re: [PATCH 02/12] DRBD: activity_log

From: Andi Kleen
Date: Wed Mar 25 2009 - 06:45:51 EST


On Wed, Mar 25, 2009 at 11:27:22AM +0100, Philipp Reisner wrote:
> md_io_page gets allocated with GFP_KERNEL (no GFP_HIGHMEM either).
>
>
> [...]
> > > +
> > > + spin_lock_irq(&mdev->al_lock);
> > > + lc_changed(mdev->act_log, al_ext);
> > > + spin_unlock_irq(&mdev->al_lock);
> > > + wake_up(&mdev->al_wait);
> >
> > The wake_up outside the lock looks a little dangerous.
> >
>
> Please share you thoughts, why this looks a little dangerous ?

I haven't double checked the whole path, but unlocked wake up
is often a good recipe to potentially lose wake ups.

> [...]
> > > + mutex_lock(&mdev->md_io_mutex); /* protects md_io_buffer, al_tr_cycle,
> > > ... */
> >
> > Doing checksumming inside a lock looks nasty.
> >
>
> Well, that is a mutex, not a spinlock. We need to hold that lock here,

Yes it's independent. If it takes a lot of CPU time you'll likely have
a bottle neck. It's normally a bad idea to do anything CPU intensive
under a lock covering more than your current limited object.

-Andi

--
ak@xxxxxxxxxxxxxxx -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/