cocalele / PureFlash

A ServerSAN storage system designed for flash device
GNU General Public License v3.0
101 stars 29 forks source link

abuse of spinlock #22

Closed cocalele closed 2 months ago

cocalele commented 1 year ago

Too many spinlocks, 1) in PfFixedSizeQueue , there's spinlock protected. 2) in PfEventQueue, there's also a spinlock.

each time post_event is called, the two spinlock will be both acquired.

int PfEventQueue::post_event(int type, int arg_i, void* arg_p, void* arg_q)
{
    //S5LOG_INFO("post_event %s into:%s", EventTypeToStr((S5EventType)type), name);
    {
        AutoSpinLock _l(&lock);
        int rc = current_queue->enqueue(S5Event{ type, arg_i, arg_p , arg_q});
        if(rc)
            return rc;
    }
    write(event_fd, &event_delta, sizeof(event_delta));
    return 0;
}
cocalele commented 1 year ago
    U* alloc() {
        AutoSpinLock _l(&lock);
        if (free_obj_queue.is_empty())
            return NULL;
        return free_obj_queue.dequeue(); //TODO: double locked here!!
    }
cocalele commented 2 months ago

Has fixed in commit bb78c76d