函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:kernel\printk\printk_safe.c Create Date:2022-07-27 11:07:51
首页 Copyright©Brick

282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
#ifdef CONFIG_PRINTK_NMI
/*
 * Safe printk() for NMI context. It uses a per-CPU buffer to
 * store the message. NMIs are not nested, so there is always only
 * one writer running. But the buffer might get flushed from another
 * CPU, so we need to be careful.
 */
static __printf(1, 0) int vprintk_nmi(const char *fmt, va_list args)
{
    struct printk_safe_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
 
    return printk_safe_log_store(s, fmt, args);
}
 
void notrace printk_nmi_enter(void)
{
    this_cpu_or(printk_context, PRINTK_NMI_CONTEXT_MASK);
}
 
void notrace printk_nmi_exit(void)
{
    this_cpu_and(printk_context, ~PRINTK_NMI_CONTEXT_MASK);
}
 
/*
 * Marks a code that might produce many messages in NMI context
 * and the risk of losing them is more critical than eventual
 * reordering.
 *
 * It has effect only when called in NMI context. Then printk()
 * will try to store the messages into the main logbuf directly
 * and use the per-CPU buffers only as a fallback when the lock
 * is not available.
 */
void printk_nmi_direct_enter(void)
{
    if (this_cpu_read(printk_context) & PRINTK_NMI_CONTEXT_MASK)
        this_cpu_or(printk_context, PRINTK_NMI_DIRECT_CONTEXT_MASK);
}
 
void printk_nmi_direct_exit(void)
{
    this_cpu_and(printk_context, ~PRINTK_NMI_DIRECT_CONTEXT_MASK);
}
 
#else
 
static __printf(1, 0) int vprintk_nmi(const char *fmt, va_list args)
{
    return 0;
}