From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751325AbcGOO7l (ORCPT ); Fri, 15 Jul 2016 10:59:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51301 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750894AbcGOO7i (ORCPT ); Fri, 15 Jul 2016 10:59:38 -0400 Date: Fri, 15 Jul 2016 16:59:35 +0200 From: Jiri Olsa To: Wang Nan Cc: acme@kernel.org, lizefan@huawei.com, linux-kernel@vger.kernel.org, pi3orama@163.com, Arnaldo Carvalho de Melo , He Kuang , Jiri Olsa , Masami Hiramatsu , Namhyung Kim , Nilay Vaish Subject: Re: [PATCH v16 05/15] perf tools: Record mmap cookie into fdarray private field Message-ID: <20160715145935.GB29695@krava> References: <1468485287-33422-1-git-send-email-wangnan0@huawei.com> <1468485287-33422-6-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1468485287-33422-6-git-send-email-wangnan0@huawei.com> User-Agent: Mutt/1.6.2 (2016-07-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 15 Jul 2016 14:59:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 14, 2016 at 08:34:37AM +0000, Wang Nan wrote: > Insetad of saving a index into fdarray entries private field, save the > corresponding 'struct perf_mmap' pointer, and release them directly > using perf_mmap__put(). > > Following commits introduce multiple mmap arrays to evlist. Without this > patch, perf_evlist__munmap_filtered() is unable to retrive correct > 'struct perf_mmap' pointer. > > Signed-off-by: Wang Nan > Cc: Arnaldo Carvalho de Melo > Cc: He Kuang > Cc: Jiri Olsa > Cc: Masami Hiramatsu > Cc: Namhyung Kim > Cc: Zefan Li > Cc: Nilay Vaish > Cc: pi3orama@163.com > --- > tools/perf/util/evlist.c | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index a4137e0..1462085 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -30,6 +30,7 @@ > static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx); > static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx); > static void perf_mmap__munmap(struct perf_mmap *map); > +static void perf_mmap__put(struct perf_mmap *map); > > #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) > #define SID(e, x, y) xyarray__entry(e->sample_id, x, y) > @@ -466,7 +467,8 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) > return 0; > } > > -static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx, short revent) > +static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, > + struct perf_mmap *map, short revent) > { > int pos = fdarray__add(&evlist->pollfd, fd, revent | POLLERR | POLLHUP); > /* > @@ -474,7 +476,7 @@ static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx > * close the associated evlist->mmap[] entry. > */ > if (pos >= 0) { > - evlist->pollfd.priv[pos].idx = idx; > + evlist->pollfd.priv[pos].ptr = map; looks like there's no user for idx now, patch below compiles for me I guess we should remove it.. jirka --- diff --git a/tools/lib/api/fd/array.h b/tools/lib/api/fd/array.h index 71287dddc05f..54041a4ded39 100644 --- a/tools/lib/api/fd/array.h +++ b/tools/lib/api/fd/array.h @@ -21,7 +21,6 @@ struct fdarray { int nr_autogrow; struct pollfd *entries; union { - int idx; void *ptr; } *priv; };