[SPDK] Re: thread->msg_cache is not safe when multiple threads send messages to same spdk_thread

Harris, James R <james.r.harris at intel.com>
Newsgroups dev.linux.lists.spdk
Message-ID <[email protected]>
Hi,

local_thread gets its value from _get_thread().  _get_thread() returns the thread-local spdk_thread structure for the calling thread. So if multiple threads call spdk_thread_send_msg() in parallel, they will each use their own thread-local spdk_thread structure and no lock or synchronization is needed.

-Jim

On 9/15/20, 6:33 AM, "sunshihao(a)huawei.com" <sunshihao(a)huawei.com> wrote:

    hello,maintainer:
    when i use spdk api spdk_thread_send_msg to send io read/write msg,i found a bug:
    multiple threads send msg to one spdk_thread,they may get msg form local_thread->msg_cache,there is not a lock or cas to 
    ensure the safety of the linked list。 

             msg = NULL;

    	if (local_thread != NULL) {
    		if (local_thread->msg_cache_count > 0) {
    				msg = SLIST_FIRST(&local_thread->msg_cache);    /* here maybe not thread safe */
    				assert(msg != NULL);
    				SLIST_REMOVE_HEAD(&local_thread->msg_cache, link);
    				local_thread->msg_cache_count--;
    		}
    	}

    i don't konw whether is my wrong way to use spdk_thread_send_msg  or the list is not safe,so please give me some advice。
    Thank you!
    _______________________________________________
    SPDK mailing list -- spdk(a)lists.01.org
    To unsubscribe send an email to spdk-leave(a)lists.01.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.