[Cbe-oss-dev] [PATCH 04/15] ps3vram: Replace mutex by spinlock + list

Geert Uytterhoeven Geert.Uytterhoeven at sonycom.com
Mon May 11 16:38:06 EST 2009


On Fri, 8 May 2009, Andrew Morton wrote:
> On Fri,  8 May 2009 16:01:13 +0200
> Geert Uytterhoeven <Geert.Uytterhoeven at sonycom.com> wrote:
> 
> > +static int ps3vram_make_request(struct request_queue *q, struct bio *bio)
> > +{
> > +	struct ps3_system_bus_device *dev = q->queuedata;
> > +	struct ps3vram_priv *priv = dev->core.driver_data;
> > +
> > +	dev_dbg(&dev->core, "%s\n", __func__);
> > +
> > +	spin_lock_irq(&priv->lock);
> > +	if (priv->tail) {
> > +		priv->tail->bi_next = bio;
> > +		priv->tail = bio;
> > +		spin_unlock_irq(&priv->lock);
> > +		return 0;
                ^^^^^^^^
> > +	}
> > +
> > +	priv->tail = bio;
> > +	spin_unlock_irq(&priv->lock);
> > +
> > +	do {
> > +		bio = ps3vram_do_bio(dev, bio);
> > +	} while (bio);
> 
> Is there something which prevents two threads of control from walking
> the same list at the same time?

Sure: only the thread who adds the first request to the empty list will walk
the list later.

With kind regards,

Geert Uytterhoeven
Software Architect
Techsoft Centre

Technology and Software Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   Geert.Uytterhoeven at sonycom.com
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010



More information about the cbe-oss-dev mailing list