[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] trace: Add ftrace tracing backend
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] trace: Add ftrace tracing backend |
Date: |
Mon, 8 Apr 2013 16:10:54 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Apr 03, 2013 at 03:30:58PM +0900, Eiichi Tsukata wrote:
> diff --git a/scripts/tracetool/backend/ftrace.py
> b/scripts/tracetool/backend/ftrace.py
> new file mode 100644
> index 0000000..e02f0ca
> --- /dev/null
> +++ b/scripts/tracetool/backend/ftrace.py
> @@ -0,0 +1,53 @@
> +#!/usr/bin/env python
> +# -*- coding: utf-8 -*-
> +
> +"""
> +Ftrace built-in backend.
> +"""
> +
> +__author__ = "Eiichi Tsukata <address@hidden>"
> +__copyright__ = "Copyright (C) 2013 Hitachi, Ltd."
> +__license__ = "GPL version 2 or (at your option) any later version"
> +
> +__maintainer__ = "Stefan Hajnoczi"
> +__email__ = "address@hidden"
My email is now address@hidden I can fix this up when merging the
patch.
> + out('static inline void trace_%(name)s(%(args)s)',
> + '{',
> + ' char ftrace_buf[MAX_TRACE_STRLEN];',
> + ' int unused __attribute__ ((unused));'
> + ' bool _state = trace_event_get_state(%(event_id)s);',
> + ' if (_state) {',
> + ' snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
> + ' "%(name)s " %(fmt)s "\\n" %(argnames)s);',
> + ' unused = write(trace_marker_fd, ftrace_buf,',
> + ' MAX_TRACE_STRLEN);',
Looking at kernel/trace/trace.c:tracing_mark_write() the kernel will
memcpy() the full number of bytes we give.
You could use the snprintf(3) return value (number of characters
written, excluding NUL byte).
I think that would waste less trace buffer space.
Stefan