Received: by 10.223.185.116 with SMTP id b49csp1019261wrg; Fri, 16 Feb 2018 10:56:04 -0800 (PST) X-Google-Smtp-Source: AH8x225VD9wW1P5pM+4L9B+NHLuv3ljC8d4sdOowuCgcfgjf3/kIpng9mAbObLRSjRYpVcjXRfwX X-Received: by 10.99.151.74 with SMTP id d10mr5868753pgo.258.1518807364387; Fri, 16 Feb 2018 10:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518807364; cv=none; d=google.com; s=arc-20160816; b=EkmAoQUMKrzcqppg8il5qE8nF/M3ZXPAOG6bwiMLo45WEKVh9OWRIhaLGKf0HnZhqE 9fyBngtIr02VdxDb4bx17hn7msfkxcy1YFPYcpaR1RM64kend+hHmOIUrhKiGhgAv92F sBKbi+q5aZCFcsgI6Qo9Oqct3M1ZmMDEt170dMDrDRmCKWP8sqS4mYxc2JlsnSGF8GNS H7KOuEORNKiQjyduaU0KZDykZQfh3pFcih34a4KUg+JIW1AV3cdhOViCYkLnVl+IVS/O +i8GPSzaDkE3lvPnmZlnQYpmBhFpEgetC8jMinsurLmZ6DszpGZ9PBLY5sRQXlBl111W hZCQ== 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=fFy1c5jbnRYDyio2wExs+FIkLyd1mgEitDwchJBdvIc=; b=Z0rmQBqLjsDOTKc+ijV0awrf+eHWKk3SgxdbMxuei1zqv5T9r7B3m8Tmn5gkHC11vw kM4GysF1A3DNrh8qAKfysm9Ng7CqQfubEeM5WE1i8k9UiKLlTlbIap3OurdvD/sNexxj bR2CnQP+C/sRkqo9RONIq0e3SS4JOdQ/ClTLkN0GH8bgdqIjrmyZh+UwhWeRFwN6dmVz oyi2d8jYOjA82f3zQAF7Imgu31rt9ySiePSfUriwrjmkV4/I54DRoWylKDdT1RADAFD1 4zjLw8Vw87ExUXhh+uJWJYmoi4fwjU92b1346mMvU5ujBkfwrwgwKe+nsAIuYFPMz/mC mtXg== 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 m4si6127260pgd.450.2018.02.16.10.55.49; Fri, 16 Feb 2018 10:56:04 -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 S932732AbeBPJvH (ORCPT + 99 others); Fri, 16 Feb 2018 04:51:07 -0500 Received: from terminus.zytor.com ([198.137.202.136]:58853 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932472AbeBPJvD (ORCPT ); Fri, 16 Feb 2018 04:51:03 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w1G9aL60021726; Fri, 16 Feb 2018 01:36:21 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w1G9aLr0021723; Fri, 16 Feb 2018 01:36:21 -0800 Date: Fri, 16 Feb 2018 01:36:21 -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: acme@redhat.com, mingo@kernel.org, ak@linux.intel.com, tglx@linutronix.de, kan.liang@intel.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, namhyung@kernel.org, wangnan0@huawei.com, hpa@zytor.com, peterz@infradead.org, yao.jin@linux.intel.com Reply-To: acme@redhat.com, mingo@kernel.org, ak@linux.intel.com, tglx@linutronix.de, kan.liang@intel.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, wangnan0@huawei.com, namhyung@kernel.org, yao.jin@linux.intel.com, peterz@infradead.org, hpa@zytor.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: 189f2cc91f9f2efef5d5f4dde43684c01b5f6f2f 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: 189f2cc91f9f2efef5d5f4dde43684c01b5f6f2f Gitweb: https://git.kernel.org/tip/189f2cc91f9f2efef5d5f4dde43684c01b5f6f2f Author: Kan Liang AuthorDate: Thu, 18 Jan 2018 13:26:20 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 15 Feb 2018 09:52: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;