trace_waitpid() loop hogs one CPU during trace-cmd record. Add a delay there to
slow down the loop, to reduce the CPU load.

Signed-off-by: Vincent Stehlé <[email protected]>
Cc: Steven Rostedt <[email protected]>

---


Changes since v1:
- Use nanosleep and sleep_time from command line.


 trace-record.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/trace-record.c b/trace-record.c
index 18e2e2d..a230fde 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -837,6 +837,7 @@ static pid_t trace_waitpid(enum trace_type type, pid_t pid, 
int *status, int opt
        struct timeval tv = { 1, 0 };
        int ret;
        int profile = (type & TRACE_TYPE_PROFILE) == TRACE_TYPE_PROFILE;
+       struct timespec req;
 
        options |= WNOHANG;
 
@@ -847,6 +848,11 @@ static pid_t trace_waitpid(enum trace_type type, pid_t 
pid, int *status, int opt
 
                if (type & TRACE_TYPE_STREAM)
                        trace_stream_read(pids, recorder_threads, &tv, profile);
+
+               req.tv_sec = sleep_time / 1000000;
+               req.tv_nsec = (sleep_time % 1000000) * 1000;
+               nanosleep(&req, NULL);
+
        } while (1);
 }
 #ifndef NO_PTRACE
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-trace-users" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to