examples: add eal cleanup to examples
authorChengchang Tang <tangchengchang@huawei.com>
Thu, 15 Apr 2021 02:26:03 +0000 (10:26 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 21 Apr 2021 18:21:25 +0000 (20:21 +0200)
According to the programming guide, the rte_eal_init should be used pairs
with rte_eal_cleanup.

This patch add rte_eal_cleanup to examples to encourage new users of
DPDK to use it.

Fixes: aec9c13c5257 ("eal: add function to release internal resources")
Fixes: 3d0fad56b74a ("examples/fips_validation: add crypto FIPS application")
Fixes: c8e6ceecebc1 ("examples/ioat: add new sample app for ioat driver")
Fixes: 4ff457986f76 ("examples/l2fwd-event: add default poll mode routines")
Fixes: 08bd1a174461 ("examples/l3fwd-graph: add graph-based l3fwd skeleton")
Fixes: c5eebf85badc ("examples/ntb: add example for NTB")
Fixes: b77f66002812 ("examples/pipeline: add new example application")
Fixes: edbed86d1cc3 ("examples/vdpa: introduce a new sample for vDPA")
Fixes: c19beb3f38cd ("examples/vhost_blk: introduce vhost storage sample")
Fixes: f5188211c721 ("examples/vhost_crypto: add sample application")
Cc: stable@dpdk.org
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
51 files changed:
examples/bbdev_app/main.c
examples/bond/main.c
examples/cmdline/main.c
examples/distributor/main.c
examples/ethtool/ethtool-app/main.c
examples/fips_validation/main.c
examples/flow_classify/flow_classify.c
examples/flow_filtering/main.c
examples/helloworld/main.c
examples/ioat/ioatfwd.c
examples/ip_fragmentation/main.c
examples/ip_reassembly/main.c
examples/ipsec-secgw/ipsec-secgw.c
examples/ipv4_multicast/main.c
examples/kni/main.c
examples/l2fwd-cat/l2fwd-cat.c
examples/l2fwd-crypto/main.c
examples/l2fwd-event/main.c
examples/l2fwd-jobstats/main.c
examples/l2fwd-keepalive/main.c
examples/l2fwd/main.c
examples/l3fwd-acl/main.c
examples/l3fwd-graph/main.c
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/multi_process/client_server_mp/mp_client/client.c
examples/multi_process/client_server_mp/mp_server/main.c
examples/multi_process/simple_mp/main.c
examples/multi_process/symmetric_mp/main.c
examples/ntb/ntb_fwd.c
examples/packet_ordering/main.c
examples/performance-thread/l3fwd-thread/main.c
examples/performance-thread/pthread_shim/main.c
examples/pipeline/main.c
examples/ptpclient/ptpclient.c
examples/qos_meter/main.c
examples/qos_sched/main.c
examples/rxtx_callbacks/main.c
examples/server_node_efd/node/node.c
examples/server_node_efd/server/main.c
examples/service_cores/main.c
examples/skeleton/basicfwd.c
examples/timer/main.c
examples/vdpa/main.c
examples/vhost/main.c
examples/vhost_blk/vhost_blk.c
examples/vhost_crypto/main.c
examples/vm_power_manager/guest_cli/main.c
examples/vm_power_manager/main.c
examples/vmdq/main.c
examples/vmdq_dcb/main.c

index 20cfd32..5251db0 100644 (file)
@@ -1195,5 +1195,8 @@ main(int argc, char **argv)
                ret |= rte_eal_wait_lcore(lcore_id);
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return ret;
 }
index 81a6fa9..f48400e 100644 (file)
@@ -876,5 +876,9 @@ main(int argc, char *argv[])
        prompt(NULL);
 
        rte_delay_ms(100);
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index bb79542..94002f0 100644 (file)
@@ -36,5 +36,8 @@ int main(int argc, char **argv)
        cmdline_interact(cl);
        cmdline_stdin_exit(cl);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index caa7c46..1b10296 100644 (file)
@@ -932,5 +932,8 @@ main(int argc, char *argv[])
        rte_free(pd);
        rte_free(pr);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index c6023a1..21ed85c 100644 (file)
