Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gsplhtlxg
clone-Linux
提交
9f68cb57
C
clone-Linux
项目概览
gsplhtlxg
/
clone-Linux
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
clone-Linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9f68cb57
编写于
8月 14, 2018
作者:
P
Petr Mladek
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'for-4.19-nmi' into for-linus
上级
554ec508
03fc7f9c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
87 addition
and
48 deletion
+87
-48
include/linux/printk.h
include/linux/printk.h
+4
-0
kernel/printk/internal.h
kernel/printk/internal.h
+8
-1
kernel/printk/printk.c
kernel/printk/printk.c
+35
-22
kernel/printk/printk_safe.c
kernel/printk/printk_safe.c
+37
-21
kernel/trace/trace.c
kernel/trace/trace.c
+3
-1
lib/nmi_backtrace.c
lib/nmi_backtrace.c
+0
-3
未找到文件。
include/linux/printk.h
浏览文件 @
9f68cb57
...
...
@@ -148,9 +148,13 @@ void early_printk(const char *s, ...) { }
#ifdef CONFIG_PRINTK_NMI
extern
void
printk_nmi_enter
(
void
);
extern
void
printk_nmi_exit
(
void
);
extern
void
printk_nmi_direct_enter
(
void
);
extern
void
printk_nmi_direct_exit
(
void
);
#else
static
inline
void
printk_nmi_enter
(
void
)
{
}
static
inline
void
printk_nmi_exit
(
void
)
{
}
static
inline
void
printk_nmi_direct_enter
(
void
)
{
}
static
inline
void
printk_nmi_direct_exit
(
void
)
{
}
#endif
/* PRINTK_NMI */
#ifdef CONFIG_PRINTK
...
...
kernel/printk/internal.h
浏览文件 @
9f68cb57
...
...
@@ -19,11 +19,16 @@
#ifdef CONFIG_PRINTK
#define PRINTK_SAFE_CONTEXT_MASK 0x3fffffff
#define PRINTK_NMI_D
EFERRED_CONTEXT_MASK
0x40000000
#define PRINTK_NMI_D
IRECT_CONTEXT_MASK
0x40000000
#define PRINTK_NMI_CONTEXT_MASK 0x80000000
extern
raw_spinlock_t
logbuf_lock
;
__printf
(
5
,
0
)
int
vprintk_store
(
int
facility
,
int
level
,
const
char
*
dict
,
size_t
dictlen
,
const
char
*
fmt
,
va_list
args
);
__printf
(
1
,
0
)
int
vprintk_default
(
const
char
*
fmt
,
va_list
args
);
__printf
(
1
,
0
)
int
vprintk_deferred
(
const
char
*
fmt
,
va_list
args
);
__printf
(
1
,
0
)
int
vprintk_func
(
const
char
*
fmt
,
va_list
args
);
...
...
@@ -54,6 +59,8 @@ void __printk_safe_exit(void);
local_irq_enable(); \
} while (0)
void
defer_console_output
(
void
);
#else
__printf
(
1
,
0
)
int
vprintk_func
(
const
char
*
fmt
,
va_list
args
)
{
return
0
;
}
...
...
kernel/printk/printk.c
浏览文件 @
9f68cb57
...
...
@@ -1829,28 +1829,16 @@ static size_t log_output(int facility, int level, enum log_flags lflags, const c
return
log_store
(
facility
,
level
,
lflags
,
0
,
dict
,
dictlen
,
text
,
text_len
);
}
asmlinkage
int
vprintk_emit
(
int
facility
,
int
level
,
const
char
*
dict
,
size_t
dictlen
,
const
char
*
fmt
,
va_list
args
)
/* Must be called under logbuf_lock. */
int
vprintk_store
(
int
facility
,
int
level
,
const
char
*
dict
,
size_t
dictlen
,
const
char
*
fmt
,
va_list
args
)
{
static
char
textbuf
[
LOG_LINE_MAX
];
char
*
text
=
textbuf
;
size_t
text_len
;
enum
log_flags
lflags
=
0
;
unsigned
long
flags
;
int
printed_len
;
bool
in_sched
=
false
;
if
(
level
==
LOGLEVEL_SCHED
)
{
level
=
LOGLEVEL_DEFAULT
;
in_sched
=
true
;
}
boot_delay_msec
(
level
);
printk_delay
();
/* This stops the holder of console_sem just where we want him */
logbuf_lock_irqsave
(
flags
);
/*
* The printf needs to come first; we need the syslog
* prefix which might be passed-in as a parameter.
...
...
@@ -1894,8 +1882,29 @@ asmlinkage int vprintk_emit(int facility, int level,
if
(
suppress_message_printing
(
level
))
lflags
|=
LOG_NOCONS
;
printed_len
=
log_output
(
facility
,
level
,
lflags
,
dict
,
dictlen
,
text
,
text_len
);
return
log_output
(
facility
,
level
,
lflags
,
dict
,
dictlen
,
text
,
text_len
);
}
asmlinkage
int
vprintk_emit
(
int
facility
,
int
level
,
const
char
*
dict
,
size_t
dictlen
,
const
char
*
fmt
,
va_list
args
)
{
int
printed_len
;
bool
in_sched
=
false
;
unsigned
long
flags
;
if
(
level
==
LOGLEVEL_SCHED
)
{
level
=
LOGLEVEL_DEFAULT
;
in_sched
=
true
;
}
boot_delay_msec
(
level
);
printk_delay
();
/* This stops the holder of console_sem just where we want him */
logbuf_lock_irqsave
(
flags
);
printed_len
=
vprintk_store
(
facility
,
level
,
dict
,
dictlen
,
fmt
,
args
);
logbuf_unlock_irqrestore
(
flags
);
/* If called from the scheduler, we can not call up(). */
...
...
@@ -2884,16 +2893,20 @@ void wake_up_klogd(void)
preempt_enable
();
}
int
vprintk_deferred
(
const
char
*
fmt
,
va_list
args
)
void
defer_console_output
(
void
)
{
int
r
;
r
=
vprintk_emit
(
0
,
LOGLEVEL_SCHED
,
NULL
,
0
,
fmt
,
args
);
preempt_disable
();
__this_cpu_or
(
printk_pending
,
PRINTK_PENDING_OUTPUT
);
irq_work_queue
(
this_cpu_ptr
(
&
wake_up_klogd_work
));
preempt_enable
();
}
int
vprintk_deferred
(
const
char
*
fmt
,
va_list
args
)
{
int
r
;
r
=
vprintk_emit
(
0
,
LOGLEVEL_SCHED
,
NULL
,
0
,
fmt
,
args
);
defer_console_output
();
return
r
;
}
...
...
kernel/printk/printk_safe.c
浏览文件 @
9f68cb57
...
...
@@ -308,24 +308,33 @@ static __printf(1, 0) int vprintk_nmi(const char *fmt, va_list args)
void
printk_nmi_enter
(
void
)
{
/*
* The size of the extra per-CPU buffer is limited. Use it only when
* the main one is locked. If this CPU is not in the safe context,
* the lock must be taken on another CPU and we could wait for it.
*/
if
((
this_cpu_read
(
printk_context
)
&
PRINTK_SAFE_CONTEXT_MASK
)
&&
raw_spin_is_locked
(
&
logbuf_lock
))
{
this_cpu_or
(
printk_context
,
PRINTK_NMI_CONTEXT_MASK
);
}
else
{
this_cpu_or
(
printk_context
,
PRINTK_NMI_DEFERRED_CONTEXT_MASK
);
}
this_cpu_or
(
printk_context
,
PRINTK_NMI_CONTEXT_MASK
);
}
void
printk_nmi_exit
(
void
)
{
this_cpu_and
(
printk_context
,
~
(
PRINTK_NMI_CONTEXT_MASK
|
PRINTK_NMI_DEFERRED_CONTEXT_MASK
));
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
...
...
@@ -363,6 +372,20 @@ void __printk_safe_exit(void)
__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
);
raw_spin_unlock
(
&
logbuf_lock
);
defer_console_output
();
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
);
...
...
@@ -371,13 +394,6 @@ __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
if
(
this_cpu_read
(
printk_context
)
&
PRINTK_SAFE_CONTEXT_MASK
)
return
vprintk_safe
(
fmt
,
args
);
/*
* Use the main logbuf when logbuf_lock is available in NMI.
* But avoid calling console drivers that might have their own locks.
*/
if
(
this_cpu_read
(
printk_context
)
&
PRINTK_NMI_DEFERRED_CONTEXT_MASK
)
return
vprintk_deferred
(
fmt
,
args
);
/* No obstacles. */
return
vprintk_default
(
fmt
,
args
);
}
...
...
kernel/trace/trace.c
浏览文件 @
9f68cb57
...
...
@@ -8265,6 +8265,7 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
tracing_off
();
local_irq_save
(
flags
);
printk_nmi_direct_enter
();
/* Simulate the iterator */
trace_init_global_iter
(
&
iter
);
...
...
@@ -8344,7 +8345,8 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
for_each_tracing_cpu
(
cpu
)
{
atomic_dec
(
&
per_cpu_ptr
(
iter
.
trace_buffer
->
data
,
cpu
)
->
disabled
);
}
atomic_dec
(
&
dump_running
);
atomic_dec
(
&
dump_running
);
printk_nmi_direct_exit
();
local_irq_restore
(
flags
);
}
EXPORT_SYMBOL_GPL
(
ftrace_dump
);
...
...
lib/nmi_backtrace.c
浏览文件 @
9f68cb57
...
...
@@ -87,11 +87,9 @@ void nmi_trigger_cpumask_backtrace(const cpumask_t *mask,
bool
nmi_cpu_backtrace
(
struct
pt_regs
*
regs
)
{
static
arch_spinlock_t
lock
=
__ARCH_SPIN_LOCK_UNLOCKED
;
int
cpu
=
smp_processor_id
();
if
(
cpumask_test_cpu
(
cpu
,
to_cpumask
(
backtrace_mask
)))
{
arch_spin_lock
(
&
lock
);
if
(
regs
&&
cpu_in_idle
(
instruction_pointer
(
regs
)))
{
pr_warn
(
"NMI backtrace for cpu %d skipped: idling at %pS
\n
"
,
cpu
,
(
void
*
)
instruction_pointer
(
regs
));
...
...
@@ -102,7 +100,6 @@ bool nmi_cpu_backtrace(struct pt_regs *regs)
else
dump_stack
();
}
arch_spin_unlock
(
&
lock
);
cpumask_clear_cpu
(
cpu
,
to_cpumask
(
backtrace_mask
));
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录