From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751919AbcFWBT7 (ORCPT ); Wed, 22 Jun 2016 21:19:59 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:41776 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751772AbcFWBT5 (ORCPT ); Wed, 22 Jun 2016 21:19:57 -0400 Subject: Re: [PATCH v9 5/8] perf record: Toggle overwrite ring buffer for reading To: Nilay Vaish References: <1466586531-89751-1-git-send-email-wangnan0@huawei.com> <1466586531-89751-6-git-send-email-wangnan0@huawei.com> CC: , Linux Kernel list , , He Kuang , Arnaldo Carvalho de Melo , Jiri Olsa , Masami Hiramatsu , Namhyung Kim , Zefan Li From: "Wangnan (F)" Message-ID: <576B3923.2020909@huawei.com> Date: Thu, 23 Jun 2016 09:19:31 +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: 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.0A020203.576B3938.01A6,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: fabbfc2da137f649b6fdd7261fe86268 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/6/22 22:33, Nilay Vaish wrote: > On 22 June 2016 at 04:08, Wang Nan wrote: >> @@ -549,17 +573,72 @@ static struct perf_event_header finished_round_event = { >> .type = PERF_RECORD_FINISHED_ROUND, >> }; >> >> -static int record__mmap_read_all(struct record *rec) >> +static void >> +record__toggle_overwrite_evsels(struct record *rec, >> + enum overwrite_evt_state state) >> +{ >> + struct perf_evlist *evlist = rec->overwrite_evlist; >> + enum overwrite_evt_state old_state = rec->overwrite_evt_state; >> + enum action { >> + NONE, >> + PAUSE, >> + RESUME, >> + } action = NONE; >> + >> + switch (old_state) { >> + case OVERWRITE_EVT_RUNNING: >> + if (state != OVERWRITE_EVT_RUNNING) >> + action = PAUSE; >> + break; >> + case OVERWRITE_EVT_DATA_PENDING: >> + if (state == OVERWRITE_EVT_RUNNING) >> + action = RESUME; >> + break; >> + case OVERWRITE_EVT_EMPTY: >> + if (state == OVERWRITE_EVT_RUNNING) >> + action = RESUME; >> + if (state == OVERWRITE_EVT_DATA_PENDING) >> + state = OVERWRITE_EVT_EMPTY; > else if (state == OVERWRITE_EVT_DATA_PENDING) You are right, but I believe compiler makes identical binaries even without 'else'. With no 'else' these two 'if' are aligned. I'll recheck this patch. >> + break; >> + default: >> + WARN_ONCE(1, "Shouldn't get there\n"); >> + } >> + >> + rec->overwrite_evt_state = state; >> + >> + if (action == NONE) >> + return; > I think the above two lines are not required. The switch below should > be enough. > >> + >> + if (!evlist) >> + return; >> + >> + switch (action) { >> + case PAUSE: >> + perf_evlist__pause(evlist); >> + break; >> + case RESUME: >> + perf_evlist__resume(evlist); >> + break; >> + case NONE: >> + default: >> + break; >> + } >> +} >> + > -- > Nilay