-
Notifications
You must be signed in to change notification settings - Fork 8.3k
bluetooth: host: Split cmd complete & cmd status to separate pool #74645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a3ca302 to
cd33a8b
Compare
f49cf94 to
37d5879
Compare
96db9d2 to
bdec445
Compare
The default main branch, cmd complete & cmd status use common normal net_buf pool, will be increase dead-lock, so split it to separate. Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Thalley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not yet sure whether this is a good change or not.
Do you have any logs or (even better) some tests that show the issue you are trying to solve, which shows that the issue is solved by this PR?
Maybe this answer by @alwa-nordic better. |
subsys/bluetooth/common/Kconfig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the range and default value here due to the fallback mechanism you have defined?
If we did not fallback to the event buffers in case of error, could this be reduced? Do we have any events larger than ~32 without ext_adv?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have also thought of a similar approach, but considering that almost all configurations now use extended advertising as a default option, the value of this optimization is not high.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current design will add about 140 bytes of RAM overhead, but it ensures relative safety, so I think it is worth it and change this way will not be noticeable to users.
subsys/bluetooth/host/buf.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that valid behavior of the controller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is the command complete for NOP opcode. This is legal to send on boot, and we have a quirk in the host to wait for it, as it is somewhat useful over H4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: #64158
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently normal event pool will also use by extended advertising event report, this is a huge activity, Also other events such as periodic advertising report. So for command complete and command status also use same normal pool not a good way.
Thalley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me, but it looks to me that we can get some significant optimization from the default size of BT_BUF_CMD_COMPLETE_EVT_SIZE
subsys/bluetooth/common/Kconfig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me this reads as "if you use a split build (ie hci on another chip), then you better use 255".
So I propose you also add default 255 if !BT_CTLR. Same remark for the other kconfig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
After zephyrproject-rtos#72135 there are no-used at all, so deleted. Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
|
Do we need a pool for Command Complete? I think we don't need the new pool and can save the memory by putting Command Complete events into the single-buffer The current implementation only needs one event buffer, since we copy out the data immediately in |
Three reasons to keep a separate pool for command complete events:
|
I fully understand that currently only one is supported, but the current configuration is two: config BT_BUF_CMD_TX_COUNT
int "Number of HCI command buffers"
default 2
range 2 64
help
Number of buffers available for outgoing HCI commands from the Host.Another advantage of using two here is that we can always ensure that there is always a free buffer for command complete event even in some extreme scenarios, if the Controller reports a message inexplicably, we can still tolerate the error., so I use |
What deadlock are you hinting at? |
Can you elaborate on this deadlock scenario? What sequence of events/data would get us into this state. Have you seen it in manual testing? |
I don't understand the issue this patch is supposed to address.
Please see:#68008 (comment) |
|
The default main branch, cmd complete & cmd status use common normal net_buf pool, will be increase dead-lock, so split it to separate.
This always ensures that the event flow is not blocked.