net: buf: Generate periodic warnings for allocation that takes too long
This might indicate buffer leaks or deadlock is happening. Change-Id: If91a65ccfe1be9497b210de21e80b533b6739367 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
a745832dc4
commit
7cdb750539
|
@ -36,6 +36,8 @@
|
|||
#define NET_BUF_ASSERT(cond)
|
||||
#endif /* CONFIG_NET_BUF_LOG */
|
||||
|
||||
#define WARN_ALLOC_INTERVAL K_SECONDS(1)
|
||||
|
||||
/* Helpers to access the storage array, since we don't have access to its
|
||||
* type at this point anymore.
|
||||
*/
|
||||
|
@ -106,11 +108,15 @@ struct net_buf *net_buf_alloc(struct net_buf_pool *pool, int32_t timeout)
|
|||
|
||||
#if defined(CONFIG_NET_BUF_LOG) && SYS_LOG_LEVEL >= SYS_LOG_LEVEL_WARNING
|
||||
if (timeout == K_FOREVER) {
|
||||
uint32_t ref = k_uptime_get_32();
|
||||
buf = k_lifo_get(&pool->free, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
while (!buf) {
|
||||
NET_BUF_WARN("%s():%d: Pool %p low on buffers.",
|
||||
func, line, pool);
|
||||
buf = k_lifo_get(&pool->free, timeout);
|
||||
buf = k_lifo_get(&pool->free, WARN_ALLOC_INTERVAL);
|
||||
NET_BUF_WARN("%s():%d: blocked for %u secs",
|
||||
func, line,
|
||||
(k_uptime_get_32() - ref) / MSEC_PER_SEC);
|
||||
}
|
||||
} else {
|
||||
buf = k_lifo_get(&pool->free, timeout);
|
||||
|
|
Loading…
Reference in a new issue