When trying to log/debug an ISR, I’ve seen:
1) sprintf() used as example in ‘O’Reilly Linux Device Drivers’
irqreturn_t short_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
struct timeval tv;
int written;
do_gettimeofday(&tv);
/* Write a 16 byte record. Assume PAGE_SIZE is a multiple of 16 */
written = sprintf((char *)short_head,"%08u.%06u\n",
(int)(tv.tv_sec % 100000000), (int)(tv.tv_usec));
BUG_ON(written != 16);
short_incr_bp(&short_head, written);
wake_up_interruptible(&short_queue); /* awake any reading process */
return IRQ_HANDLED;
}
unlike printf(), sprintf() write to memory instead of to console, and does not seem to have re-entrant or blocking issue, correct? but I’ve seen words against sprintf() on other forum. I am not sure if it’s only because of its performance overhead, or else?
2) printk() is another one i’ve seen people used but blamed for, again performance issue (maybe nothing else?)
What is a generally good method/function to use when logging, or debugging ISR in Linux these days?
Regarding
sprintf(). Do the search in any LXR site, for example here:I think this eliminates any doubts.
As for
printk(),printk.hsays: