Received: by 10.223.185.116 with SMTP id b49csp3558346wrg; Tue, 13 Feb 2018 04:18:03 -0800 (PST) X-Google-Smtp-Source: AH8x224qSdu26BpG0are47JnD+dQQOfkfS3u814draZ1BNDgjU1Ly1koLWQ49EDOJiXN5Q5ruXAP X-Received: by 10.98.17.156 with SMTP id 28mr1089235pfr.112.1518524282904; Tue, 13 Feb 2018 04:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518524282; cv=none; d=google.com; s=arc-20160816; b=ILxSfqTMo8UN0sGHN/Fbujpcw8m7wAXh+4h3fiwBGty11HGfOXoG/KY5sihlj6/jvN 2fcJq0pXIEU+FPOcwH0CGMmPHTvowv1y6pmv5sKOKlamIlDU8A/MZrdWq1/puaOiUhoD BkBrZjl9SThkLxq91lDHFYWBQ2naEHRSTE34S9n9ATzx1gNcGzl0Pg7IKgLSR5Pq2bQw nrI7JKl0sTyXIAoKH4TgaOPF3IwyN0qGygCc8sImpxy/TDdAascY0PkyGX31QNVH4X3w iS7oFintQlgZv3M85xwzBFFd070L+IVlL2CBdK577W7rTlMbA2g+4N2QyC5CkffxRW/4 rzEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=H0it19GnVLjtnrcr0bkW1HsHGO7RgncDUzqVPkgunvs=; b=wlu/eCzCUjgOHTg3Fi7m+DcYYrPE5C7QoVyx9/Lir+9jK8poFnSJByKh1Xq6CGk0dS guAX4IA1QcbSLmEXKTnKowJy4u0lVO0g2IZaPs3IF8v9Gl7e6hilKYxz3K8W0lKJhCYk Tfzy00F9r1p6i82SqMOD2oHDDdOOXkaChj4blU2nfAF/kcOhErwNRLDdEv0RKxq0xlbe HWTcaCi+am5I/Lv/w/pjLUfX/ZdRx5b7XLas+HHY95u+CArUrbgDbLWhI4tMRc8BPvjs zPkpidDAKbYo1lWf55EF8mMfNuMrpR/XsONZ6vaGQMfuw8wWP8XseIUHvfjArF584nkM 7MUQ== 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 s67si1666874pgb.64.2018.02.13.04.17.48; Tue, 13 Feb 2018 04:18:02 -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 S935204AbeBMMQe (ORCPT + 99 others); Tue, 13 Feb 2018 07:16:34 -0500 Received: from terminus.zytor.com ([198.137.202.136]:59827 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934944AbeBMMQc (ORCPT ); Tue, 13 Feb 2018 07:16:32 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1DC65i5028486; Tue, 13 Feb 2018 04:06:05 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1DC65rY028483; Tue, 13 Feb 2018 04:06:05 -0800 Date: Tue, 13 Feb 2018 04:06:05 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Kan Liang Message-ID: Cc: hpa@zytor.com, kan.liang@intel.com, jolsa@kernel.org, yao.jin@linux.intel.com, peterz@infradead.org, wangnan0@huawei.com, mingo@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org, ak@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org Reply-To: ak@linux.intel.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org, wangnan0@huawei.com, acme@redhat.com, jolsa@kernel.org, yao.jin@linux.intel.com, hpa@zytor.com, kan.liang@intel.com In-Reply-To: <1516310792-208685-6-git-send-email-kan.liang@intel.com> References: <1516310792-208685-6-git-send-email-kan.liang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf mmap: Add new return value logic for perf_mmap__read_init() Git-Commit-ID: e0c75323e9f7002d84abbf68650277a6d971b3c0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e0c75323e9f7002d84abbf68650277a6d971b3c0 Gitweb: https://git.kernel.org/tip/e0c75323e9f7002d84abbf68650277a6d971b3c0 Author: Kan Liang AuthorDate: Thu, 18 Jan 2018 13:26:20 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 6 Feb 2018 10:11:49 -0300 perf mmap: Add new return value logic for perf_mmap__read_init() Improve the readability by using meaningful enum (-EAGAIN, -EINVAL and 0) to replace the three returning states (0, -1 and 1). Suggested-by: Wang Nan Signed-off-by: Kan Liang Acked-by: Jiri Olsa Cc: Andi Kleen Cc: Jin Yao Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1516310792-208685-6-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/mmap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index c19a4e6..38fa69d 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -282,7 +282,7 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, *endp = overwrite ? old : head; if (*startp == *endp) - return 0; + return -EAGAIN; size = *endp - *startp; if (size > (unsigned long)(md->mask) + 1) { @@ -291,7 +291,7 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, md->prev = head; perf_mmap__consume(md, overwrite); - return 0; + return -EAGAIN; } /* @@ -299,10 +299,10 @@ int perf_mmap__read_init(struct perf_mmap *md, bool overwrite, * most of data from it. */ if (overwrite_rb_find_range(data, md->mask, head, startp, endp)) - return -1; + return -EINVAL; } - return 1; + return 0; } int perf_mmap__push(struct perf_mmap *md, bool overwrite, @@ -316,8 +316,8 @@ int perf_mmap__push(struct perf_mmap *md, bool overwrite, int rc = 0; rc = perf_mmap__read_init(md, overwrite, &start, &end); - if (rc < 1) - return rc; + if (rc < 0) + return (rc == -EAGAIN) ? 0 : -1; size = end - start;