Short answer: yes. Here's an example of how to start a foreign thread taken
from the [golang dialect] g2 viewer plugin (*):
/* *INDENT-OFF* */
VLIB_REGISTER_THREAD (ego_g2_thread_reg, static) = {
.name = "g2-thread",
.short_name = "g2",
.function = ego_g2_thread_fn,
.use_pthreads = 1,
.no_data_structure_clone = 1,
.fixed_count = 1,
.count = 1,
};
/* *INDENT-ON* */
In this case, we don't clone the required data structures to free a buffer.
If you remove the initialization ".no_data_structure_clone=1", you should be
all set. Check out ".use_pthreads = 1" in src/vlib/threads.c, etc. to see if
that's what you want.
HTH... Dave
(*) See https://github.com/dbarach/vpp-event-viewer.git if you're interested
in the g2 viewer.
From: vpp-dev@lists.fd.io On Behalf Of Simon Barber
via lists.fd.io
Sent: Friday, August 12, 2022 9:30 AM
To: vpp-dev@lists.fd.io
Subject: Re: [vpp-dev] Free a vlib buffer from out a VPP worker thread
Dave,
Does VPP support the concept of additional threads that are spawned from
within a plugin, lets call them 'external threads', and the allocation
of a vlib_main_t / vlib_buffer_pool_thread_t for these external threads, or
should all interactions such as freeing a buffer, be performed from within
the worker thread that the buffer was originally presented to the plugin
on..
Cheers
Simon
From: vpp-dev@lists.fd.io <mailto:vpp-dev@lists.fd.io> mailto:vpp-dev@lists.fd.io> > On Behalf Of Dave Barach via lists.fd.io
Sent: Thursday, August 11, 2022 12:07 PM
To: vpp-dev@lists.fd.io <mailto:vpp-dev@lists.fd.io>
Subject: [EXTERNAL] Re: [vpp-dev] Free from a vlib buffer from out a VPP
worker thread
You don't often get email from vpp=barachs@lists.fd.io
<mailto:vpp=barachs@lists.fd.io> . Learn why this is important
<https://aka.ms/LearnAboutSenderIdentification>
As long as the thread has an associated vlib_main_t /
vlib_buffer_pool_thread_t not accidentally shared with another thread, you
shouldn't have any problems...
FWIW... Dave
From: vpp-dev@lists.fd.io <mailto:vpp-dev@lists.fd.io> mailto:vpp-dev@lists.fd.io> > On Behalf Of Simon Barber via lists.fd.io
Sent: Thursday, August 11, 2022 6:42 AM
To: vpp-dev@lists.fd.io <mailto:vpp-dev@lists.fd.io>
Subject: [vpp-dev] Free from a vlib buffer from out a VPP worker thread
Hi,
Does anybody anticipate any issues calling vlib_buffer_free_one to free a
buffer when running on a thread that is not registered as a VPP worker
thread.
Initial testing indicates that it works.
Regards
Simon
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#21798): https://lists.fd.io/g/vpp-dev/message/21798
Mute This Topic: https://lists.fd.io/mt/92979452/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/leave/1480452/21656/631435203/xyzzy
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-