From cdeddee7c6763f51eaa6e1ff46795ca0ad8ece83 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 12 Oct 2018 21:17:19 +0300 Subject: [PATCH] net: Set names for threads used by the network subsys/libs Previously, these either used generic names like "workqueue" (so, it wasn't possible to distiguish tx and rx workqueues) or didn't set for net management thread. Here's an example of thread dump in a typical system (using stack_analyze() call): rx_workq (real size 4092): unused 3696 usage 396 / 4092 (9 %) tx_workq (real size 4092): unused 3692 usage 400 / 4092 (9 %) net_mgmt (real size 4092): unused 3772 usage 320 / 4092 (7 %) sysworkq (real size 4092): unused 3512 usage 580 / 4092 (14 %) idle (real size 252): unused 64 usage 188 / 252 (74 %) main (real size 4732): unused 3672 usage 1060 / 4732 (22 %) Signed-off-by: Paul Sokolovsky --- subsys/net/ip/net_if.c | 1 + subsys/net/ip/net_mgmt.c | 1 + subsys/net/ip/net_tc.c | 2 ++ subsys/net/l2/ethernet/gptp/gptp.c | 1 + subsys/net/l2/openthread/openthread.c | 1 + subsys/net/lib/lwm2m/lwm2m_engine.c | 2 ++ 6 files changed, 8 insertions(+) diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index 0e975200a4b..f1bd84be911 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -2957,6 +2957,7 @@ void net_if_init(void) K_THREAD_STACK_SIZEOF(tx_ts_stack), (k_thread_entry_t)net_tx_ts_thread, NULL, NULL, NULL, K_PRIO_COOP(1), 0, 0); + k_thread_name_set(&tx_thread_ts, "tx_tstamp"); #endif /* CONFIG_NET_PKT_TIMESTAMP */ #if defined(CONFIG_NET_VLAN) diff --git a/subsys/net/ip/net_mgmt.c b/subsys/net/ip/net_mgmt.c index 481c2733ecc..012c8ee9690 100644 --- a/subsys/net/ip/net_mgmt.c +++ b/subsys/net/ip/net_mgmt.c @@ -381,6 +381,7 @@ void net_mgmt_event_init(void) K_THREAD_STACK_SIZEOF(mgmt_stack), (k_thread_entry_t)mgmt_thread, NULL, NULL, NULL, K_PRIO_COOP(CONFIG_NET_MGMT_EVENT_THREAD_PRIO), 0, 0); + k_thread_name_set(&mgmt_thread_data, "net_mgmt"); NET_DBG("Net MGMT initialized: queue of %u entries, stack size of %u", CONFIG_NET_MGMT_EVENT_QUEUE_SIZE, diff --git a/subsys/net/ip/net_tc.c b/subsys/net/ip/net_tc.c index 53c36df2833..563869baa8b 100644 --- a/subsys/net/ip/net_tc.c +++ b/subsys/net/ip/net_tc.c @@ -257,6 +257,7 @@ void net_tc_tx_init(void) tx_stack[i], K_THREAD_STACK_SIZEOF(tx_stack[i]), K_PRIO_COOP(thread_priority)); + k_thread_name_set(&tx_classes[i].work_q.thread, "tx_workq"); } } @@ -295,5 +296,6 @@ void net_tc_rx_init(void) rx_stack[i], K_THREAD_STACK_SIZEOF(rx_stack[i]), K_PRIO_COOP(thread_priority)); + k_thread_name_set(&rx_classes[i].work_q.thread, "rx_workq"); } } diff --git a/subsys/net/l2/ethernet/gptp/gptp.c b/subsys/net/l2/ethernet/gptp/gptp.c index 621e512a554..65fde068179 100644 --- a/subsys/net/l2/ethernet/gptp/gptp.c +++ b/subsys/net/l2/ethernet/gptp/gptp.c @@ -900,6 +900,7 @@ static void init_ports(void) K_THREAD_STACK_SIZEOF(gptp_stack), (k_thread_entry_t)gptp_thread, NULL, NULL, NULL, K_PRIO_COOP(5), 0, 0); + k_thread_name_set(&gptp_thread_data, "gptp"); } #if defined(CONFIG_NET_GPTP_VLAN) diff --git a/subsys/net/l2/openthread/openthread.c b/subsys/net/l2/openthread/openthread.c index a50e1ceeade..ae3c3a0605f 100644 --- a/subsys/net/l2/openthread/openthread.c +++ b/subsys/net/l2/openthread/openthread.c @@ -336,6 +336,7 @@ static int openthread_init(struct net_if *iface) openthread_process, ot_context, NULL, NULL, OT_PRIORITY, 0, K_NO_WAIT); + k_thread_name_set(&ot_thread_data, "openthread"); return 0; } diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index 37dcc464ad7..9a6c0cb6035 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -4043,6 +4043,8 @@ static int lwm2m_engine_init(struct device *dev) /* Lowest priority cooperative thread */ K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1), 0, K_NO_WAIT); + k_thread_name_set(&engine_thread_data, "lwm2m"); + LOG_DBG("LWM2M engine thread started"); return 0; }