lkml.org 
[lkml]   [2015]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 08/38] perf record: Add --index option for building index table
On Thu, Mar 05, 2015 at 08:56:44AM +0100, Jiri Olsa wrote:
> On Tue, Mar 03, 2015 at 12:07:20PM +0900, Namhyung Kim wrote:
>
> SNIP
>
> > +static int record__merge_index_files(struct record *rec, int nr_index)
> > +{
> > + int i;
> > + int ret = -1;
> > + u64 offset;
> > + char path[PATH_MAX];
> > + struct perf_file_section *idx;
> > + struct perf_data_file *file = &rec->file;
> > + struct perf_session *session = rec->session;
> > + int output_fd = perf_data_file__fd(file);
> > +
> > + /* +1 for header file itself */
> > + nr_index++;
> > +
> > + idx = calloc(nr_index, sizeof(*idx));
> > + if (idx == NULL)
> > + goto out_close;
> > +
> > + offset = lseek(output_fd, 0, SEEK_END);
> > +
> > + idx[0].offset = session->header.data_offset;
> > + idx[0].size = offset - idx[0].offset;
> > +
> > + for (i = 1; i < nr_index; i++) {
> > + struct stat stbuf;
> > + int fd = rec->fds[i];
> > +
> > + if (fstat(fd, &stbuf) < 0)
> > + goto out_close;
> > +
> > + idx[i].offset = offset;
> > + idx[i].size = stbuf.st_size;
> > +
> > + offset += stbuf.st_size;
> > + }
> > +
> > + /* copy sample events */
> > + for (i = 1; i < nr_index; i++) {
> > + int fd = rec->fds[i];
> > +
> > + if (idx[i].size == 0)
> > + continue;
> > +
> > + if (copyfile_offset(fd, 0, output_fd, idx[i].offset,
> > + idx[i].size) < 0)
> > + goto out_close;
> > + }
>
> why not do the copy in previous loop as well?

I will change it in the next version.

Thanks,
Namhyung


\
 
 \ /
  Last update: 2015-03-06 05:41    [W:0.057 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site