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 <eiichi.tsukata...@hitachi.com>" > +__copyright__ = "Copyright (C) 2013 Hitachi, Ltd." > +__license__ = "GPL version 2 or (at your option) any later version" > + > +__maintainer__ = "Stefan Hajnoczi" > +__email__ = "stefa...@linux.vnet.ibm.com"
My email is now stefa...@redhat.com. 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