From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932342Ab0LMG44 (ORCPT ); Mon, 13 Dec 2010 01:56:56 -0500 Received: from mga09.intel.com ([134.134.136.24]:15822 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753807Ab0LMGtn (ORCPT ); Mon, 13 Dec 2010 01:49:43 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.59,335,1288594800"; d="scan'208";a="686523124" Message-Id: <20101213064839.531946766@intel.com> User-Agent: quilt/0.48-1 Date: Mon, 13 Dec 2010 14:43:10 +0800 From: Wu Fengguang To: Andrew Morton CC: Jan Kara , Peter Zijlstra , Wu Fengguang CC: Christoph Hellwig CC: Trond Myklebust CC: Dave Chinner CC: "Theodore Ts'o" CC: Chris Mason CC: Mel Gorman CC: Rik van Riel CC: KOSAKI Motohiro CC: Greg Thelen CC: Minchan Kim Cc: linux-mm Cc: Cc: LKML Subject: [PATCH 21/47] writeback: prevent divide error on tiny HZ References: <20101213064249.648862451@intel.com> Content-Disposition: inline; filename=writeback-bandwidth-HZ-fix.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As suggested by Andrew and Peter: I do recall hearing of people who set HZ very low, perhaps because their huge machines were seeing performance problems when the timer tick went off. Probably there's no need to do that any more. But still, we shouldn't hard-wire the (HZ >= 100) assumption if we don't absolutely need to, and I don't think it is absolutely needed here. People who do cpu bring-up on very slow FPGAs also lower HZ as far as possible. CC: Peter Zijlstra Signed-off-by: Wu Fengguang --- mm/page-writeback.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- linux-next.orig/mm/page-writeback.c 2010-12-08 22:44:28.000000000 +0800 +++ linux-next/mm/page-writeback.c 2010-12-08 22:44:28.000000000 +0800 @@ -527,6 +527,7 @@ void bdi_update_write_bandwidth(struct b unsigned long *bw_time, s64 *bw_written) { + const unsigned long unit_time = max(HZ/100, 1); unsigned long written; unsigned long elapsed; unsigned long bw; @@ -536,7 +537,7 @@ void bdi_update_write_bandwidth(struct b goto snapshot; elapsed = jiffies - *bw_time; - if (elapsed < HZ/100) + if (elapsed < unit_time) return; /* @@ -550,7 +551,7 @@ void bdi_update_write_bandwidth(struct b written = percpu_counter_read(&bdi->bdi_stat[BDI_WRITTEN]) - *bw_written; bw = (HZ * PAGE_CACHE_SIZE * written + elapsed/2) / elapsed; - w = min(elapsed / (HZ/100), 128UL); + w = min(elapsed / unit_time, 128UL); bdi->write_bandwidth = (bdi->write_bandwidth * (1024-w) + bw * w) >> 10; bdi->write_bandwidth_update_time = jiffies; snapshot: From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: [PATCH 21/47] writeback: prevent divide error on tiny HZ Date: Mon, 13 Dec 2010 14:43:10 +0800 Message-ID: <20101213064839.531946766@intel.com> References: <20101213064249.648862451@intel.com> Cc: Jan Kara , Peter Zijlstra , Wu Fengguang To: Andrew Morton Return-path: CC: Christoph Hellwig CC: Trond Myklebust CC: Dave Chinner CC: Theodore Ts'o CC: Chris Mason CC: Mel Gorman CC: Rik van Riel CC: KOSAKI Motohiro CC: Greg Thelen CC: Minchan Kim Cc: linux-mm Cc: Cc: LKML Content-Disposition: inline; filename=writeback-bandwidth-HZ-fix.patch Sender: owner-linux-mm@kvack.org List-Id: linux-fsdevel.vger.kernel.org As suggested by Andrew and Peter: I do recall hearing of people who set HZ very low, perhaps because their huge machines were seeing performance problems when the timer tick went off. Probably there's no need to do that any more. But still, we shouldn't hard-wire the (HZ >= 100) assumption if we don't absolutely need to, and I don't think it is absolutely needed here. People who do cpu bring-up on very slow FPGAs also lower HZ as far as possible. CC: Peter Zijlstra Signed-off-by: Wu Fengguang --- mm/page-writeback.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- linux-next.orig/mm/page-writeback.c 2010-12-08 22:44:28.000000000 +0800 +++ linux-next/mm/page-writeback.c 2010-12-08 22:44:28.000000000 +0800 @@ -527,6 +527,7 @@ void bdi_update_write_bandwidth(struct b unsigned long *bw_time, s64 *bw_written) { + const unsigned long unit_time = max(HZ/100, 1); unsigned long written; unsigned long elapsed; unsigned long bw; @@ -536,7 +537,7 @@ void bdi_update_write_bandwidth(struct b goto snapshot; elapsed = jiffies - *bw_time; - if (elapsed < HZ/100) + if (elapsed < unit_time) return; /* @@ -550,7 +551,7 @@ void bdi_update_write_bandwidth(struct b written = percpu_counter_read(&bdi->bdi_stat[BDI_WRITTEN]) - *bw_written; bw = (HZ * PAGE_CACHE_SIZE * written + elapsed/2) / elapsed; - w = min(elapsed / (HZ/100), 128UL); + w = min(elapsed / unit_time, 128UL); bdi->write_bandwidth = (bdi->write_bandwidth * (1024-w) + bw * w) >> 10; bdi->write_bandwidth_update_time = jiffies; snapshot: -- 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/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: [PATCH 21/47] writeback: prevent divide error on tiny HZ Date: Mon, 13 Dec 2010 14:43:10 +0800 Message-ID: <20101213064839.531946766@intel.com> References: <20101213064249.648862451@intel.com> Return-path: Received: from kanga.kvack.org ([205.233.56.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PS2EV-0005VA-OK for glkm-linux-mm-2@m.gmane.org; Mon, 13 Dec 2010 07:50:04 +0100 Received: from mail191.messagelabs.com (mail191.messagelabs.com [216.82.242.19]) by kanga.kvack.org (Postfix) with SMTP id 7550E6B009A for ; Mon, 13 Dec 2010 01:49:40 -0500 (EST) Content-Disposition: inline; filename=writeback-bandwidth-HZ-fix.patch Sender: owner-linux-mm@kvack.org To: Andrew Morton Cc: Jan Kara , Peter Zijlstra , Wu Fengguang , Christoph Hellwig , Trond Myklebust , Dave Chinner , Theodore Ts'o , Chris Mason , Mel Gorman , Rik van Riel , KOSAKI Motohiro , Greg Thelen , Minchan Kim , linux-mm , linux-fsdevel@vger.kernel.org, LKML List-Id: linux-mm.kvack.org As suggested by Andrew and Peter: I do recall hearing of people who set HZ very low, perhaps because their huge machines were seeing performance problems when the timer tick went off. Probably there's no need to do that any more. But still, we shouldn't hard-wire the (HZ >= 100) assumption if we don't absolutely need to, and I don't think it is absolutely needed here. People who do cpu bring-up on very slow FPGAs also lower HZ as far as possible. CC: Peter Zijlstra Signed-off-by: Wu Fengguang --- mm/page-writeback.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- linux-next.orig/mm/page-writeback.c 2010-12-08 22:44:28.000000000 +0800 +++ linux-next/mm/page-writeback.c 2010-12-08 22:44:28.000000000 +0800 @@ -527,6 +527,7 @@ void bdi_update_write_bandwidth(struct b unsigned long *bw_time, s64 *bw_written) { + const unsigned long unit_time = max(HZ/100, 1); unsigned long written; unsigned long elapsed; unsigned long bw; @@ -536,7 +537,7 @@ void bdi_update_write_bandwidth(struct b goto snapshot; elapsed = jiffies - *bw_time; - if (elapsed < HZ/100) + if (elapsed < unit_time) return; /* @@ -550,7 +551,7 @@ void bdi_update_write_bandwidth(struct b written = percpu_counter_read(&bdi->bdi_stat[BDI_WRITTEN]) - *bw_written; bw = (HZ * PAGE_CACHE_SIZE * written + elapsed/2) / elapsed; - w = min(elapsed / (HZ/100), 128UL); + w = min(elapsed / unit_time, 128UL); bdi->write_bandwidth = (bdi->write_bandwidth * (1024-w) + bw * w) >> 10; bdi->write_bandwidth_update_time = jiffies; snapshot: -- 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/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: email@kvack.org