-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
It's the same story again (#11008, #11417) - logging doesn't log what's expected. Consider following snippet from ethernet driver ISR handler (i.e. it executes on packet reception) run in the context of samples/net/echo_server:
printk("eth_smsc9220_isr: %x %x\n", SMSC9220->INT_STS, SMSC9220->INT_EN);
struct eth_context *context = dev->driver_data;
u32_t int_status = SMSC9220->INT_STS;
/* Ack pending interrupts */
SMSC9220->INT_STS = int_status;
if (int_status & BIT(enum_smsc9220_interrupt_rxstatus_fifo_level)) {
LOG_DBG("in RX FIFO: pkts: %u, bytes: %u",
SMSC9220_BFIELD(RX_FIFO_INF, RXSUSED),
SMSC9220_BFIELD(RX_FIFO_INF, RXDUSED));
printk("this should be shown immediately after 'in RX FIFO'\n");
u32_t pkt_size = smsc9220_peek_next_packet_size();
LOG_DBG("peek sz: %u", pkt_size);
...
LOG_DBG("out RX FIFO: pkts: %u, bytes: %u",
SMSC9220_BFIELD(RX_FIFO_INF, RXSUSED),
SMSC9220_BFIELD(RX_FIFO_INF, RXDUSED));
The output after startup followed the initial ping packet is (sorry for a lot of extra debug output):
uart:~$ init ok
eth_smsc9220_isr: 0 0
[00:00:03.381,509] <err> eth_smsc9220.eth_init: MAC 52:54:00:12:34:56
uart:~$ eth_initialize
get_cap
***** Booting Zephyr OS zephyr-v1.13.0-2175-g8759b9bec1 *****
eth_smsc9220_isr: 8 8
this should be shown immediately after 'in RX FIFO'
proto: 1
get_cap
log_strdup: no mem
log_strdup: no mem
log_strdup: no mem
log_strdup: no mem
log_strdup: no mem
eth_tx
eth_smsc9220_isr: 8 8
this should be shown immediately after 'in RX FIFO'
log_strdup: no mem
log_strdup: no mem
log_strdup: no mem
log_strdup: no mem
eth_tx
[00:00:17.896,378] <dbg> eth_smsc9220.eth_smsc9220_isr: out RX FIFO: pkts: 0, bytes: 0
[00:00:17.896,866] <dbg> net_arp.arp_update: (0x20000a38): src 192.0.2.2
[00:00:17.896,929] <dbg> net_arp.arp_entry_get_pending: (0x20000a38): dst 192.0.2.2
[00:00:17.896,992] <dbg> net_arp.arp_entry_find: (0x20000a38): iface 0x2000b0e0 dst 192.0.2.2
[00:00:17.897,187] <dbg> net_arp.arp_update: (0x20000a38): dst 192.0.2.2 pending 0x200053f8 frag 0x200058a8
[00:00:17.897,377] <dbg> net_arp.arp_entry_find_move_first: (0x20000a38): dst log_strdup pool empty!
[00:00:17.897,580] <dbg> net_arp.arp_entry_find: (0x20000a38): iface 0x2000b0e0 dst log_strdup pool empty!
[00:00:17.898,126] <dbg> net_arp.net_arp_prepare: (0x20000a38): ARP using ll log_strdup pool empty! for IP log_strdup pool empty!
What we should pay attention to is:
- On the first entry to ISR (first output
eth_smsc9220_isr: 8 8) no debug logging occurs. - On the 2nd entry to ISR, first debug output we get is
[00:00:17.896,378] <dbg> eth_smsc9220.eth_smsc9220_isr: out RX FIFO: .... But per the code above,out RX FIFO:logging should occur afterin RX FIFO:, and the latter didn't occur.
It should be noted that on the next ping packet, the problems subsides, and there's in RX FIFO: followed by out RX FIFO:.
Based on such a black-box analysis of logging behavior, we can make following conjectures (as conjectures, they may be false):
- (Knowing that logging is deferred,) logging has limited buffer to store output messages.
- This buffer is circular.
- When it overflows, older messages are overwritten SILENTLY.
But p.3 is absolutely IMPOSSIBLE way to deal with the situation. At worst, it should store a message notifying user that some output was lost (this is worst solution, as such a message can be lost itself). Normally, it should switch to non-deferred mode. Under condition logging should be dropped silently as a default option.