BT GATT DM Workqueue Stack Size

Hello,

I had a question about the BT GATT DM Workqueue used in gatt_dm.c.

In NCS 2.8.0, the BT GATT DM Workqueue was introduced as an alternative to the System Workqueue to allow for scheduling non-blocking callbacks from the GATT Discovery Manager.

One difference between the BT GATT DM Workqueue and the System Workqueue is stack size. The System Workqueue's stack size is configurable while the BT GATT DM Workqueue is a hidden Kconfig option.

When testing GATT Discovery Manager error cases, I found the error handling in my application was just barely exceeding the BT GATT DM Workqueue stack size of 1300 leading to a crash. This same error handling would not crash with the System Workqueue implementation because I could configure the stack size of that queue to be larger.

I would like to continue to use the BT GATT DM Workqueue as recommended, but I would also like to keep the same error handling in my application. For now, I am modifying my copy of NCS to allow myself to configure BT_GATT_DM_WORKQ_STACK_SIZE.

Would Nordic consider allowing CONFIG_BT_GATT_DM_WORKQ_STACK_SIZE to be configurable in the future?

Thanks

  • An additional question:  Why was CONFIG_BT_GATT_DM_WORKQ_STACK_SIZE deliberately made a hidden option?

    The comment for that CONFIG says "Hidden option for workqueue stack size. Should be derived from system requirements."

    The problem is that that workqueue includes callbacks to our application code, which to me is part of the system. Even though we want to limit the amount of work done in that context as part of the callback, why do we have to limit our stack use too, as constrained by the hidden CONFIG_BT_GATT_DM_WORKQ_STACK_SIZE?

  • Hi,

    I cannot see that there is a good reason for not having the GATT DM workqueue size user configurable. I have reported this internally. For now, you can make it configurable by doing a small change in nrf/subsys/bluetooth/Kconfig.discovery so that BT_GATT_DM_WORKQ_STACK_SIZE looks like this:

    config BT_GATT_DM_WORKQ_STACK_SIZE
    	int  "GATT Discovery Manager workqueue stack size."
    	default 1300 if BT_GATT_CACHING
    	default 1024

    Edit: to avoid modifying SDK code you can also override by using an application specific Kconfig file containing the following (adjust as needed):

    config BT_GATT_DM_WORKQ_STACK_SIZE
    	default 2048
    
    source "Kconfig.zephyr"
    

Related