浏览代码

ftrace: trace_pipe implement NONBLOCK

This patch implements "NONBLOCK" for trace_pipe. If the trace_pipe is opened
with O_NONBLOCK, then the trace_pipe read will not block when buffer is empty.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Steven Rostedt 17 年之前
父节点
当前提交
2dc8f09571
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      kernel/trace/trace.c

+ 4 - 0
kernel/trace/trace.c

@@ -2233,6 +2233,10 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
 	start = 0;
 	start = 0;
 
 
 	while (trace_empty(iter)) {
 	while (trace_empty(iter)) {
+
+		if ((filp->f_flags & O_NONBLOCK))
+			return -EAGAIN;
+
 		/*
 		/*
 		 * This is a make-shift waitqueue. The reason we don't use
 		 * This is a make-shift waitqueue. The reason we don't use
 		 * an actual wait queue is because:
 		 * an actual wait queue is because: