From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752576AbbJENqr (ORCPT ); Mon, 5 Oct 2015 09:46:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55355 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751385AbbJENqq (ORCPT ); Mon, 5 Oct 2015 09:46:46 -0400 Date: Mon, 5 Oct 2015 15:46:41 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , Frederic Weisbecker , Stephane Eranian , David Ahern , Andi Kleen Subject: Re: [RFC/PATCH 09/38] perf record: Add --index option for building index table Message-ID: <20151005134641.GC26800@krava.landal.opennet> References: <1443763159-29098-1-git-send-email-namhyung@kernel.org> <1443763159-29098-10-git-send-email-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1443763159-29098-10-git-send-email-namhyung@kernel.org> 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 Fri, Oct 02, 2015 at 02:18:50PM +0900, Namhyung Kim wrote: SNIP > +static int record__merge_index_files(struct record *rec, int nr_index) > +{ > + int i; > + int ret = -ENOMEM; > + 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 - 1]; > + > + ret = fstat(fd, &stbuf); > + if (ret < 0) > + goto out_close; > + > + idx[i].offset = offset; > + idx[i].size = stbuf.st_size; > + > + offset += stbuf.st_size; > + > + if (idx[i].size == 0) > + continue; > + > + ret = copyfile_offset(fd, 0, output_fd, idx[i].offset, > + idx[i].size); > + if (ret < 0) > + goto out_close; > + } > + > + session->header.index = idx; > + session->header.nr_index = nr_index; > + > + perf_has_index = true; I might have asked earlier, but why is this global? seems like perf_session member to me.. thanks, jirka