Skip to content

Commit 7699563

Browse files
committed
net: mgmt: Use proper coop thread priority value
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 <[email protected]>
1 parent bdba2e6 commit 7699563

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

subsys/net/ip/Kconfig.mgmt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ config NET_MGMT_EVENT_STACK_SIZE
2727
Set the internal stack size for NM to run registered callbacks
2828
on events.
2929

30-
config NET_MGMT_EVENT_THREAD_PRIO
31-
int "Inner thread priority (use with care)"
32-
default -1 if NET_TC_THREAD_COOPERATIVE
33-
default 7
34-
help
35-
Set the network management event core's inner thread priority.
36-
Do not change this unless you know what you are doing.
37-
3830
config NET_MGMT_EVENT_QUEUE_SIZE
3931
int "Size of event queue"
4032
default 16 if NET_MGMT_EVENT_MONITOR

subsys/net/ip/net_mgmt.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,17 @@ void net_mgmt_event_init(void)
386386
(void)memset(events, 0, CONFIG_NET_MGMT_EVENT_QUEUE_SIZE *
387387
sizeof(struct mgmt_event_entry));
388388

389+
#if IS_ENABLED(CONFIG_NET_TC_THREAD_COOPERATIVE)
390+
/* Lowest priority cooperative thread */
391+
#define THREAD_PRIORITY K_PRIO_COOP(CONFIG_NUM_COOP_PRIORITIES - 1)
392+
#else
393+
#define THREAD_PRIORITY K_PRIO_PREEMPT(CONFIG_NUM_PREEMPT_PRIORITIES - 1)
394+
#endif
395+
389396
k_thread_create(&mgmt_thread_data, mgmt_stack,
390397
K_KERNEL_STACK_SIZEOF(mgmt_stack),
391398
(k_thread_entry_t)mgmt_thread, NULL, NULL, NULL,
392-
CONFIG_NET_MGMT_EVENT_THREAD_PRIO, 0, K_NO_WAIT);
399+
THREAD_PRIORITY, 0, K_NO_WAIT);
393400
k_thread_name_set(&mgmt_thread_data, "net_mgmt");
394401

395402
NET_DBG("Net MGMT initialized: queue of %u entries, stack size of %u",

tests/net/all/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ CONFIG_NET_CONFIG_NEED_IPV6=y
207207
CONFIG_NET_MGMT=y
208208
CONFIG_NET_MGMT_EVENT=y
209209
CONFIG_NET_MGMT_EVENT_STACK_SIZE=800
210-
CONFIG_NET_MGMT_EVENT_THREAD_PRIO=66
211210
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=2
212211
CONFIG_NET_MGMT_EVENT_LOG_LEVEL_DBG=y
213212
CONFIG_NET_DEBUG_MGMT_EVENT_STACK=y

tests/net/lib/dns_addremove/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ CONFIG_DNS_NUM_CONCUR_QUERIES=1
99
CONFIG_NET_LOG=y
1010
CONFIG_NET_MGMT=y
1111
CONFIG_NET_MGMT_EVENT=y
12-
CONFIG_NET_MGMT_EVENT_THREAD_PRIO=7
1312
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=2
1413
CONFIG_NET_IPV4=y
1514
CONFIG_NET_IPV6=y

0 commit comments

Comments
 (0)