From patchwork Mon Jan 11 13:48:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 59507 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2122614lbb; Mon, 11 Jan 2016 05:53:08 -0800 (PST) X-Received: by 10.66.156.106 with SMTP id wd10mr181164864pab.150.1452520388472; Mon, 11 Jan 2016 05:53:08 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si40336195pat.37.2016.01.11.05.53.08; Mon, 11 Jan 2016 05:53:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760171AbcAKNt6 (ORCPT + 29 others); Mon, 11 Jan 2016 08:49:58 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:11633 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760109AbcAKNtz (ORCPT ); Mon, 11 Jan 2016 08:49:55 -0500 Received: from 172.24.1.47 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.47]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CZQ72446; Mon, 11 Jan 2016 21:49:42 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Mon, 11 Jan 2016 21:49:32 +0800 From: Wang Nan To: CC: , , , , , Wang Nan , He Kuang , "Arnaldo Carvalho de Melo" , Jiri Olsa , Masami Hiramatsu , Namhyung Kim Subject: [PATCH 52/53] perf record: Toggle tailsize ring buffer for reading Date: Mon, 11 Jan 2016 13:48:43 +0000 Message-ID: <1452520124-2073-53-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1452520124-2073-1-git-send-email-wangnan0@huawei.com> References: <1452520124-2073-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5693B2F7.000D, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: fc66c8bebac95e97671c480cd5b0268b Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Toggel tailsize_evt_stopped director after receiving done or switch output. After this patch it is possible to trigger a dump use SIGUSR2 when something happen. Signed-off-by: Wang Nan Signed-off-by: He Kuang Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3orama@163.com --- tools/perf/builtin-record.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) -- 1.8.3.4 diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 6c8905b..6ec0529 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -591,6 +591,26 @@ static void record__init_features(struct record *rec) } static void +record__toggle_tailsize_evsels(struct record *rec, bool stop) +{ + struct perf_evsel *pos; + struct perf_evlist *evlist = rec->evlist; + + evlist__for_each(evlist, pos) { + if (!pos->tailsize) + continue; + if (!pos->overwrite) + continue; + if (stop) + perf_evsel__disable(pos); + else + perf_evsel__enable(pos); + } + + rec->tailsize_evt_stopped = stop; +} + +static void record__finish_output(struct record *rec) { struct perf_data_file *file = &rec->file; @@ -925,6 +945,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) for (;;) { unsigned long long hits = rec->samples; + if (switch_output_started || done) + record__toggle_tailsize_evsels(rec, true); + if (record__mmap_read_all(rec) < 0) { auxtrace_snapshot_disable(); err = -1; @@ -943,7 +966,20 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) } if (switch_output_started) { + /* + * SIGUSR2 raise after or during record__mmap_read_all(). + * continue to read again. + */ + if (!rec->tailsize_evt_stopped) + continue; + switch_output_started = 0; + /* + * Reenable events in tailsize ring buffer after + * record__mmap_read_all(): we have collected + * data from it. + */ + record__toggle_tailsize_evsels(rec, false); if (!quiet) fprintf(stderr, "[ perf record: dump data: Woken up %ld times ]\n",