Skip to content

Commit

Permalink
unified: dissociate system workqueue from common workqueue module
Browse files Browse the repository at this point in the history
Making a reference to the common work queue code should not necessarily
drag in the system workqueue, since it is possible to use a workqueue
that is not the system workqueue. This is done by moving the system
workqueue into its own code module.

Moving the system workqueue to its own code module allows removing the
NANO_WORKQUEUE and SYSTEM_WORKQUEUE kconfig options, and compiling the
common workqueue code and system workqueue all the time. They are only
linked in the final image if a reference to them exist, same as the
other kernel modules.

Change-Id: I6f48d2542bda24f4702e7c2e317818dd082b3c11
Signed-off-by: Benjamin Walsh <[email protected]>
  • Loading branch information
benwrs authored and Anas Nashif committed Nov 4, 2016
1 parent fcfddc0 commit 8cf56bc
Show file tree
Hide file tree
Showing 31 changed files with 60 additions and 79 deletions.
2 changes: 0 additions & 2 deletions drivers/bluetooth/hci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ config BLUETOOTH_H5
select UART_INTERRUPT_DRIVEN
select BLUETOOTH_UART
select BLUETOOTH_HOST_BUFFERS
select NANO_WORKQUEUE
select SYSTEM_WORKQUEUE
help
Bluetooth three-wire (H:5) UART driver. Implementation of HCI
Three-Wire UART Transport Layer.
Expand Down
2 changes: 0 additions & 2 deletions drivers/bluetooth/nble/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ config NBLE
select UART_INTERRUPT_DRIVEN
select NANO_TIMEOUTS
select NET_BUF
select NANO_WORKQUEUE
select SYSTEM_WORKQUEUE
depends on BLUETOOTH_STACK_NBLE
help
Enables support for using Nordic Semiconductor nRF51 Bluetooth
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/bma280/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ config BMA280_TRIGGER_NONE
config BMA280_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select BMA280_TRIGGER

config BMA280_TRIGGER_OWN_FIBER
Expand Down
1 change: 0 additions & 1 deletion drivers/sensor/bmg160/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ config BMG160_TRIGGER_NONE

config BMG160_TRIGGER_GLOBAL_FIBER
bool "Use global fiber"
depends on SYSTEM_WORKQUEUE
select BMG160_TRIGGER

config BMG160_TRIGGER_OWN_FIBER
Expand Down
1 change: 0 additions & 1 deletion drivers/sensor/bmi160/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ config BMI160_TRIGGER_NONE

config BMI160_TRIGGER_GLOBAL_FIBER
bool "Use global fiber"
depends on SYSTEM_WORKQUEUE
select BMI160_TRIGGER

config BMI160_TRIGGER_OWN_FIBER
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/hmc5883l/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ config HMC5883L_TRIGGER_NONE
config HMC5883L_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select HMC5883L_TRIGGER

config HMC5883L_TRIGGER_OWN_FIBER
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/hts221/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ config HTS221_TRIGGER_NONE
config HTS221_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select HTS221_TRIGGER

config HTS221_TRIGGER_OWN_FIBER
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/isl29035/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ config ISL29035_TRIGGER_NONE
config ISL29035_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select ISL29035_TRIGGER

config ISL29035_TRIGGER_OWN_FIBER
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/lis3dh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ config LIS3DH_TRIGGER_NONE
config LIS3DH_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select LIS3DH_TRIGGER

config LIS3DH_TRIGGER_OWN_FIBER
Expand Down
4 changes: 2 additions & 2 deletions drivers/sensor/lis3mdl/Kconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#

# Copyright (c) 2016 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -63,7 +63,7 @@ config LIS3MDL_TRIGGER_NONE
config LIS3MDL_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select LIS3MDL_TRIGGER

config LIS3MDL_TRIGGER_OWN_FIBER
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/mcp9808/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ config MCP9808_TRIGGER_NONE
bool "No trigger"

config MCP9808_TRIGGER_GLOBAL_FIBER
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select MCP9808_TRIGGER
bool "Use global fiber"

Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/mpu6050/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ config MPU6050_TRIGGER_NONE
config MPU6050_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select MPU6050_TRIGGER

config MPU6050_TRIGGER_OWN_FIBER
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/sht3xd/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ config SHT3XD_TRIGGER_NONE
config SHT3XD_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select SHT3XD_TRIGGER

config SHT3XD_TRIGGER_OWN_FIBER
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/sx9500/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ config SX9500_TRIGGER_NONE
bool "No trigger"

