linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Understanding page faults code in mm/memory.c
@ 2003-07-31 11:15 Eugene Teo
  2003-07-31 11:47 ` Mel Gorman
  0 siblings, 1 reply; 6+ messages in thread
From: Eugene Teo @ 2003-07-31 11:15 UTC (permalink / raw)
  To: linux-mm

[-- Attachment #1: Type: text/plain, Size: 1706 bytes --]

Hi there,

With reference to 2.4.20, I have a few questions:

[1] I was looking at mm/memory.c. I noticed that there is a 
difference between minor, and major faults. My guess is that
when a major fault occurs, the mm performs a page-in from the
swap to the memory, whilst a minor fault doesn't? No?

[2] I understand that for the handle_pte_fault routine, the
if structure basically handles page-in. I am trying to figure
out where I can find the code for page-out which I understand
it can be involved the swap, etc. Can someone give me some
pointers as to where I can look for:

    - what causes page-outs,
    - where in the kernel can i look for them?

[3] in mm/memory.c, in do_wp_page, I am not sure what the
portion of code is about:

// If old_page bit is not set, set it, and test.
if (!TryLockPage(old_page) {

    // [QN:] I don't understand what can_share_swap_page() do
    // I tried tracing, but i still don't quite get it.
    int reuse = can_share_swap_page(old_page);    
    unlock_page(old_page);
    if (reuse) {
        // flush the old mapping out of the tlb.
        fluse_cache_page(vma, address);
        
        // creates a new mapping with entry in the page table        
        // [QN:] What is pte_mkyoung?
        establish_pte(vma, address, page_table, pte_mkyoung(...
        
        spin_unlock(&mm->page_table_lock);

        // [QN:] why didn't the mm->rss increased since it is
        // a minor fault? hmm, i am not sure what minor
        // fault is though.
        return 1; /* minor fault */
    }
}    

Hear from you guys. Thank you so much.

Cheers,
Eugene
(posted this in another mailing list before)


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: Understanding page faults code in mm/memory.c
  2003-07-31 11:15 Understanding page faults code in mm/memory.c Eugene Teo
@ 2003-07-31 11:47 ` Mel Gorman
  2003-07-31 16:12   ` Raghu R. Arur
  0 siblings, 1 reply; 6+ messages in thread
From: Mel Gorman @ 2003-07-31 11:47 UTC (permalink / raw)
  To: Eugene Teo; +Cc: linux-mm

On Thu, 31 Jul 2003, Eugene Teo wrote:

> [1] I was looking at mm/memory.c. I noticed that there is a
> difference between minor, and major faults. My guess is that
> when a major fault occurs, the mm performs a page-in from the
> swap to the memory, whilst a minor fault doesn't?
>

Close enough. A major fault requires disk IO of some sort, it could be
either to a file or to swap.

> [2] <snip>
>     - what causes page-outs,
>     - where in the kernel can i look for them?
>

vmscan.c:shrink_cache() is a decent place to start.

> [3] in mm/memory.c, in do_wp_page, I am not sure what the
> portion of code is about:
>
> // If old_page bit is not set, set it, and test.
> if (!TryLockPage(old_page) {
>
>     // [QN:] I don't understand what can_share_swap_page() do
>     // I tried tracing, but i still don't quite get it.
>     int reuse = can_share_swap_page(old_page);

Basically it'll determine if you are the only user of that swap page. If
it returns true, it means that you are the last process to break COW on
that page so just use it. Otherwise it'll fall through and a new page will
be allocated.

>         // creates a new mapping with entry in the page table
>         // [QN:] What is pte_mkyoung?

Sets the accessed bit in the PTE to show it has been recently used

>         // [QN:] why didn't the mm->rss increased since it is
>         // a minor fault? hmm, i am not sure what minor
>         // fault is though.

Because you are using the same page that was there before. No new page is
being used by the process so no need to rss++

-- 
Mel Gorman
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

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

* Re: Understanding page faults code in mm/memory.c
  2003-07-31 11:47 ` Mel Gorman
@ 2003-07-31 16:12   ` Raghu R. Arur
  2003-07-31 17:06     ` Mel Gorman
  0 siblings, 1 reply; 6+ messages in thread
