From patchwork Wed Dec 6 14:41:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 120859 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7142418qgn; Wed, 6 Dec 2017 06:45:19 -0800 (PST) X-Google-Smtp-Source: AGs4zMalILI7/1xUaXIxsq4cI8qM/kgg9FZ3aSaVyg+UEzLaFLrHQmwrlO0AIiL5a4iA3Pgkhqhn X-Received: by 10.84.193.129 with SMTP id f1mr22332333pld.355.1512571519284; Wed, 06 Dec 2017 06:45:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512571519; cv=none; d=google.com; s=arc-20160816; b=d57hFKAJswhDS4DKErt9zRCb6J9GwWSvoFud48YDHP/8Dvc49XmjJGXPk571kkqiDo pa764GrHNZieIVFMPNZo5k0lI7Q8JnsLmBLm8+nrZ0dQljixo32al0QGzrvRKtSIJvmQ Jx6eMF+5hJ0ypHiPHi5/JkhQ0qHD2rrSdcyw5GGmCnlWKsQoDXrkZAmOgX9yHV28SLxi pkYsC7HEtTGGaLiJOxSH4s2YfjB4EPJTHFv+YgNz5ZliWGP8vpSCdoQ6o21j9UngdsNA Di/LkT5HJJ/fR/Sfewid098LFmV1sZxzvUrPFI9QM/loEYmlN/lm1HvpIk3qRD9QZ92q Kpyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=ND8P0RKy/zOIgD1MBx1Xt0Fp5i0T0kN9y1/obsjqjHk=; b=aJvhApBnhDdSORLrZrNPhXBCv1IA3z9bz9aK3G6YTIWKyF4QQDQ/yLFiEw5gm5RvW5 RlPszDokiftA46lpOHvR7j2Gv0IbbLfqEnsrMINjyLFPGd/WoLlb1CwopHjn9MUAb0xk JSNwaj3arPj/3BHVXGJfKrqWEytUgurzhanhM0UWzCRATYo3SF6oF99qJy7i/bV1hP90 8t8CZ+k37zwOImMs/L1GbgAN2qG23Em9L1r7JjgIJhxPaDmU/D+Q1ihaCSd9zVSg+Ljl HHk4CGL/yPFKdCFgSMnopoWnSWxHK0NPoBTkS9ufzMoNKHXN48ksu5xDV8q3nvEZFEVz yXMA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si2082372plt.372.2017.12.06.06.45.19; Wed, 06 Dec 2017 06:45:19 -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 S1753085AbdLFOpQ (ORCPT + 28 others); Wed, 6 Dec 2017 09:45:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:58470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752881AbdLFOnY (ORCPT ); Wed, 6 Dec 2017 09:43:24 -0500 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D6B8219A9; Wed, 6 Dec 2017 14:43:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D6B8219A9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Wang Nan , Jiri Olsa , Kan Liang , Arnaldo Carvalho de Melo Subject: [PATCH 29/36] perf mmap: Remove overwrite and check_messup from mmap read Date: Wed, 6 Dec 2017 11:41:08 -0300 Message-Id: <20171206144115.15097-30-acme@kernel.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171206144115.15097-1-acme@kernel.org> References: <20171206144115.15097-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Nan All perf_mmap__read_forward() read from read-write ring buffer, so no need check_messup. Reading from backward ring buffer doesn't require check_messup because it never mess up. Cleanup arguments lists. Signed-off-by: Wang Nan Acked-by: Namhyung Kim Cc: Jiri Olsa Cc: Kan Liang Link: http://lkml.kernel.org/r/20171203020044.81680-6-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 2 +- tools/perf/util/mmap.c | 28 ++++------------------------ tools/perf/util/mmap.h | 2 +- 3 files changed, 6 insertions(+), 26 deletions(-) -- 2.13.6 diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index a59134fb141f..68c1f9546650 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -711,7 +711,7 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int * No need for read-write ring buffer: kernel stop outputting when * it hit md->prev (perf_mmap__consume()). */ - return perf_mmap__read_forward(md, false); + return perf_mmap__read_forward(md); } union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 703ed41a9269..3f262e707a41 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -21,33 +21,13 @@ size_t perf_mmap__mmap_len(struct perf_mmap *map) } /* When check_messup is true, 'end' must points to a good entry */ -static union perf_event *perf_mmap__read(struct perf_mmap *map, bool check_messup, +static union perf_event *perf_mmap__read(struct perf_mmap *map, u64 start, u64 end, u64 *prev) { unsigned char *data = map->base + page_size; union perf_event *event = NULL; int diff = end - start; - if (check_messup) { - /* - * If we're further behind than half the buffer, there's a chance - * the writer will bite our tail and mess up the samples under us. - * - * If we somehow ended up ahead of the 'end', we got messed up. - * - * In either case, truncate and restart at 'end'. - */ - if (diff > map->mask / 2 || diff < 0) { - fprintf(stderr, "WARNING: failed to keep up with mmap data.\n"); - - /* - * 'end' points to a known good entry, start there. - */ - start = end; - diff = 0; - } - } - if (diff >= (int)sizeof(event->header)) { size_t size; @@ -89,7 +69,7 @@ static union perf_event *perf_mmap__read(struct perf_mmap *map, bool check_messu return event; } -union perf_event *perf_mmap__read_forward(struct perf_mmap *map, bool check_messup) +union perf_event *perf_mmap__read_forward(struct perf_mmap *map) { u64 head; u64 old = map->prev; @@ -102,7 +82,7 @@ union perf_event *perf_mmap__read_forward(struct perf_mmap *map, bool check_mess head = perf_mmap__read_head(map); - return perf_mmap__read(map, check_messup, old, head, &map->prev); + return perf_mmap__read(map, old, head, &map->prev); } union perf_event *perf_mmap__read_backward(struct perf_mmap *map) @@ -138,7 +118,7 @@ union perf_event *perf_mmap__read_backward(struct perf_mmap *map) else end = head + map->mask + 1; - return perf_mmap__read(map, false, start, end, &map->prev); + return perf_mmap__read(map, start, end, &map->prev); } void perf_mmap__read_catchup(struct perf_mmap *map) diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index 2c3d291785de..d640273b7762 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -86,7 +86,7 @@ static inline void perf_mmap__write_tail(struct perf_mmap *md, u64 tail) pc->data_tail = tail; } -union perf_event *perf_mmap__read_forward(struct perf_mmap *map, bool check_messup); +union perf_event *perf_mmap__read_forward(struct perf_mmap *map); union perf_event *perf_mmap__read_backward(struct perf_mmap *map); int perf_mmap__push(struct perf_mmap *md, bool backward,