@@ -299,5 +299,8 @@ int main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index b73691d..c175fe6 100644 (file)
@@ -501,6 +501,9 @@ exit:
        fips_test_clear();
        cryptodev_fips_validate_app_uninit();
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return ret;
 
 }
index 335d7d2..5c3e111 100644 (file)
@@ -853,5 +853,8 @@ main(int argc, char *argv[])
        /* Call lcore_main on the main core only. */
        lcore_main(cls_app);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index bc28468..f1940bc 100644 (file)
@@ -258,5 +258,10 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "error in creating flow");
        }
 
-       return main_loop();
+       ret = main_loop();
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
+       return ret;
 }
index 8a4cee6..ac72145 100644 (file)
@@ -43,5 +43,9 @@ main(int argc, char **argv)
        lcore_hello(NULL);
 
        rte_eal_mp_wait_lcore();
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 6502e45..845301a 100644 (file)
@@ -1011,6 +1011,9 @@ main(int argc, char **argv)
                        rte_ring_free(cfg.ports[i].rx_to_tx_ring);
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        printf("Bye...\n");
        return 0;
 }
index 5a96841..77a6a18 100644 (file)
@@ -1075,5 +1075,8 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 954a115..ce8882a 100644 (file)
@@ -1201,5 +1201,8 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 59971dc..a9f9b58 100644 (file)
@@ -3076,6 +3076,9 @@ main(int32_t argc, char **argv)
                rte_eth_dev_close(portid);
                printf(" Done\n");
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
        printf("Bye...\n");
 
        return 0;
index e18726a..fd6207a 100644 (file)
@@ -805,5 +805,8 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index fe93b86..beabb3c 100644 (file)
@@ -1140,5 +1140,8 @@ main(int argc, char** argv)
                        kni_port_params_array[i] = NULL;
                }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 2e632c5..02288a3 100644 (file)
@@ -201,5 +201,8 @@ main(int argc, char *argv[])
        /* Call lcore_main on the main core only. */
        lcore_main();
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index a957df0..4f51616 100644 (file)
@@ -2835,5 +2835,8 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 444ee4e..0acfee4 100644 (file)
@@ -716,6 +716,9 @@ main(int argc, char **argv)
                        printf(" Done\n");
                }
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
        printf("Bye...\n");
 
        return 0;
index 1151769..58a7226 100644 (file)
@@ -1022,5 +1022,8 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index e4c2b27..be66162 100644 (file)
@@ -817,5 +817,9 @@ main(int argc, char **argv)
 
        if (ka_shm != NULL)
                rte_keepalive_shm_cleanup(ka_shm);
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index be5bf7b..32d405e 100644 (file)
@@ -902,6 +902,9 @@ main(int argc, char **argv)
                rte_eth_dev_close(portid);
                printf(" Done\n");
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
        printf("Bye...\n");
 
        return ret;
index 4a17274..a1f457b 100644 (file)
@@ -2258,5 +2258,8 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 127c5e8..75c2e0e 100644 (file)
@@ -1123,6 +1123,9 @@ main(int argc, char **argv)
                rte_eth_dev_close(portid);
                printf(" Done\n");
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
        printf("Bye...\n");
 
        return ret;
index 7441305..4cb800a 100644 (file)
@@ -1405,6 +1405,10 @@ main(int argc, char **argv)
                        printf(" Done\n");
                }
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        printf("Bye...\n");
 
        return ret;
index 8ca3586..d8ff5f1 100644 (file)
@@ -730,5 +730,8 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 361d90b..6d4c246 100644 (file)
@@ -268,4 +268,7 @@ main(int argc, char *argv[])
 
                need_flush = 1;
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
 }
index b18e12d..9bcee46 100644 (file)
@@ -304,5 +304,9 @@ main(int argc, char *argv[])
        rte_eal_mp_remote_launch(sleep_lcore, NULL, SKIP_MAIN);
 
        do_packet_forwarding();
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 109b8bb..a05404f 100644 (file)
@@ -121,5 +121,9 @@ main(int argc, char **argv)
        cmdline_stdin_exit(cl);
 
        rte_eal_mp_wait_lcore();
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index ae7f5e0..79e5c61 100644 (file)
@@ -472,5 +472,8 @@ main(int argc, char **argv)
 
        rte_eal_mp_remote_launch(lcore_main, NULL, CALL_MAIN);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 54b7f08..e9a3887 100644 (file)
