From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755502AbbCCIoP (ORCPT ); Tue, 3 Mar 2015 03:44:15 -0500 Received: from mail-wg0-f53.google.com ([74.125.82.53]:33767 "EHLO mail-wg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751441AbbCCIoO (ORCPT ); Tue, 3 Mar 2015 03:44:14 -0500 Date: Tue, 3 Mar 2015 09:44:08 +0100 From: Ingo Molnar To: hpa@zytor.com, ak@linux.intel.com, acme@redhat.com, kan.liang@intel.com, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, xiakaixu@huawei.com, tglx@linutronix.de Cc: linux-tip-commits@vger.kernel.org Subject: Re: [tip:perf/core] Revert "perf: Remove the extra validity check on nr_pages" Message-ID: <20150303084407.GA1448@gmail.com> References: <1425280466-7830-1-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * tip-bot for Kan Liang wrote: > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -4446,7 +4446,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 (!is_power_of_2(nr_pages)) > + if (nr_pages != 0 && !is_power_of_2(nr_pages)) > return -EINVAL; Hm, what does is_power_of_2(0) return? It should return 0, because 0 is not a power of 2! and if it's fixed to return 0, then the check should properly be something like: if (!nr_pages || !is_power_of_2(nr_pages)) or so? Thanks, Ingo