From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752864Ab0CWMDv (ORCPT ); Tue, 23 Mar 2010 08:03:51 -0400 Received: from gir.skynet.ie ([193.1.99.77]:52904 "EHLO gir.skynet.ie" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752363Ab0CWMDt (ORCPT ); Tue, 23 Mar 2010 08:03:49 -0400 Date: Tue, 23 Mar 2010 12:03:30 +0000 From: Mel Gorman To: KOSAKI Motohiro Cc: Andrew Morton , Andrea Arcangeli , Christoph Lameter , Adam Litke , Avi Kivity , David Rientjes , Rik van Riel , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 06/11] Export fragmentation index via /proc/extfrag_index Message-ID: <20100323120329.GE9590@csn.ul.ie> References: <20100317114321.4C9A.A69D9226@jp.fujitsu.com> <20100317113326.GD12388@csn.ul.ie> <20100323050910.A473.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20100323050910.A473.A69D9226@jp.fujitsu.com> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 23, 2010 at 09:22:04AM +0900, KOSAKI Motohiro wrote: > > > > + /* > > > > + * Index is between 0 and 1 so return within 3 decimal places > > > > + * > > > > + * 0 => allocation would fail due to lack of memory > > > > + * 1 => allocation would fail due to fragmentation > > > > + */ > > > > + return 1000 - ( (1000+(info->free_pages * 1000 / requested)) / info->free_blocks_total); > > > > +} > > > > > > Dumb question. > > > your paper (http://portal.acm.org/citation.cfm?id=1375634.1375641) says > > > fragmentation_index = 1 - (TotalFree/SizeRequested)/BlocksFree > > > but your code have extra '1000+'. Why? > > > > To get an approximation to three decimal places. > > Do you mean this is poor man's round up logic? Not exactly. The intention is to have a value of 968 instead of 0.968231. i.e. instead of a value between 0 and 1, it'll be a value between 0 and 1000 that matches the first three digits after the decimal place. > Why don't you use DIV_ROUND_UP? likes following, > > return 1000 - (DIV_ROUND_UP(info->free_pages * 1000 / requested) / info->free_blocks_total); > Because it's not doing the same thing unless I missed something. -- Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail138.messagelabs.com (mail138.messagelabs.com [216.82.249.35]) by kanga.kvack.org (Postfix) with ESMTP id 252326B01AD for ; Tue, 23 Mar 2010 08:03:52 -0400 (EDT) Date: Tue, 23 Mar 2010 12:03:30 +0000 From: Mel Gorman Subject: Re: [PATCH 06/11] Export fragmentation index via /proc/extfrag_index Message-ID: <20100323120329.GE9590@csn.ul.ie> References: <20100317114321.4C9A.A69D9226@jp.fujitsu.com> <20100317113326.GD12388@csn.ul.ie> <20100323050910.A473.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20100323050910.A473.A69D9226@jp.fujitsu.com> Sender: owner-linux-mm@kvack.org To: KOSAKI Motohiro Cc: Andrew Morton , Andrea Arcangeli , Christoph Lameter , Adam Litke , Avi Kivity , David Rientjes , Rik van Riel , linux-kernel@vger.kernel.org, linux-mm@kvack.org List-ID: On Tue, Mar 23, 2010 at 09:22:04AM +0900, KOSAKI Motohiro wrote: > > > > + /* > > > > + * Index is between 0 and 1 so return within 3 decimal places > > > > + * > > > > + * 0 => allocation would fail due to lack of memory > > > > + * 1 => allocation would fail due to fragmentation > > > > + */ > > > > + return 1000 - ( (1000+(info->free_pages * 1000 / requested)) / info->free_blocks_total); > > > > +} > > > > > > Dumb question. > > > your paper (http://portal.acm.org/citation.cfm?id=1375634.1375641) says > > > fragmentation_index = 1 - (TotalFree/SizeRequested)/BlocksFree > > > but your code have extra '1000+'. Why? > > > > To get an approximation to three decimal places. > > Do you mean this is poor man's round up logic? Not exactly. The intention is to have a value of 968 instead of 0.968231. i.e. instead of a value between 0 and 1, it'll be a value between 0 and 1000 that matches the first three digits after the decimal place. > Why don't you use DIV_ROUND_UP? likes following, > > return 1000 - (DIV_ROUND_UP(info->free_pages * 1000 / requested) / info->free_blocks_total); > Because it's not doing the same thing unless I missed something. -- Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org