From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756074AbbBRSnn (ORCPT ); Wed, 18 Feb 2015 13:43:43 -0500 Received: from terminus.zytor.com ([198.137.202.10]:41815 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755970AbbBRSmI (ORCPT ); Wed, 18 Feb 2015 13:42:08 -0500 Date: Wed, 18 Feb 2015 10:41:50 -0800 From: tip-bot for Kaixu Xia Message-ID: Cc: paulus@samba.org, acme@redhat.com, linux-kernel@vger.kernel.org, a.p.zijlstra@chello.nl, hpa@zytor.com, mingo@kernel.org, xiakaixu@huawei.com, tglx@linutronix.de Reply-To: hpa@zytor.com, xiakaixu@huawei.com, tglx@linutronix.de, mingo@kernel.org, paulus@samba.org, acme@redhat.com, linux-kernel@vger.kernel.org, a.p.zijlstra@chello.nl In-Reply-To: <1422352512-75150-1-git-send-email-xiakaixu@huawei.com> References: <1422352512-75150-1-git-send-email-xiakaixu@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf: Remove the extra validity check on nr_pages Git-Commit-ID: 74390aa5567827add5058a3b26eff0ed06a629ba 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 74390aa5567827add5058a3b26eff0ed06a629ba Gitweb: http://git.kernel.org/tip/74390aa5567827add5058a3b26eff0ed06a629ba Author: Kaixu Xia AuthorDate: Tue, 27 Jan 2015 17:55:12 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 13 Feb 2015 11:40:30 -0300 perf: Remove the extra validity check on nr_pages The function is_power_of_2() also do the check on nr_pages, so the first check performed is unnecessary. On the other hand, the key point is to ensure @nr_pages is a power-of-two number and mostly @nr_pages is a nonzero value, so in the most cases, the function is_power_of_2() will be called. Signed-off-by: Kaixu Xia Cc: Peter Zijlstra Cc: Paul Mackerras Link: http://lkml.kernel.org/r/1422352512-75150-1-git-send-email-xiakaixu@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 7f2fbb8..0969c9b 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4420,7 +4420,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma) * If we have rb pages ensure they're a power-of-two number, so we * can do bitmasks instead of modulo. */ - if (nr_pages != 0 && !is_power_of_2(nr_pages)) + if (!is_power_of_2(nr_pages)) return -EINVAL; if (vma_size != PAGE_SIZE * (1 + nr_pages))