[PATCH v3] trace-record: slow down trace_waitpid loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



trace_waitpid() loop hogs one CPU during trace-cmd record. Slow it down by
making waitpid() hang for all non-stream cases (as per Steven's solution).

Signed-off-by: Vincent Stehlé <vincent.stehle@xxxxxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>

---


On 02/04/2015 08:07 PM, Steven Rostedt wrote:
> As you pointed it out, please send a new patch.

Hi Steven,

Thank you! Here is a v3 patch, which works for me on ARM and x86.

Best regards,

V.


Changes since v2:
- Make waitpid() hang instead of using nanosleep, as per Steven's solution.

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


 trace-record.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/trace-record.c b/trace-record.c
index 18e2e2d..3cb943d 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -838,7 +838,8 @@ static pid_t trace_waitpid(enum trace_type type, pid_t pid, int *status, int opt
 	int ret;
 	int profile = (type & TRACE_TYPE_PROFILE) == TRACE_TYPE_PROFILE;
 
-	options |= WNOHANG;
+	if (type & TRACE_TYPE_STREAM)
+		options |= WNOHANG;
 
 	do {
 		ret = waitpid(pid, status, options);
-- 
2.1.4

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




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux