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 4E545A0093; Sat, 21 May 2022 12:01:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2A57640156; Sat, 21 May 2022 12:01:01 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id A083D40040 for ; Sat, 21 May 2022 12:00:59 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4L4zb85b61z1JBwT; Sat, 21 May 2022 17:59:32 +0800 (CST) Received: from [127.0.0.1] (10.67.100.224) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 21 May 2022 18:00:57 +0800 Subject: Re: [PATCH] app/testpmd: remove invalid ports when other process detach To: Ferruh Yigit , Thomas Monjalon CC: , , , , Andrew Rybchenko References: <20220302023326.16509-1-fengchengwen@huawei.com> <5569707.V25eIC5XRa@thomas> <31263d7d-b880-ff29-70d9-2a8f75b0bb45@huawei.com> <80bdb6d3-8259-80b1-3733-ef19b6b4f840@amd.com> From: fengchengwen Message-ID: Date: Sat, 21 May 2022 18:00:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <80bdb6d3-8259-80b1-3733-ef19b6b4f840@amd.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected 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 Hi Ferruh, On 2022/5/20 23:05, Ferruh Yigit wrote: > On 3/2/2022 8:36 AM, fengchengwen wrote: >> On 2022/3/2 16:26, Thomas Monjalon wrote: >>> 02/03/2022 03:33, Chengwen Feng: >>>> Start main and secondary process: >>>> ./dpdk-testpmd -a BDF0 -a BDF1 --proc-type=auto -- -i --rxq=8 --txq=8 >>>>     --num-procs=2 --proc-id=0 >>>> ./dpdk-testpmd -a BDF0 -a BDF1 --proc-type=auto -- -i --rxq=8 --txq=8 >>>>     --num-procs=2 --proc-id=1 >>>> Execute following command in main process: >>>>     port stop 0 >>>>     port detach 0 >>>> Execute following command in secondary process: >>>>     set fwd mac >>>>     start >>>> The secondary process will display: >>>>     Invalid port_id=0 >>>>     telcore 19 called rx_pkt_burst for not ready port 0 >>>>     stpmd> 8: [/lib64/libc.so.6(+0xdf600) [0xffff9e1dc600]] >>>>     7: [/lib64/libpthread.so.0(+0x7c48) [0xffff9e28ac48]] >>>>     6: [/usr/app/testpmd(eal_thread_loop+0x2c4) [0xb23574]] >>>>     5: [/usr/app/testpmd() [0x9c21d8]] >>>>     4: [/usr/app/testpmd() [0x9c2108]] >>>>     3: [/usr/app/testpmd() [0x9b6cf0]] >>>>     2: [/usr/app/testpmd() [0xad8620]] >>>>     1: [/usr/app/testpmd(rte_dump_stack+0x20) [0xb1a130]] >>>> >>>> The root cause it that the secondary process has not removed invalid >>>> ports when it processes RTE_ETH_EVENT_DESTROY event. >>> >>> Why the ports are not removed? >> > > It is referring to application (testpmd) level state, ethdev port is removed. > > Above mentioned problem is valid since testpmd secondary process support is added. > When primary hot remove a device, it updates relevant application state too, but for secondary process ethdev removes device without secondary process updating its state. > > I agree that using ethdev events is appropriate for this case, since action originated from ethdev for secondary process, need a way to notify application about it. > Another option can be checking and removing invalid ports in secondary before each forwarding start, but since we already have an event for destroy, using it looks good to me. > > >> Testpmd register function eth_event_callback to deal with DESTROY event, >> currently it only assign ports[port_id].port_status with RTE_PORT_CLOSED, it >> doesn't update other global variables like nb_ports. >> >>> >>>> This patch adds a delay remove invalid ports invoke when process the >>>> RTE_ETH_EVENT_DESTROY event. >>> >>> Why do we need this delay? >> >> The remove_invalid_ports will scan rte_eth_devices[], when process the DESTROY >> event, the rte_eth_devices[x] still valid, so here we should a delay logic. >> > > There is a dependency problem in the DESTROY event. > > We need some ethdev information to be able to deliver the event, so ethdev can't be completely destroyed until DESTROY event is processed. Which means when application received DESTROY event, ethdev is not fully destroyed yet. > > Except from above, 'remove_invalid_ports()' is called twice for primary process (as mentioned in commit log), this timer can be helping these two calls not conflict, but I am not sure if we can rely on a time for this. > Since the problem is mainly for secondary process, assuming control commands like detaching a device will be called by primary process, so @Feng what do you think about adding a secondary process check to in the 'remove_invalid_ports_callback()' call? So 'remove_invalid_ports()' is called only once for primary process. If we execute following command in secondary process: port stop 0 port detach 0 And execute following command in main process: set fwd mac start The main process also show the same error. So I think we should keep it. > >>> >>> [...] >>>> +static void >>>> +remove_invalid_ports_callback(void *arg) >>>> +{ >>>> +    RTE_SET_USED(arg); >>>> +    remove_invalid_ports(); >>>> +} >>> [...] >>>>       case RTE_ETH_EVENT_DESTROY: >>>>           ports[port_id].port_status = RTE_PORT_CLOSED; >>>>           printf("Port %u is closed\n", port_id); >>>> +        if (rte_eal_alarm_set(100000, remove_invalid_ports_callback, >>>> +                (void *)(intptr_t)port_id)) >>>> +            fprintf(stderr, >>>> +                "Could not set up deferred device released\n"); >>>>           break; >>> >>> >>> >>> >>> . >>> >> > > > .