[SPDK] Re: How to fix the error generated while generating SPDK thread

Walker, Benjamin <benjamin.walker at intel.com>
Newsgroups dev.linux.lists.spdk
Message-ID <37B08312E007AE46A00101F43DA919DD011E1445EB@FMSMSX105.amr.corp.intel.com>
> -----Original Message-----
> From: Zawadzki, Tomasz <tomasz.zawadzki(a)intel.com>
> Sent: Monday, May 4, 2020 4:39 AM
> To: Storage Performance Development Kit <spdk(a)lists.01.org>
> Subject: [SPDK] Re: How to fix the error generated while generating SPDK thread
> 
> Hi,
> 
> There is bit more setup needed to be done in order to use spdk_threads, at least
> spdk_thread_lib_init() is needed.
> Even tough bit complex, the nvmf example might be good one for that. Please
> see:
> nvmf_init_threads() in examples/nvmf/nvmf/nvmf.c
> 
> Note: Depending on the goal, Application Framework could be used to simplify
> the process of preparing the environment.
> https://spdk.io/doc/event.html
> 
> Thanks,
> Tomek
> 
> > -----Original Message-----
> > From: mostaan.fereidooni(a)gmail.com <mostaan.fereidooni(a)gmail.com>
> > Sent: Monday, May 4, 2020 12:48 PM
> > To: spdk(a)lists.01.org
> > Subject: [SPDK] How to fix the error generated while generating SPDK
> > thread
> >
> > Hello I am new with SPDK and have done all the steps mentioned in the
> > https://spdk.io/doc/getting_started.html completely and without
> > observing any errors.
> >
> > But when I run the following simple code on my system #include
> > <stdio.h> #include <spdk/bdev.h> #include <spdk/thread.h> #include
> > <spdk/queue.h>
> >
> > void main()
> > {
> >
> >     struct spdk_thread* first_reader_thread =
> >             spdk_thread_create("first_reader_thread", NULL);
> >
> >     if (first_reader_thread == NULL)
> >     {
> >         printf("First thread creation failed...\n");
> >         return ;
> >     }
> >
> >     struct spdk_thread* second_reader_thread =
> >             spdk_thread_create("second_reader_thread", NULL);
> >     if (second_reader_thread == NULL)
> >     {
> >         printf("Second thread creation failed...\n");
> >         return ;
> >     }
> >
> >     printf("first reader thread id is: %"PRIu64"\n",
> >            spdk_thread_get_id(first_reader_thread));
> >     printf("second reader thread id is: %"PRIu64"\n",
> >            spdk_thread_get_id(second_reader_thread));
> >     printf("Hello World!\n");
> >     return;
> > }
> >
> > I get the following error:
> >
> > "RING: Cannot reserve memory for tailq,
> > thread.c: 260:spdk_thread_create: ERROR: Unable to allocate memory for
> > message ring, First thread creation failed..."
> >
> > it will be appraciated if anyone can guide me to fix this error.

As Tomek mentioned, SPDK is broken up into various "layers", where each layer you move up handles more of the application logic for you, but also gives you less control. The breakdown is rough like this:

1) Lowest level libraries - the drivers and utility code. This includes things like lib/nvme. These don't depend on any particular threading model or really anything else.
2) Lightweight-threaded libraries. Most of the code in SPDK falls into this category. They're libraries you can link into your application, but they depend on the SPDK lightweight threading library. The interface for that is in include/spdk/thread.h, and to use it you must call spdk_thread_lib_init from your application and implement the function pointer callbacks it requires. This seems to be the layer your code is trying to leverage.
3) SPDK's full application framework. This is in include/spdk/event.h. If you use this, you make calls like spdk_app_start() and SPDK sets everything up for you, using a threading model that it has determined is optimal. This is mostly intended to be used from the applications that SPDK ships as part of its release, rather than from third party applications. But it's available to everyone if they have a use for it.

Thanks,
Ben


> > _______________________________________________
> > 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
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.