From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung.kim@lge.com>,
LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH 4/8] perf tools: Introduce struct perf_log
Date: Fri, 03 Jan 2014 17:23:05 +0900 [thread overview]
Message-ID: <87a9fdfp92.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <20131226145051.GG30980@ghostprotocols.net> (Arnaldo Carvalho de Melo's message of "Thu, 26 Dec 2013 11:50:51 -0300")
Hi Arnaldo,
On Thu, 26 Dec 2013 11:50:51 -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Dec 26, 2013 at 02:38:00PM +0900, Namhyung Kim escreveu:
>> From: Namhyung Kim <namhyung.kim@lge.com>
>>
>> Add new functions to save error messages in a temp file. It'll be
>> used by some UI front-ends to see the messages.
[SNIP]
>> +struct perf_log {
>> + FILE *fp;
>> + off_t *linemap;
>> + u32 lines;
>> + u32 nr_alloc;
>> + bool seen_newline;
>> +};
>> +
>> +extern struct perf_log perf_log;
>> +
>> +int perf_log_init(void);
>> +int perf_log_exit(void);
>> +void perf_log_add(const char *msg);
>> +void perf_log_addv(const char *fmt, va_list ap);
>
> The convention in tools/perf/ has been to use class__method, i.e. in the
> above case we would have:
>
> int perf_log__init(void);
> int perf_log__exit(void);
> void perf_log__add(const char *msg);
> void perf_log__addv(const char *fmt, va_list ap);
Okay. (I wasn't follow the convention since the functions do not pass
the perf_log as an argument, but I agree it's better to follow it.)
Will change.
>
>
> But I have some questions about the implementation, will we go on
> allocating memory for each and every line?
Yes, it needs an offset for each line in order to find starting point.
>
> Can't we just come out with a simple ui_file_browser class that would
> then be usable for any file, including this one?
Yes we can do it if need be. Do you think of another use case?
>
> The ui_file_browser__seek() method would have to go on reading lines and
> seeking newlines, with the ui_file_browser__seek(browser, 0, SEEK_SET)
> would map directly to fseek(log_fp, 0, SEEK_SET), etc.
It supposed to. But in this case, the ->seek() method is called in
ui_browser__run() which is not protected by ui__lock. So it's possible
that new log message alters file position if it's called after ->seek()
method was executed.
If it's guaranteed that there's no concurrent access to the file, we can
move fseek() to the ->seek() method IMHO.
>
> It should handle "live" files, like the one we're feeding log lines,
> etc.
>
> The way you implemented it will grow memory consumption without
> limits, no?
Right, it'll consume 8 bytes for each line of the file. What's the
reasonable limitation?
Thanks,
Namhyung
next prev parent reply other threads:[~2014-01-03 8:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-26 5:37 [PATCHSET 0/8] perf tools: A couple of TUI improvements (v3) Namhyung Kim
2013-12-26 5:37 ` [PATCH 1/8] perf ui/tui: Protect windows by ui__lock Namhyung Kim
2014-01-12 18:39 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-26 5:37 ` [PATCH 2/8] perf ui/tui: Split help message for perf top and report Namhyung Kim
2013-12-26 14:05 ` Arnaldo Carvalho de Melo
2013-12-26 14:12 ` Arnaldo Carvalho de Melo
2014-01-12 18:39 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-26 5:37 ` [PATCH 3/8] perf ui/tui: Implement header window Namhyung Kim
2014-01-12 18:39 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-26 5:38 ` [PATCH 4/8] perf tools: Introduce struct perf_log Namhyung Kim
2013-12-26 14:50 ` Arnaldo Carvalho de Melo
2014-01-03 8:23 ` Namhyung Kim [this message]
2013-12-26 14:51 ` David Ahern
2014-01-03 8:49 ` Namhyung Kim
2013-12-26 5:38 ` [PATCH 5/8] perf tools: Save message when pr_*() was called Namhyung Kim
2013-12-26 5:38 ` [PATCH 6/8] perf ui/tui: Implement log window Namhyung Kim
2013-12-26 5:38 ` [PATCH 7/8] perf ui/tui: Filter messages in " Namhyung Kim
2013-12-26 5:38 ` [PATCH 8/8] perf ui/tui: Remember last log line for filtering Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a9fdfp92.fsf@sejong.aot.lge.com \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.