config SX9500_TRIGGER_GLOBAL_FIBER
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select SX9500_TRIGGER
bool "Use global fiber"

Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/tmp007/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ config TMP007_TRIGGER_NONE
config TMP007_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
depends on GPIO && SYSTEM_WORKQUEUE
depends on GPIO
select TMP007_TRIGGER

config TMP007_TRIGGER_OWN_FIBER
Expand Down
3 changes: 0 additions & 3 deletions include/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -1079,8 +1079,6 @@ extern int k_delayed_work_cancel(struct k_delayed_work *work);

#endif /* CONFIG_SYS_CLOCK_EXISTS */

#if defined(CONFIG_SYSTEM_WORKQUEUE)

extern struct k_work_q k_sys_work_q;

/**
Expand Down Expand Up @@ -1114,7 +1112,6 @@ static inline int k_delayed_work_submit(struct k_delayed_work *work,
}

#endif /* CONFIG_SYS_CLOCK_EXISTS */
#endif /* CONFIG_SYSTEM_WORKQUEUE */

/**
* synchronization
Expand Down
18 changes: 0 additions & 18 deletions kernel/unified/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -183,31 +183,13 @@ config ERRNO
symbol. The C library must access the per-thread errno via the
_get_errno() symbol.

config NANO_WORKQUEUE
bool "Enable nano workqueue support"
default y
help
Nano workqueues allow scheduling work items to be executed in a fiber
context. Typically such work items are scheduled from ISRs, when the
work cannot be executed in interrupt context.

config SYSTEM_WORKQUEUE
bool "Start a system workqueue"
default y
depends on NANO_WORKQUEUE
help
Start a system-wide nano_workqueue that can be used by any system
component.

config SYSTEM_WORKQUEUE_STACK_SIZE
int "System workqueue stack size"
default 1024
depends on SYSTEM_WORKQUEUE

config SYSTEM_WORKQUEUE_PRIORITY
int "System workqueue priority"
default -1
depends on SYSTEM_WORKQUEUE

config OFFLOAD_WORKQUEUE_STACK_SIZE
int "Workqueue stack size for thread offload requests"
Expand Down
3 changes: 2 additions & 1 deletion kernel/unified/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ lib-y += $(strip \
pipes.o \
legacy_offload.o \
errno.o \
work_q.o \
system_work_q.o \
)

lib-$(CONFIG_INT_LATENCY_BENCHMARK) += int_latency_bench.o
Expand All @@ -38,4 +40,3 @@ lib-$(CONFIG_SYS_CLOCK_EXISTS) += timer.o legacy_timer.o
lib-$(CONFIG_KERNEL_EVENT_LOGGER) += event_logger.o
lib-$(CONFIG_KERNEL_EVENT_LOGGER) += kernel_event_logger.o
lib-$(CONFIG_ATOMIC_OPERATIONS_C) += atomic_c.o
lib-$(CONFIG_NANO_WORKQUEUE) += work_q.o
43 changes: 43 additions & 0 deletions kernel/unified/system_work_q.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2016 Wind River Systems, Inc.
* Copyright (c) 2016 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file
*
* System workqueue.
*/

#include <kernel.h>
#include <init.h>

static char __stack sys_work_q_stack[CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE];

struct k_work_q k_sys_work_q;

static int k_sys_work_q_init(struct device *dev)
{
ARG_UNUSED(dev);

k_work_q_start(&k_sys_work_q,
sys_work_q_stack,
sizeof(sys_work_q_stack),
CONFIG_SYSTEM_WORKQUEUE_PRIORITY);

return 0;
}

SYS_INIT(k_sys_work_q_init, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
25 changes: 1 addition & 24 deletions kernel/unified/work_q.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2016 Intel Corporation
* Copyright (c) 2016 Wind River Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -145,27 +146,3 @@ int k_delayed_work_cancel(struct k_delayed_work *work)
return 0;
}
#endif /* CONFIG_SYS_CLOCK_EXISTS */

#ifdef CONFIG_SYSTEM_WORKQUEUE

#include <init.h>

static char __stack sys_work_q_stack[CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE];

struct k_work_q k_sys_work_q;

static int k_sys_work_q_init(struct device *dev)
{
ARG_UNUSED(dev);

k_work_q_start(&k_sys_work_q,
sys_work_q_stack,
sizeof(sys_work_q_stack),
CONFIG_SYSTEM_WORKQUEUE_PRIORITY);

return 0;
}

