Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758900Ab3GRMsR (ORCPT ); Thu, 18 Jul 2013 08:48:17 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:24210 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754507Ab3GRMsQ (ORCPT ); Thu, 18 Jul 2013 08:48:16 -0400 Message-ID: <51E7E400.4070705@oracle.com> Date: Thu, 18 Jul 2013 20:48:00 +0800 From: Bob Liu User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130221 Thunderbird/17.0.3 MIME-Version: 1.0 To: Heesub Shin CC: Andrew Morton , Seth Jennings , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dongjun Shin , Sunae Seo , Heesub Shin Subject: Re: [PATCH] mm: zbud: fix condition check on allocation size References: <1374071410-9337-1-git-send-email-heesub.shin@samsung.com> In-Reply-To: <1374071410-9337-1-git-send-email-heesub.shin@samsung.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1370 Lines: 40 On 07/17/2013 10:30 PM, Heesub Shin wrote: > zbud_alloc() incorrectly verifies the size of allocation limit. It > should deny the allocation request greater than (PAGE_SIZE - > ZHDR_SIZE_ALIGNED - CHUNK_SIZE), not (PAGE_SIZE - ZHDR_SIZE_ALIGNED) > which has no remaining spaces for its buddy. There is no point in > spending the entire zbud page storing only a single page, since we don't > have any benefits. > > Signed-off-by: Heesub Shin Looks good to me, although I'm thinking to make it more aggressive. eg. minus two or three times of CHUNK_SIZE. > --- > mm/zbud.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/zbud.c b/mm/zbud.c > index 9bb4710..ad1e781 100644 > --- a/mm/zbud.c > +++ b/mm/zbud.c > @@ -257,7 +257,7 @@ int zbud_alloc(struct zbud_pool *pool, int size, gfp_t gfp, > > if (size <= 0 || gfp & __GFP_HIGHMEM) > return -EINVAL; > - if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED) > + if (size > PAGE_SIZE - ZHDR_SIZE_ALIGNED - CHUNK_SIZE) > return -ENOSPC; > chunks = size_to_chunks(size); > spin_lock(&pool->lock); > -- Regards, -Bob -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/