@@ -1498,5 +1498,8 @@ main(int argc, char **argv)
                start_pkt_fwd();
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index bcbda05..d2fe9f6 100644 (file)
@@ -783,5 +783,9 @@ main(int argc, char **argv)
        }
 
        print_stats();
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index b16c19b..2f593ab 100644 (file)
@@ -3781,5 +3781,8 @@ main(int argc, char **argv)
                }
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 4ce3622..257de50 100644 (file)
@@ -263,5 +263,9 @@ int main(int argc, char **argv)
        RTE_LCORE_FOREACH_WORKER(lcore_id) {
                rte_eal_wait_lcore(lcore_id);
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index fb57ef3..8ea19f9 100644 (file)
@@ -190,4 +190,7 @@ main(int argc, char **argv)
 
                conn_poll_for_msg(conn);
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
 }
index 878d1a0..173451e 100644 (file)
@@ -784,5 +784,8 @@ main(int argc, char *argv[])
        /* Call lcore_main on the main core only. */
        lcore_main();
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index f2d9c28..6e724f3 100644 (file)
@@ -460,5 +460,8 @@ main(int argc, char **argv)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index a6071b9..dc6a17a 100644 (file)
@@ -218,5 +218,8 @@ main(int argc, char **argv)
                }
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 35c6c39..b57b2fc 100644 (file)
@@ -338,5 +338,9 @@ main(int argc, char *argv[])
 
        /* call lcore_main on main core only */
        lcore_main();
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 67a5580..e68606e 100644 (file)
@@ -383,4 +383,7 @@ main(int argc, char *argv[])
 
                need_flush = 1;
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
 }
index 4728960..39b7b63 100644 (file)
@@ -334,5 +334,9 @@ main(int argc, char *argv[])
        rte_eal_mp_remote_launch(sleep_lcore, NULL, SKIP_MAIN);
 
        do_packet_forwarding();
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 0b3d8c8..2b57a52 100644 (file)
@@ -220,5 +220,8 @@ main(int argc, char **argv)
                        i = 0;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 4b2b6ab..a31b288 100644 (file)
@@ -205,5 +205,8 @@ main(int argc, char *argv[])
        /* Call lcore_main on the main core only. */
        lcore_main();
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 5a57e48..d67301e 100644 (file)
@@ -117,5 +117,8 @@ main(int argc, char **argv)
        /* call it on main lcore too */
        (void) lcore_mainloop(NULL);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 97e967b..097a267 100644 (file)
@@ -576,5 +576,8 @@ main(int argc, char *argv[])
                vdpa_sample_quit();
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 2ca7d98..ff48ba2 100644 (file)
@@ -1781,6 +1781,8 @@ main(int argc, char *argv[])
        RTE_LCORE_FOREACH_WORKER(lcore_id)
                rte_eal_wait_lcore(lcore_id);
 
-       return 0;
+       /* clean up the EAL */
+       rte_eal_cleanup();
 
+       return 0;
 }
index 54f81b3..fe2b4e4 100644 (file)
@@ -907,5 +907,8 @@ int main(int argc, char *argv[])
        while (1)
                sleep(1);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 7ed38fe..dea7dcb 100644 (file)
@@ -469,6 +469,9 @@ free_resource(void)
        }
 
        memset(&options, 0, sizeof(options));
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
 }
 
 int
index 4e17f7f..b8fa65e 100644 (file)
@@ -200,5 +200,8 @@ main(int argc, char **argv)
        }
        run_cli(NULL);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 799d7b9..7d5bf68 100644 (file)
@@ -468,5 +468,8 @@ main(int argc, char **argv)
 
        free(ci->cd);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 3cb890f..a19f7db 100644 (file)
@@ -659,5 +659,8 @@ main(int argc, char *argv[])
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }
index 1a74364..ba99280 100644 (file)
@@ -707,5 +707,8 @@ main(int argc, char *argv[])
        /* call on main too */
        (void) lcore_main((void*)i);
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }