linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
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
Date: Fri, 26 Aug 2011 07:26:22 +1000	[thread overview]
Message-ID: <20110826072622.406d3395@kryten> (raw)


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 <anton@samba.org>
---

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

             reply	other threads:[~2011-08-25 21:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 21:26 Anton Blanchard [this message]
2011-08-25 21:29 ` [PATCH 2/2] percpu_counter: Put a reasonable upper bound on percpu_counter_batch Anton Blanchard
2011-08-26  8:39   ` Eric Dumazet
2011-08-29 11:46     ` [PATCH] " Anton Blanchard
2011-09-06  3:48       ` Tejun Heo
2011-09-06 13:30         ` Theodore Tso
2011-09-06 16:44           ` Tejun Heo
2011-09-07 11:08           ` Anton Blanchard
2011-08-26  9:00   ` [PATCH 2/2] " Tejun Heo
2011-08-26 11:48   ` Theodore Tso
2011-08-29 11:54     ` Anton Blanchard
2011-08-29 13:27     ` Ted Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110826072622.406d3395@kryten \
    --to=anton@samba.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).