From patchwork Mon Jan 11 13:48:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 59536 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2133037lbb; Mon, 11 Jan 2016 06:10:01 -0800 (PST) X-Received: by 10.66.97.5 with SMTP id dw5mr91584534pab.27.1452521396642; Mon, 11 Jan 2016 06:09:56 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si19529008pat.126.2016.01.11.06.09.56; Mon, 11 Jan 2016 06:09:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933454AbcAKOJE (ORCPT + 4 others); Mon, 11 Jan 2016 09:09:04 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:50059 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933178AbcAKOJB (ORCPT ); Mon, 11 Jan 2016 09:09:01 -0500 Received: from 172.24.1.51 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.51]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DCU72342; Mon, 11 Jan 2016 21:49:25 +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:12 +0800 From: Wang Nan To: CC: , , , , , Wang Nan , He Kuang , "Arnaldo Carvalho de Melo" , Jiri Olsa , Masami Hiramatsu , Namhyung Kim Subject: [PATCH 29/53] perf tools: Make ordered_events reusable Date: Mon, 11 Jan 2016 13:48:20 +0000 Message-ID: <1452520124-2073-30-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.0A020202.5693B2E5.0167, 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: 76a4bc9b38bd4aac8498c7918737da74 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org ordered_events__free() leaves linked lists and timestamps not cleared. Introduce ordered_events__reset() to reinit ordered_events so it can be reused again. 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/util/ordered-events.c | 9 +++++++++ tools/perf/util/ordered-events.h | 1 + tools/perf/util/session.c | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) -- 1.8.3.4 diff --git a/tools/perf/util/ordered-events.c b/tools/perf/util/ordered-events.c index b1b9e23..81daada 100644 --- a/tools/perf/util/ordered-events.c +++ b/tools/perf/util/ordered-events.c @@ -308,3 +308,12 @@ void ordered_events__free(struct ordered_events *oe) free(event); } } + +void ordered_events__reset(struct ordered_events *oe) +{ + ordered_events__deliver_t old_deliver = oe->deliver; + + ordered_events__free(oe); + memset(oe, '\0', sizeof(*oe)); + ordered_events__init(oe, old_deliver); +} diff --git a/tools/perf/util/ordered-events.h b/tools/perf/util/ordered-events.h index f403991..77e0f1b 100644 --- a/tools/perf/util/ordered-events.h +++ b/tools/perf/util/ordered-events.h @@ -49,6 +49,7 @@ void ordered_events__delete(struct ordered_events *oe, struct ordered_event *eve int ordered_events__flush(struct ordered_events *oe, enum oe_flush how); void ordered_events__init(struct ordered_events *oe, ordered_events__deliver_t deliver); void ordered_events__free(struct ordered_events *oe); +void ordered_events__reset(struct ordered_events *oe); static inline void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index d5636ba..96e10d2 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1701,7 +1701,7 @@ done: out_err: free(buf); perf_session__warn_about_errors(session); - ordered_events__free(&session->ordered_events); + ordered_events__reset(&session->ordered_events); auxtrace__free_events(session); return err; } @@ -1857,7 +1857,7 @@ out: out_err: ui_progress__finish(); perf_session__warn_about_errors(session); - ordered_events__free(&session->ordered_events); + ordered_events__reset(&session->ordered_events); auxtrace__free_events(session); session->one_mmap = false; return err;