On 06/08, Nicholas A. Bellinger wrote: > > +unsigned tag_alloc(struct tag_pool *pool, bool wait) > +{ > + struct tag_cpu_freelist *tags; > + unsigned long flags; > + unsigned ret; > +retry: > + preempt_disable(); > + local_irq_save(flags); > + tags = this_cpu_ptr(pool->tag_cpu); > + > + while (!tags->nr_free) { > + spin_lock(&pool->lock); > + > + if (pool->nr_free) > + move_tags(tags->free, &tags->nr_free, > + pool->free, &pool->nr_free, > + min(pool->nr_free, pool->watermark)); > + else if (wait) { > + struct tag_waiter wait = { .task = current }; > + > + __set_current_state(TASK_UNINTERRUPTIBLE); > + list_add(&wait.list, &pool->wait); > + > + spin_unlock(&pool->lock); > + local_irq_restore(flags); > + preempt_enable(); > + > + schedule(); > + > + if (!list_empty_careful(&wait.list)) { > + spin_lock_irqsave(&pool->lock, flags); > + list_del_init(&wait.list); > + spin_unlock_irqrestore(&pool->lock, flags); > + } > + > + goto retry; > + } else > + goto fail; > + > + spin_unlock(&pool->lock); > + } > + > + ret = tags->free[--tags->nr_free]; > + > + local_irq_restore(flags); > + preempt_enable(); > + > + return ret; > +fail: > + local_irq_restore(flags); > + preempt_enable(); > + return 0; > +} I still think this code should use the normal wait_event(). See http://marc.info/?l=linux-kernel&m=136863269729888 > +void tag_free(struct tag_pool *pool, unsigned tag) > +{ > + struct tag_cpu_freelist *tags; > + unsigned long flags; > + > + preempt_disable(); > + local_irq_save(flags); > + tags = this_cpu_ptr(pool->tag_cpu); > + > + tags->free[tags->nr_free++] = tag; > + > + if (tags->nr_free == pool->watermark * 2) { > + spin_lock(&pool->lock); > + > + move_tags(pool->free, &pool->nr_free, > + tags->free, &tags->nr_free, > + pool->watermark); > + > + while (!list_empty(&pool->wait)) { > + struct tag_waiter *wait; > + wait = list_first_entry(&pool->wait, > + struct tag_waiter, list); > + list_del_init(&wait->list); > + wake_up_process(wait->task); And this still looks racy. see http://marc.info/?l=linux-kernel&m=136853955229504 And probably the changelog should mention that cpu_down() can lose the tags. Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html