Skip to content

Commit

Permalink
net: mgmt: Use proper coop thread priority value
Browse files Browse the repository at this point in the history
If user sets CONFIG_NUM_PREEMPT_PRIORITIES=0, then the priority
of the net_mgmt thread will be -1 which is the same as idle thread.
This will trigger assert in kernel as then the minimum coop priority
is -2 in this case. Remove the net_mgmt thread priority setting from
Kconfig file as it is low value and set the coop thread priority
the same way as other network threads are doing it.

Fixes #32375

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Feb 17, 2021
1 parent b49e395 commit 18ecdce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
8 changes: 0 additions & 8 deletions subsys/net/ip/Kconfig.mgmt
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ config NET_MGMT_EVENT_STACK_SIZE
Set the internal stack size for NM to run registered callbacks
on events.

config NET_MGMT_EVENT_THREAD_PRIO
int "Inner thread priority (use with care)"
default -1 if NET_TC_THREAD_COOPERATIVE
default 7
help
Set the network management event core's inner thread priority.
Do not change this unless you know what you are doing.

config NET_MGMT_EVENT_QUEUE_SIZE
int "Size of event queue"
default 16 if NET_MGMT_EVENT_MONITOR
Expand Down
9 changes: 8 additions & 1 deletion subsys/net/ip/net_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,17 @@ void net_mgmt_event_init(void)
(void)memset(events, 0, CONFIG_NET_MGMT_EVENT_QUEUE_SIZE *
sizeof(struct mgmt_event_entry));

#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
/* Lowest priority cooperative thread */
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
#else
#define THREAD_PRIORITY K_PRIO_PREEMPT(CONFIG_NUM_PREEMPT_PRIORITIES - 1)
#endif

k_thread_create(&mgmt_thread_data, mgmt_stack,
K_KERNEL_STACK_SIZEOF(mgmt_stack),
(k_thread_entry_t)mgmt_thread, NULL, NULL, NULL,
CONFIG_NET_MGMT_EVENT_THREAD_PRIO, 0, K_NO_WAIT);
THREAD_PRIORITY, 0, K_NO_WAIT);
k_thread_name_set(&mgmt_thread_data, "net_mgmt");

NET_DBG("Net MGMT initialized: queue of %u entries, stack size of %u",
Expand Down
1 change: 0 additions & 1 deletion tests/net/all/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ CONFIG_NET_CONFIG_NEED_IPV6=y
CONFIG_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_MGMT_EVENT_STACK_SIZE=800
CONFIG_NET_MGMT_EVENT_THREAD_PRIO=66
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=2
CONFIG_NET_MGMT_EVENT_LOG_LEVEL_DBG=y
CONFIG_NET_DEBUG_MGMT_EVENT_STACK=y
Expand Down
1 change: 0 additions & 1 deletion tests/net/lib/dns_addremove/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ CONFIG_DNS_NUM_CONCUR_QUERIES=1
CONFIG_NET_LOG=y
CONFIG_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_MGMT_EVENT_THREAD_PRIO=7
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=2
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
Expand Down

0 comments on commit 18ecdce

Please sign in to comment.