Skip to contentSkip to conversation

Re: [[email protected]: Returned mail: see transcript for details]

[email protected]: Returned mail: see transcript for details Balbir Singh 2 participants 2 messages Sep 4, 2007 1 message not in the archive Memory management

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 5 lines · Nick Piggin

Hi,

This mail to Shailabh bounced, but I noticed you're on the Signed-off-by trail too, so forwarding to you so you don't miss it. Thanks,

Thanks, Nick. I am cc'ing Shailabh's new email id.

Quoted 6 lines

Hi,

I can't convince myself that delay accounting for swapin is quite right at the moment (not having a test setup handy to run and check for myself). Maybe I'm not reading the swapin code very well...

Quoted 9 lines

lookup_swap_cache, and read_swap_cache_async should be non-blocking operations for the most part.

read_swap_cache_async might, when allocating the new page, go into reclaim and take a long time to come back. However is that any more a "swapin" delay than eg. when we sleep on mmap_sem when first taking the fault, or any other types of fault which require allocations? None of which we account for as swapin delay.

Yes, for us it is. We measure the end to end delay of swapping in/out a page.

Quoted 3 lines

But the most obvious delay, where we actually lock the page waiting for the swap IO to finish, does not seem to be accounted at all!

Hmm.. Does lock_page() eventually call io_schedule() or io_schedule_timeout()? I think it does -- via sync_page(). The way our accounting works is that we account for block I/O in io_schedule*(). If we see the SWAPIN flag set, we then account for that I/O as swap I/O.

Quoted 16 lines

My proposed fix is to just move the swaping delay accounting to the point where the VM does actually wait, for the swapin.

I have no idea what uses swapin delay accounting, but it would be good to see if this makes a positive (or at least not negative) impact on those users...

Thanks,
Nick

--
Index: linux-2.6/mm/memory.c
===================================================================

mm/memory.c static int do_swap_page(struct mm_struct · line 2161

Quoted 4 lines
mm/memory.c +0 -1
@@ -2158,7 +2158,6 @@ static int do_swap_page(struct mm_struct
 		migration_entry_wait(mm, pmd, address);
 		goto out;
 	}
-	delayacct_set_flag(DELAYACCT_PF_SWAPIN);

Let's start the accounting here.

Quoted 12 lines
mm/memory.c +0 -1
 	page = lookup_swap_cache(entry);
 	if (!page) {
 		grab_swap_token(); /* Contend for token _before_ read-in */
@@ -2172,7 +2171,6 @@ static int do_swap_page(struct mm_struct
 			page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
 			if (likely(pte_same(*page_table, orig_pte)))
 				ret = VM_FAULT_OOM;
-			delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
 			goto unlock;
 		}
 

mm/memory.c static int do_swap_page(struct mm_struct · line 2186

Quoted 9 lines
mm/memory.c +2 -1
@@ -2181,9 +2179,10 @@ static int do_swap_page(struct mm_struct
 		count_vm_event(PGMAJFAULT);
 	}
 
-	delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
 	mark_page_accessed(page);
+	delayacct_set_flag(DELAYACCT_PF_SWAPIN);
 	lock_page(page);
+	delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
 

I agree that we should end it after lock_page().

Quoted 5 lines
mm/memory.c +0 -1
 	/*
 	 * Back out if somebody else already faulted in this pte.
 
 
----- End forwarded message -----
Signature · 10 lines
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 10 lines · Balbir Singh
Quoted 3 lines · Nick Piggin

But the most obvious delay, where we actually lock the page waiting for the swap IO to finish, does not seem to be accounted at all!

Hmm.. Does lock_page() eventually call io_schedule() or io_schedule_timeout()? I think it does -- via sync_page(). The way our accounting works is that we account for block I/O in io_schedule*(). If we see the SWAPIN flag set, we then account for that I/O as swap I/O.

Yes, lock_page will io_schedule() down the path you say.

Quoted 10 lines
Quoted 10 lines

My proposed fix is to just move the swaping delay accounting to the point where the VM does actually wait, for the swapin.

I have no idea what uses swapin delay accounting, but it would be good to see if this makes a positive (or at least not negative) impact on those users...

Thanks,
Nick

Quoted 12 lines

mm/memory.c static int do_swap_page(struct mm_struct · line 2161

Quoted 10 lines

--
Index: linux-2.6/mm/memory.c
===================================================================

mm/memory.c +0 -1
@@ -2158,7 +2158,6 @@ static int do_swap_page(struct mm_struct
 		migration_entry_wait(mm, pmd, address);
 		goto out;
 	}
-	delayacct_set_flag(DELAYACCT_PF_SWAPIN);

Let's start the accounting here.

If you start accounting here, then you can potentially also count other stuff as swapin delay which I don't think you want to. I'm not sure if there is any part of reclaim where we directly wait on page IO, but we do wait on blkdev congestion which calls io_schedule. It seems funny to account this as swapin delay.

Quoted 15 lines
Quoted 15 lines
mm/memory.c +0 -1
 	page = lookup_swap_cache(entry);
 	if (!page) {
 		grab_swap_token(); /* Contend for token _before_ read-in */
@@ -2172,7 +2171,6 @@ static int do_swap_page(struct mm_struct
 			page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
 			if (likely(pte_same(*page_table, orig_pte)))
 				ret = VM_FAULT_OOM;
-			delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
 			goto unlock;
 		}
 
@@ -2181,9 +2179,10 @@ static int do_swap_page(struct mm_struct
 		count_vm_event(PGMAJFAULT);
 	}
 
Quoted 8 lines

mm/memory.c static int do_swap_page(struct mm_struct · line 2186

Quoted 6 lines
mm/memory.c +2 -1
-	delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
 	mark_page_accessed(page);
+	delayacct_set_flag(DELAYACCT_PF_SWAPIN);
 	lock_page(page);
+	delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
 

I agree that we should end it after lock_page().

OK.

--
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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>