From: Raghu R. Arur @ 2003-07-31 16:12 UTC (permalink / raw)
  To: Mel Gorman; +Cc: Eugene Teo, linux-mm


>
> > [3] in mm/memory.c, in do_wp_page, I am not sure what the
> > portion of code is about:
> >
> > // If old_page bit is not set, set it, and test.
> > if (!TryLockPage(old_page) {
> >
> >     // [QN:] I don't understand what can_share_swap_page() do
> >     // I tried tracing, but i still don't quite get it.
> >     int reuse = can_share_swap_page(old_page);
>
> Basically it'll determine if you are the only user of that swap page. If
> it returns true, it means that you are the last process to break COW on
> that page so just use it. Otherwise it'll fall through and a new page will
> be allocated.

   But when you put a page on to the swap cache will not the rss of the
address spage  decrease. if not then when will the rss value of the
address space change.

 thanks,
Raghu
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

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

* Re: Understanding page faults code in mm/memory.c
  2003-07-31 16:12   ` Raghu R. Arur
@ 2003-07-31 17:06     ` Mel Gorman
  2003-07-31 17:11       ` Raghu R. Arur
  0 siblings, 1 reply; 6+ messages in thread
From: Mel Gorman @ 2003-07-31 17:06 UTC (permalink / raw)
  To: Raghu R. Arur; +Cc: Eugene Teo, linux-mm

On Thu, 31 Jul 2003, Raghu R. Arur wrote:

>    But when you put a page on to the swap cache will not the rss of the
> address spage  decrease. if not then when will the rss value of the
> address space change.
>

vmscan.c:try_to_swap_out() will decrement the rss before adding it to the
swap cache with add_to_swap_cache()

-- 
Mel Gorman
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

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

* Re: Understanding page faults code in mm/memory.c
  2003-07-31 17:06     ` Mel Gorman
@ 2003-07-31 17:11       ` Raghu R. Arur
  2003-07-31 18:20         ` Mel Gorman
  0 siblings, 1 reply; 6+ messages in thread
From: Raghu R. Arur @ 2003-07-31 17:11 UTC (permalink / raw)
  To: Mel Gorman; +Cc: Eugene Teo, linux-mm

  No, what i meant was, if the rss value gets decremented when a page is
put into swap cache, then why is it not incremented in do_wp_page when you
fault for a page inside swap cache. if you fault, then you add it
establish the pte to the page in the swap cache. dont you need to
increment the rss value too ?? I know i am missing something over here.
Please help me in understanding it correctly.

 Thanks,
Raghu

On Thu, 31 Jul 2003, Mel Gorman wrote:

> On Thu, 31 Jul 2003, Raghu R. Arur wrote:
>
> >    But when you put a page on to the swap cache will not the rss of the
> > address spage  decrease. if not then when will the rss value of the
> > address space change.
> >
>
> vmscan.c:try_to_swap_out() will decrement the rss before adding it to the
> swap cache with add_to_swap_cache()
>
> --
> Mel Gorman
>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

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

* Re: Understanding page faults code in mm/memory.c
  2003-07-31 17:11       ` Raghu R. Arur
@ 2003-07-31 18:20         ` Mel Gorman
  0 siblings, 0 replies; 6+ messages in thread
From: Mel Gorman @ 2003-07-31 18:20 UTC (permalink / raw)
  To: Raghu R. Arur; +Cc: Eugene Teo, linux-mm

On Thu, 31 Jul 2003, Raghu R. Arur wrote:

>
>   No, what i meant was, if the rss value gets decremented when a page is
> put into swap cache, then why is it not incremented in do_wp_page when you
> fault for a page inside swap cache.

Because paging in from the swap cache is handled by do_swap_page() which
does increment rss, not do_wp_page().

-- 
Mel Gorman
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

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

end of thread, other threads:[~2003-07-31 18:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-31 11:15 Understanding page faults code in mm/memory.c Eugene Teo
2003-07-31 11:47 ` Mel Gorman
2003-07-31 16:12   ` Raghu R. Arur
2003-07-31 17:06     ` Mel Gorman
2003-07-31 17:11       ` Raghu R. Arur
2003-07-31 18:20         ` Mel Gorman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox