Re: [PATCH 04/15] ps3vram: Replace mutex by spinlock + list
From: Geert Uytterhoeven <hidden>
Date: 2009-05-11 06:38:20
Also in:
lkml
On Fri, 8 May 2009, Andrew Morton wrote:
On Fri, 8 May 2009 16:01:13 +0200 Geert Uytterhoeven [off-list ref] wrote:quoted
+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;
^^^^^^^^
quoted
+ } + + 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@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