Skip to contentSkip to conversation

writeback: avoid unnecessary determine_dirtyable_memory call

PATCH In review Minchan Kim 2 participants 3 messages Jan 3, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 writeback: avoid unnecessary determine_dirtyable_memory call

I think determine_dirtyable_memory is rather costly function since it need many atomic reads for gathering zone/global page state. But when we use vm_dirty_bytes && dirty_background_bytes, we don't need that costly calculation.

This patch eliminates such unnecessary overhead.

NOTE : newly added if condition might add overhead in normal path.
But it should be _really_ small because anyway we need the access both vm_dirty_bytes and dirty_background_bytes so it is likely to hit the cache.

Cc Wu Fengguang <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 mm/page-writeback.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
mm/page-writeback.c +4 -1
index fc93802..c340536 100644
@@ -390,9 +390,12 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty)
 {
 	unsigned long background;
 	unsigned long dirty;
-	unsigned long available_memory = determine_dirtyable_memory();
+	unsigned long available_memory;
 	struct task_struct *tsk;
 
+	if (!vm_dirty_bytes || !dirty_background_bytes)
+		available_memory = determine_dirtyable_memory();
+
 	if (vm_dirty_bytes)
 		dirty = DIV_ROUND_UP(vm_dirty_bytes, PAGE_SIZE);
 	else
Signature · 1 line
1.7.0.4
#1 lore raw

mm/page-writeback.c void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty) · line 393

Quoted 10 lines · Minchan Kim
mm/page-writeback.c +1 -1
index fc93802..c340536 100644
@@ -390,9 +390,12 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty)
 {
 	unsigned long background;
 	unsigned long dirty;
-	unsigned long available_memory = determine_dirtyable_memory();
+	unsigned long available_memory;

You need unsigned long uninitialized_var(available_memory) to avoid the warning.

Quoted 8 lines
mm/page-writeback.c +3 -0
 	struct task_struct *tsk;
 
+	if (!vm_dirty_bytes || !dirty_background_bytes)
+		available_memory = determine_dirtyable_memory();
+
 	if (vm_dirty_bytes)
 		dirty = DIV_ROUND_UP(vm_dirty_bytes, PAGE_SIZE);
 	else
#2 lore raw
Quoted 15 lines · David Rientjes

mm/page-writeback.c void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty) · line 393

Quoted 10 lines · Minchan Kim
mm/page-writeback.c +1 -1
index fc93802..c340536 100644
@@ -390,9 +390,12 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty)
  {
       unsigned long background;
       unsigned long dirty;
-     unsigned long available_memory = determine_dirtyable_memory();
+     unsigned long available_memory;

You need unsigned long uninitialized_var(available_memory) to avoid the warning.

Yes. It's my fault. Andrew already fixed it.
Thanks, David.

Signature · 9 lines
Kind regards,
Minchan Kim

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  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: <a href=mailto:"[email protected]"> [email protected] </a>