Content-Type: multipart/mixed; boundary="===============4698326989388716313==" MIME-Version: 1.0 From: Sunshihao (Euler OS) Subject: =?utf-8?q?=5BSPDK=5D_=E7=AD=94=E5=A4=8D=3A_Re=3A_thread-=3Emsg=5Fcache_is?= =?utf-8?q?_not_safe_when_multiple_threads_send_messages_to_same_spdk=5Fth?= =?utf-8?q?read?= Date: Wed, 16 Sep 2020 02:07:44 +0000 Message-ID: In-Reply-To: D70225EA-E2B0-4846-8B58-CD8D007A66A6@intel.com List-ID: To: spdk@lists.01.org --===============4698326989388716313== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Dear maintainer Jim, thank you for your reply. After reading your email, I know I have used the wrong way to submiting io. When I create a thread to submit io, I don't create spdk_thread structure f= or the thread, this structure only be created in spdk_reactors_start api fo= r every lcore; Must I create spdk_thread structure for every submit thread? Please give me some advice, thank you! -----=E9=82=AE=E4=BB=B6=E5=8E=9F=E4=BB=B6----- =E5=8F=91=E4=BB=B6=E4=BA=BA: Harris, James R [mailto:james.r.harris(a)intel= .com] = =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2020=E5=B9=B49=E6=9C=8816=E6=97=A5 3:= 32 =E6=94=B6=E4=BB=B6=E4=BA=BA: Storage Performance Development Kit =E4=B8=BB=E9=A2=98: [SPDK] Re: thread->msg_cache is not safe when multiple = threads send messages to same spdk_thread 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 t= hreads call spdk_thread_send_msg() in parallel, they will each use their ow= n thread-local spdk_thread structure and no lock or synchronization is need= ed. -Jim =EF=BB=BFOn 9/15/20, 6:33 AM, "sunshihao(a)huawei.com" wrote: hello=EF=BC=8Cmaintainer=EF=BC=9A when i use spdk api spdk_thread_send_msg to send io read/write msg=EF= =BC=8Ci found a bug=EF=BC=9A multiple threads send msg to one spdk_thread=EF=BC=8Cthey may get msg f= orm local_thread->msg_cache=EF=BC=8Cthere is not a lock or cas to = ensure the safety of the linked list=E3=80=82 = msg =3D NULL; if (local_thread !=3D NULL) { if (local_thread->msg_cache_count > 0) { msg =3D SLIST_FIRST(&local_thread->msg_cache); /* here maybe not= thread safe */ assert(msg !=3D 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 th= e list is not safe=EF=BC=8Cso please give me some advice=E3=80=82 Thank you=EF=BC=81 _______________________________________________ SPDK mailing list -- spdk(a)lists.01.org To unsubscribe send an email to spdk-leave(a)lists.01.org _______________________________________________ SPDK mailing list -- spdk(a)lists.01.org To unsubscribe send an email to spdk-leave(a)lists.01.org --===============4698326989388716313==--