SYS_INIT(k_sys_work_q_init, PRIMARY, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

#endif
1 change: 0 additions & 1 deletion samples/net/trickle-legacy/prj_802154.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CONFIG_NETWORKING_WITH_15_4_TI_CC2520=y
CONFIG_SYS_LOG_TI_CC2520_LEVEL=4
CONFIG_NETWORKING_WITH_6LOWPAN=y
CONFIG_6LOWPAN_COMPRESSION_IPHC=y
CONFIG_NANO_WORKQUEUE=y
CONFIG_NETWORKING_STATISTICS=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING_WITH_TRICKLE=y
1 change: 0 additions & 1 deletion samples/net/trickle-legacy/prj_bt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ CONFIG_6LOWPAN_COMPRESSION_IPHC=y
CONFIG_NETWORKING_WITH_BT=y
CONFIG_IP_BUF_RX_SIZE=5
CONFIG_IP_BUF_TX_SIZE=3
CONFIG_NANO_WORKQUEUE=y
CONFIG_NETWORKING_STATISTICS=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING_WITH_TRICKLE=y
1 change: 0 additions & 1 deletion samples/net/trickle-legacy/prj_ethernet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ CONFIG_NANO_TIMEOUTS=y
CONFIG_ETHERNET=y
CONFIG_ETH_DW=y
CONFIG_ETHERNET_DEBUG=y
CONFIG_NANO_WORKQUEUE=y
CONFIG_NETWORKING_STATISTICS=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING_WITH_TRICKLE=y
1 change: 0 additions & 1 deletion samples/net/trickle-legacy/prj_qemu.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=2
CONFIG_NANO_TIMEOUTS=y
CONFIG_NANO_WORKQUEUE=y
CONFIG_NETWORKING_STATISTICS=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING_WITH_TRICKLE=y
1 change: 0 additions & 1 deletion samples/net/trickle-legacy/prj_slip.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_IP_BUF_RX_SIZE=3
CONFIG_IP_BUF_TX_SIZE=2
CONFIG_NANO_TIMEOUTS=y
CONFIG_NANO_WORKQUEUE=y
CONFIG_NETWORKING_STATISTICS=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NETWORKING_WITH_TRICKLE=y
2 changes: 0 additions & 2 deletions samples/net/zoap_client/prj.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
CONFIG_NANOKERNEL=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_NANO_WORKQUEUE=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NETWORKING_IPV6_NO_ND=y
Expand All @@ -11,5 +10,4 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORK_IP_STACK_DEBUG_FULL=y
CONFIG_NET_TESTING=y
CONFIG_SYSTEM_WORKQUEUE=y
CONFIG_ZOAP=y
2 changes: 0 additions & 2 deletions samples/net/zoap_server/prj.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
CONFIG_NANOKERNEL=y
CONFIG_NANO_TIMEOUTS=y
CONFIG_NANO_WORKQUEUE=y
CONFIG_NETWORKING=y
CONFIG_NETWORKING_DEBUG_UART=y
CONFIG_NETWORKING_IPV6_NO_ND=y
Expand All @@ -11,5 +10,4 @@ CONFIG_NETWORKING_WITH_LOGGING=y
CONFIG_NETWORKING_WITH_LOOPBACK=y
CONFIG_NETWORK_IP_STACK_DEBUG_FULL=y
CONFIG_NET_TESTING=y
CONFIG_SYSTEM_WORKQUEUE=y
CONFIG_ZOAP=y
2 changes: 0 additions & 2 deletions subsys/bluetooth/host/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ config BLUETOOTH_CENTRAL

config BLUETOOTH_CONN
bool
select NANO_WORKQUEUE
select SYSTEM_WORKQUEUE
default n

if BLUETOOTH_CONN
Expand Down
2 changes: 0 additions & 2 deletions tests/legacy/kernel/test_nano_work/prj.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
CONFIG_NANO_WORKQUEUE=y
CONFIG_SYSTEM_WORKQUEUE=y
CONFIG_NANO_TIMEOUTS=y
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

#define TOTAL_THREADS (N_PHILOSOPHERS + 3 + IPM_THREAD)

void *force_sys_work_q_in = (void *)k_work_q_start;
void *force_sys_work_q_in = (void *)&k_sys_work_q;

#define OBJ_LIST_NAME k_mutex
#define OBJ_LIST_TYPE struct k_mutex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* 1 IPM console thread
*/

void *force_sys_work_q_in = (void *)k_work_q_start;
void *force_sys_work_q_in = (void *)&k_sys_work_q;

#define TOTAL_THREADS (N_PHILOSOPHERS + 3 + IPM_THREAD)

Expand Down

0 comments on commit 8cf56bc

Please sign in to comment.