Re: [PATCH v2] trace-record: slow down trace_waitpid loopi

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

 



Hi Vincent,


On Wed, 4 Feb 2015 10:06:44 +0100
Vincent Stehlé <vincent.stehle@xxxxxxxxxxxxx> wrote:


> 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;
>  

Instead of the nanosleep, I'm wondering if we should do this instead:

	if (type & TRACE_TYPE_STREAM)
		options |= WNOHANG;

Because it only needs not to wait if it is live streaming. Otherwise
we want to wait.

-- Steve

>  	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

--
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