From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91988429E9; Tue, 25 Apr 2023 11:27:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 27EF240ED6; Tue, 25 Apr 2023 11:27:37 +0200 (CEST) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id D077240395 for ; Tue, 25 Apr 2023 11:27:35 +0200 (CEST) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 4357916586 for ; Tue, 25 Apr 2023 11:27:35 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 41FD416235; Tue, 25 Apr 2023 11:27:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on hermod.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=ALL_TRUSTED, AWL, NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.6 X-Spam-Score: -2.2 Received: from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 0CF2A161D1; Tue, 25 Apr 2023 11:27:32 +0200 (CEST) Message-ID: Date: Tue, 25 Apr 2023 11:27:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC 0/3] introduce coroutine library Content-Language: en-US To: Chengwen Feng , thomas@monjalon.net, ferruh.yigit@amd.com Cc: dev@dpdk.org References: <20230424130208.9517-1-fengchengwen@huawei.com> From: =?UTF-8?Q?Mattias_R=c3=b6nnblom?= In-Reply-To: <20230424130208.9517-1-fengchengwen@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2023-04-24 15:02, Chengwen Feng 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. > Coroutines (or anything with a stack, really) are generally too slow as a vehicle for concurrency in data plane applications, I would argue. They might help you solve this particular slow path task, but that alone doesn't seem like anything close to a rationale why a new concurrency library should be accepted. DPDK does need a deferred work mechanism, but I don't think coroutines are the answer. Currently, RTE timer is the closest thing you have in DPDK. To solve your issue (and many other, including things in the fast path), I would rather look in that direction, maybe extending to something Linux' tasklets. > This patchset use 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 > > drivers/net/hns3/hns3_ethdev.c | 217 ++++++++++++++++++++++++++++++ > drivers/net/hns3/hns3_ethdev.h | 3 + > drivers/net/hns3/hns3_intr.c | 38 ++++++ > drivers/net/hns3/meson.build | 2 +- > examples/coroutine/main.c | 153 +++++++++++++++++++++ > examples/coroutine/meson.build | 10 ++ > examples/meson.build | 1 + > lib/coroutine/meson.build | 8 ++ > lib/coroutine/rte_coroutine.c | 190 ++++++++++++++++++++++++++ > lib/coroutine/rte_coroutine.h | 110 +++++++++++++++ > lib/coroutine/rte_coroutine_imp.h | 46 +++++++ > lib/coroutine/version.map | 11 ++ > lib/meson.build | 1 + > 13 files changed, 789 insertions(+), 1 deletion(-) > create mode 100644 examples/coroutine/main.c > create mode 100644 examples/coroutine/meson.build > create mode 100644 lib/coroutine/meson.build > create mode 100644 lib/coroutine/rte_coroutine.c > create mode 100644 lib/coroutine/rte_coroutine.h > create mode 100644 lib/coroutine/rte_coroutine_imp.h > create mode 100644 lib/coroutine/version.map >