All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ext4: EXT4_FREEBLOCKS_WATERMARK is overly pessimistic
@ 2011-08-25 21:26 Anton Blanchard
  2011-08-25 21:29 ` [PATCH 2/2] percpu_counter: Put a reasonable upper bound on percpu_counter_batch Anton Blanchard
  0 siblings, 1 reply; 17+ messages in thread
From: Anton Blanchard @ 2011-08-25 21:26 UTC (permalink / raw)
  To: tytso, adilger.kernel, eric.dumazet, tj; +Cc: linux-ext4, linux-kernel


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

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-09-07 17:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25 21:26 [PATCH 1/2] ext4: EXT4_FREEBLOCKS_WATERMARK is overly pessimistic Anton Blanchard
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-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 13:30           ` Theodore Tso
2011-09-06 16:44           ` Tejun Heo
2011-09-06 16:44             ` Tejun Heo
2011-09-07 11:08           ` Anton Blanchard
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 11:54       ` Anton Blanchard
2011-08-29 13:27     ` Ted Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.