Skip to content
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

Bluetooth: Mesh: Thread stack can reduce by use malloc&free function #19910

Closed
LingaoM opened this issue Oct 18, 2019 · 1 comment
Closed

Bluetooth: Mesh: Thread stack can reduce by use malloc&free function #19910

LingaoM opened this issue Oct 18, 2019 · 1 comment
Assignees
Labels
area: Bluetooth Mesh Enhancement Changes/Updates/Additions to existing features

Comments

@LingaoM
Copy link
Collaborator

LingaoM commented Oct 18, 2019

static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr,
u8_t aszmic, struct net_buf_simple *buf)
{
NET_BUF_SIMPLE_DEFINE(sdu, CONFIG_BT_MESH_RX_SDU_MAX - 4);
u8_t *ad;
u16_t i;

Just as above code, when sdu_recv be called, stack will occupy at least CONFIG_BT_MESH_RX_SDU_MAX octers, this problem occurs in many places. I think we can replace a large number of stack uses with heap.

@LingaoM LingaoM added the Enhancement Changes/Updates/Additions to existing features label Oct 18, 2019
@jhedberg
Copy link
Member

Zephyr doesn't have a heap by default, and neither the Bluetooth stack nor the mesh code requires it. Creating a heap would therefore initially likely consume more memory than the current code. Additionally the current mempool-based allocator isn't super efficient. I remember seeing some work toward a better heap allocator, so we could potentially reconsider this in the future.

Another drawback of moving to heap is that we have to start handling allocation errors everywhere, whereas now we're always guaranteed to have the memory available.

@LingaoM LingaoM closed this as completed Oct 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Mesh Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

No branches or pull requests

4 participants