From patchwork Thu Aug 25 21:26:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 111669 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BBE20B70C3 for ; Fri, 26 Aug 2011 07:26:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754334Ab1HYV0Z (ORCPT ); Thu, 25 Aug 2011 17:26:25 -0400 Received: from ozlabs.org ([203.10.76.45]:35008 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753581Ab1HYV0Z (ORCPT ); Thu, 25 Aug 2011 17:26:25 -0400 Received: from kryten (ppp121-45-171-79.lns20.syd6.internode.on.net [121.45.171.79]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id B887BB6F91; Fri, 26 Aug 2011 07:26:23 +1000 (EST) Date: Fri, 26 Aug 2011 07:26:22 +1000 From: Anton Blanchard To: tytso@mit.edu, adilger.kernel@dilger.ca, eric.dumazet@gmail.com, tj@kernel.org Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ext4: EXT4_FREEBLOCKS_WATERMARK is overly pessimistic Message-ID: <20110826072622.406d3395@kryten> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.24.4; i686-pc-linux-gnu) Mime-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When testing on a 1024 thread ppc64 box I noticed a large amount of CPU time in ext4 code. ext4_has_free_blocks has a fast path to avoid summing every free and dirty block per cpu counter, but only if the global count shows more free blocks than the maximum amount that could be stored in all the per cpu counters. While we are summing 2 per cpu counters we set the breakpoint at 4 times the maximum amount in the per cpu counter portion. Reduce that to 2. Since we fold the per cpu count of CPUs going offline into the global count, we can use num_online_cpus() instead of nr_cpu_ids here too. Both these changes match percpu_counter_compare() which is used to optimise a comparison against one per cpu counter. Signed-off-by: Anton Blanchard --- -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6-work/fs/ext4/ext4.h =================================================================== --- linux-2.6-work.orig/fs/ext4/ext4.h 2011-08-25 11:44:02.978785464 +1000 +++ linux-2.6-work/fs/ext4/ext4.h 2011-08-25 14:17:37.461904013 +1000 @@ -2051,10 +2051,11 @@ do { \ #ifdef CONFIG_SMP /* Each CPU can accumulate percpu_counter_batch blocks in their local - * counters. So we need to make sure we have free blocks more - * than percpu_counter_batch * nr_cpu_ids. Also add a window of 4 times. + * counters. Since we sum two percpu counters (s_freeblocks_counter and + * s_dirtyblocks_counter), as a worst case we need to check for 2x this. */ -#define EXT4_FREEBLOCKS_WATERMARK (4 * (percpu_counter_batch * nr_cpu_ids)) +#define EXT4_FREEBLOCKS_WATERMARK \ + (2 * (percpu_counter_batch * num_online_cpus())) #else #define EXT4_FREEBLOCKS_WATERMARK 0 #endif