Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1429382

Re: [PATCH v9 5/8] perf record: Toggle overwrite ring buffer for reading

From "Wangnan (F)" <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH v9 5/8] perf record: Toggle overwrite ring buffer for reading
Date 2016-06-23 03:30 +0200
Message-ID <rN1CW-2Rr-7@gated-at.bofh.it> (permalink)
References <rMMkx-1su-11@gated-at.bofh.it> <rMMue-1vP-9@gated-at.bofh.it> <rMRtT-4E1-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 2016/6/22 22:33, Nilay Vaish wrote:
> On 22 June 2016 at 04:08, Wang Nan <wangnan0@huawei.com> 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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v9 0/8] perf tools: Support overwritable ring buffer Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:10 +0200
  [PATCH v9 7/8] perf tools: Don't warn about out of order event if write_backward is used Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:10 +0200
  [PATCH v9 4/8] perf record: Introduce rec->overwrite_evlist for overwritable events Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:20 +0200
  [PATCH v9 2/8] perf tests: Add testcase for auxiliary evlist Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:20 +0200
  [PATCH v9 5/8] perf record: Toggle overwrite ring buffer for reading Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:20 +0200
    Re: [PATCH v9 5/8] perf record: Toggle overwrite ring buffer for reading Nilay Vaish <nilayvaish@gmail.com> - 2016-06-22 16:40 +0200
      Re: [PATCH v9 5/8] perf record: Toggle overwrite ring buffer for  reading "Wangnan (F)" <wangnan0@huawei.com> - 2016-06-23 03:30 +0200
  [PATCH v9 3/8] perf record: Extract perf_evlist__mmap_ex() processing to a new function Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:20 +0200
  [PATCH v9 6/8] perf tools: Enable overwrite settings Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:20 +0200
  [PATCH v9 8/8] perf tools: Add --tail-synthesize option Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:20 +0200
  [PATCH v9 1/8] perf evlist: Introduce aux evlist Wang Nan <wangnan0@huawei.com> - 2016-06-22 11:20 +0200
    Re: [PATCH v9 1/8] perf evlist: Introduce aux evlist Nilay Vaish <nilayvaish@gmail.com> - 2016-06-22 15:20 +0200
      Re: [PATCH v9 1/8] perf evlist: Introduce aux evlist Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-22 15:50 +0200
        Re: [PATCH v9 1/8] perf evlist: Introduce aux evlist "Wangnan (F)" <wangnan0@huawei.com> - 2016-06-23 03:40 +0200
    [PATCH v9.1] perf evlist: Introduce aux evlist Wang Nan <wangnan0@huawei.com> - 2016-06-23 04:20 +0200

csiph-web