From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755202AbbCFEYL (ORCPT ); Thu, 5 Mar 2015 23:24:11 -0500 Received: from lgeamrelo01.lge.com ([156.147.1.125]:34519 "EHLO lgeamrelo01.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbbCFEYG (ORCPT ); Thu, 5 Mar 2015 23:24:06 -0500 X-Original-SENDERIP: 10.177.220.203 X-Original-MAILFROM: namhyung@kernel.org Date: Fri, 6 Mar 2015 13:19:53 +0900 From: Namhyung Kim To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , Frederic Weisbecker , Adrian Hunter , Stephane Eranian , Andi Kleen , David Ahern Subject: Re: [PATCH 08/38] perf record: Add --index option for building index table Message-ID: <20150306041953.GB7872@sejong> References: <1425352070-1115-1-git-send-email-namhyung@kernel.org> <1425352070-1115-9-git-send-email-namhyung@kernel.org> <20150305075644.GA32252@krava.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150305075644.GA32252@krava.brq.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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