From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750875AbcFVEMq (ORCPT ); Wed, 22 Jun 2016 00:12:46 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:44406 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750719AbcFVEMl (ORCPT ); Wed, 22 Jun 2016 00:12:41 -0400 Subject: Re: [PATCH v8 3/8] perf tests: Add testcase for auxiliary evlist To: Arnaldo Carvalho de Melo References: <1466419645-75551-1-git-send-email-wangnan0@huawei.com> <1466419645-75551-4-git-send-email-wangnan0@huawei.com> <20160621210538.GE4213@kernel.org> CC: , , "Arnaldo Carvalho de Melo" , Jiri Olsa , Masami Hiramatsu , Namhyung Kim , Zefan Li , He Kuang From: "Wangnan (F)" Message-ID: <576A0FB9.30907@huawei.com> Date: Wed, 22 Jun 2016 12:10:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160621210538.GE4213@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.576A0FD7.000B,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 06d90f6d24d454eff8e4ff0193323159 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/6/22 5:05, Arnaldo Carvalho de Melo wrote: > Em Mon, Jun 20, 2016 at 10:47:20AM +0000, Wang Nan escreveu: >> Improve test backward [SNIP] >> >> diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c >> index d9ba991..76e34c0 100644 >> --- a/tools/perf/tests/backward-ring-buffer.c >> +++ b/tools/perf/tests/backward-ring-buffer.c >> @@ -31,16 +31,19 @@ static int count_samples(struct perf_evlist *evlist, int *sample_count, >> for (i = 0; i < evlist->nr_mmaps; i++) { >> union perf_event *event; >> >> - perf_evlist__mmap_read_catchup(evlist, i); >> - while ((event = perf_evlist__mmap_read_backward(evlist, i)) != NULL) { >> + if (evlist->backward) >> + perf_evlist__mmap_read_catchup(evlist, i); > So, shouldn't this be done at perf_evlist__mmap_read_catchup()? I.e. you > will use this only when you know that one of the evlists count_samples() > will deal with can be a backwards one... > > I.e. do with perf_evlist__mmap_read_catchup the same thing you did in > perf_evlist__mmap_read, checking there this evlist->backward. I can make the code clearer, but I don't agree hiding evlist->backward checker in perf_evlist__mmap_read_catchup(): 1. If we make perf_evlist__mmap_read_catchup() implicitly ignore non-backward evlist, then we are creating a new rule for reading from mmaps that, before calling perf_evlist__mmap_read() we need to call perf_evlist__mmap_read_catchup() first. Theoretically, existing code should be adjusted to satisify this new rule, but actually most of catchup does nothing. If we don't require existing code be adjusted, then we are still required to clarify when catchup() is required, so evlist->backward is still exposed. 2. I think we don't need to restrict perf_evlist__mmap_read_catchup() for backward ring buffer. It is a generic operations, can be used for a normal evlist to consume existing data in ring buffer. > This can be done on top, so I'll continue tentatively merging this. > >> + while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) { >> const u32 type = event->header.type; >> >> switch (type) { >> case PERF_RECORD_SAMPLE: >> - (*sample_count)++; >> + if (sample_count) >> + (*sample_count)++; >> break; >> case PERF_RECORD_COMM: >> - (*comm_count)++; >> + if (comm_count) >> + (*comm_count)++; > You could've avoided all this by passing some dummy integer pointer for > the enter_sample_count case. Making the patch smaller helps reviewing > :-) Will do. Thank you.