[Intel-gfx] [PATCH i-g-t 4/5] lib: clear log buffer after writing it out or starting a new subtest
Chris Wilson
chris at chris-wilson.co.uk
Wed Dec 17 09:21:49 PST 2014
On Wed, Dec 17, 2014 at 04:45:46PM +0000, Thomas Wood wrote:
> Signed-off-by: Thomas Wood <thomas.wood at intel.com>
> ---
> lib/igt_core.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index b98cb41..925d78c 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -366,6 +366,23 @@ static void low_mem_killer_disable(bool disable)
> }
>
> #define write_log_msg(x) write(STDERR_FILENO, x, strlen(x))
> +static void clear_log(void)
> +{
> + uint8_t i;
> +
> + pthread_mutex_lock(&log_buffer_mutex);
> +
> + i = 0;
> + do {
> + free(log_buffer.entries[i]);
> + log_buffer.entries[i] = NULL;
> + i++;
> + } while (i != 0);
> + log_buffer.start = 0;
> + log_buffer.end = 0;
> +
> + pthread_mutex_unlock(&log_buffer_mutex);
Too much work. Just log_buffer.start = log_buffer.end under the mutex.
The freeing of old entries will be done by new writers, or by process
termination.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list