Can't find vprintk_safe in

Chan Kim ckim at
Tue Feb 8 02:53:07 EST 2022

Hello all


I'm doing a experiment and found a strange phenomenon.

This is the vprintk_func( ) function defined in kernel/printk/printk_safe.c
(in linux 5.4.21, I'll update to recent version later, it's arm64).


__printf(1, 0) int vprintk_func(const char *fmt, va_list args)



     * Try to use the main logbuf even in NMI. But avoid calling console

     * drivers that might have their own locks.


    if ((this_cpu_read(printk_context) & PRINTK_NMI_DIRECT_CONTEXT_MASK) &&

        raw_spin_trylock(&logbuf_lock)) {

        int len;


        len = vprintk_store(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);



        return len;



    /* Use extra buffer in NMI when logbuf_lock is taken or in safe mode. */

    if (this_cpu_read(printk_context) & PRINTK_NMI_CONTEXT_MASK)

        return vprintk_nmi(fmt, args);


    /* Use extra buffer to prevent a recursion deadlock in safe mode. */

    if (this_cpu_read(printk_context) & PRINTK_SAFE_CONTEXT_MASK)

        return vprintk_safe(fmt, args);


    /* No obstacles. */

    return vprintk_default(fmt, args);



In qemu test, it passes all the printk_context check and enters
vprintk_default( ) funciton but in our FPGA board (with only 8MB ram instead
of DDR), 

by writing debug information to some variables, I found the program seems to
enter vprintk_safe( ) function and stuck somewhere inside.

But when I examine the file, I cannot find the vprintk_safe
function and vprintk_nmi (I can find vprintk_default). I'm curious if this
may be related to the malfunction.

How can this happen? And how should I understand this?

Thank you!


Chan Kim

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Kernelnewbies mailing list