On Mon, 24 Apr 2023 13:02:05 +0000 Chengwen Feng <fengcheng...@huawei.com> wrote:
> This patchset introduces the coroutine library which will help refactor > the hns3 PMD's reset process. > > The hns3 single function reset process consists of the following steps: > 1.stop_service(); > 2.prepare_reset(); > 3.delay(100ms); > 4.notify_hw(); > 5.wait_hw_reset_done(); // multiple sleep waits are involved. > 6.reinit(); > 7.restore_conf(); > > If the DPDK process take over multiple hns3 functions (e.g. 100), > it's impractical to reset and restore functions in sequence: > 1.proc_func(001); // will completed in 100+ms range. > 2.proc_func(002); // will completed in 100~200+ms range. > ... > x.proc_func(100); // will completed in 9900~10000+ms range. > The later functions will process fail because it's too late to deal with. > > One solution is that create a reset thread for each function, and it > will lead to large number of threads if the DPDK process take over > multiple hns3 functions. > > So the current hns3 driver uses asynchronous mechanism, for examples, it > use rte_eal_alarm_set() when process delay(100ms), it splits a serial > process into multiple asynchronous processes, and the code is complex > and difficult to understand. > > The coroutine is a good mechanism to provide programmers with the > simplicity of keeping serial processes within a limited number of > threads. > > This patchset use <ucontext.h> to build the coroutine framework, and it > just provides a demo. More APIs maybe added in the future. > > In addition, we would like to ask the community whether it it possible > to accept the library. If not, whether it is allowed to provide the > library in hns3 PMD. > > Chengwen Feng (3): > lib/coroutine: add coroutine library > examples/coroutine: support coroutine examples > net/hns3: refactor reset process with coroutine Interesting, but the DPDK really is not the right place for this. Also, why so much sleeping. Can't this device be handled with an event based model. Plus any complexity like this introduces more bugs into already fragile interaction of DPDK userspace applications and threads. Not only that, coroutines add to the pre-existing problems with locking. If coroutine 1 acquires a lock, the coroutine 2 will deadlock itself. And someone will spend days figuring that out. And the existing analyzer tools will not know about the magic coroutine library. Bottom line: please no