From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f195.google.com ([209.85.192.195]:32884 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750904AbcFVGIv (ORCPT ); Wed, 22 Jun 2016 02:08:51 -0400 Date: Wed, 22 Jun 2016 14:06:21 +0800 From: Minfei Huang To: Al Viro Cc: bcrl@kvack.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-kernel@vger.kernel.org, minfei.hmf@alibaba-inc.com Subject: Re: [PATCH] aio: Cleanup unnecessary test for nr_pages Message-ID: <20160622060621.GA96186@MinfeideMacBook-Pro.local> References: <1465749234-25746-1-git-send-email-mnghuan@gmail.com> <20160620140545.GA87874@MinfeideMacBook-Pro.local> <20160620141739.GK14480@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160620141739.GK14480@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 06/20/16 at 03:17P, Al Viro wrote: > On Mon, Jun 20, 2016 at 10:05:45PM +0800, Minfei Huang wrote: > > Ping. Any comment is appreciate. > > > > Thanks > > Minfei > > > > On 06/13/16 at 12:33P, Minfei Huang wrote: > > > The variable nr_pages is always more than 1, because the size of > > > structure aio_ring is bigger than 0. So remove unnecessary test for > > > nr_page. > > What this test really checks is that the value we'd put into nr_pages > (PFN_UP(size)) is not greater than 2^31. Whether it's redundant or not > is a separate question - it very well might be, due to the code in > ioctx_alloc() that caps nr_events, but that needs a proof. In any case, > the reasons you are offering in commit message are wrong - it's about > size being too _large_, not too small. Hmm. But there is a following test in function ioctx_alloc which is used to limit the max of nr_events. 713 /* Prevent overflows */ 714 if (nr_events > (0x10000000U / sizeof(struct io_event))) { 715 pr_debug("ENOMEM: nr_events too high\n"); 716 return ERR_PTR(-EINVAL); 717 } So according to this test, we can make sure that nr_pages(PFN_UP(size)) cann't be greater than 2^31, and max to 2^28. Thanks Minfei