public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* How to identify cow (copy-on-write) pages during kernel execution?
@ 2005-06-20  5:45 Mauricio Lin
  2005-06-20  6:33 ` Nick Piggin
  2005-06-20 11:09 ` Carsten Otte
  0 siblings, 2 replies; 5+ messages in thread
From: Mauricio Lin @ 2005-06-20  5:45 UTC (permalink / raw)
  To: linux-kernel

Hi all,

I would like to know if there is a way to identify
struct page that is cow (copy-on-write).

The way I figured out to identify cow pages is when
copy-on-write happens. I mean I identify cow pages
inside the do_wp_page(), the function that handles
copy-on-write. I have checked do_no_page() as well.

I have included a field (is_cow) in the struct page to
identify cow page.

struct page {
     ...
     atomic_t is_cow;
}

But I wonder if it is possible to identify cow pages
before copy-on-write happens. So identify cow pages in
advance before any process tries to write to a cow
page.

I have checked the do_fork(), copy_process() and
copy_mm() function to try to identify cow pages during
the process creation, but no success. In copy_mm(),
just the mm (of current process) is provided to the
child process, but there are no references to struct
pages related to mm and its VMAs.

So when a page struct is considered a cow in the
kernel and its count variable is updated? Certainly
the counter page (page->_count) is updated when a page
is shared because of copy-on-write feature. 
How can I identify cow pages when it becomes cow? Is
there any feasible way to perform that?

BR,

Mauricio Lin.

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

* Re: How to identify cow (copy-on-write) pages during kernel execution?
  2005-06-20  5:45 How to identify cow (copy-on-write) pages during kernel execution? Mauricio Lin
@ 2005-06-20  6:33 ` Nick Piggin
  2005-06-20 11:09 ` Carsten Otte
  1 sibling, 0 replies; 5+ messages in thread
From: Nick Piggin @ 2005-06-20  6:33 UTC (permalink / raw)
  To: Mauricio Lin; +Cc: lkml

On Mon, 2005-06-20 at 01:45 -0400, Mauricio Lin wrote:


Hi,

> So when a page struct is considered a cow in the
> kernel and its count variable is updated? Certainly
> the counter page (page->_count) is updated when a page
> is shared because of copy-on-write feature. 
> How can I identify cow pages when it becomes cow? Is
> there any feasible way to perform that?
> 

Look in mm/memory.c at how the page fault handler decides
it is dealing with a COW page.

Nick

-- 
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com 

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

* Re: How to identify cow (copy-on-write) pages during kernel execution?
  2005-06-20  5:45 How to identify cow (copy-on-write) pages during kernel execution? Mauricio Lin
  2005-06-20  6:33 ` Nick Piggin
@ 2005-06-20 11:09 ` Carsten Otte
  2005-06-20 11:30   ` Mauricio Lin
  1 sibling, 1 reply; 5+ messages in thread
From: Carsten Otte @ 2005-06-20 11:09 UTC (permalink / raw)
  To: Mauricio Lin; +Cc: linux-kernel

On 6/20/05, Mauricio Lin <mauriciolin@gmail.com> wrote:
> I would like to know if there is a way to identify
> struct page that is cow (copy-on-write).
> 
> The way I figured out to identify cow pages is when
> copy-on-write happens. I mean I identify cow pages
> inside the do_wp_page(), the function that handles
> copy-on-write. I have checked do_no_page() as well.
> 
> I have included a field (is_cow) in the struct page to
> identify cow page.
> 
> struct page {
>      ...
>      atomic_t is_cow;
> }
> 
> But I wonder if it is possible to identify cow pages
> before copy-on-write happens. So identify cow pages in
> advance before any process tries to write to a cow
> page.
> 
> I have checked the do_fork(), copy_process() and
> copy_mm() function to try to identify cow pages during
> the process creation, but no success. In copy_mm(),
> just the mm (of current process) is provided to the
> child process, but there are no references to struct
> pages related to mm and its VMAs.
> 
> So when a page struct is considered a cow in the
> kernel and its count variable is updated? Certainly
> the counter page (page->_count) is updated when a page
> is shared because of copy-on-write feature.
> How can I identify cow pages when it becomes cow? Is
> there any feasible way to perform that?
Franky, one cannot predict which pages will get copied on
write since that is related to the behaviour of the process:
if the process writes, then the corresponding page gets copied.
If the vma has the VM_WRITE flag set, and the pte is read-only,
the page is a candidate to become subject to copy on write.

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

* Re: How to identify cow (copy-on-write) pages during kernel execution?
  2005-06-20 11:09 ` Carsten Otte
@ 2005-06-20 11:30   ` Mauricio Lin
  2005-06-20 11:35     ` Carsten Otte
  0 siblings, 1 reply; 5+ messages in thread
From: Mauricio Lin @ 2005-06-20 11:30 UTC (permalink / raw)
  To: Carsten Otte; +Cc: linux-kernel

Hi,

On 6/20/05, Carsten Otte <cotte.de@gmail.com> wrote:
> On 6/20/05, Mauricio Lin <mauriciolin@gmail.com> wrote:
> > I would like to know if there is a way to identify
> > struct page that is cow (copy-on-write).
> >
> > The way I figured out to identify cow pages is when
> > copy-on-write happens. I mean I identify cow pages
> > inside the do_wp_page(), the function that handles
> > copy-on-write. I have checked do_no_page() as well.
> >
> > I have included a field (is_cow) in the struct page to
> > identify cow page.
> >
> > struct page {
> >      ...
> >      atomic_t is_cow;
> > }
> >
> > But I wonder if it is possible to identify cow pages
> > before copy-on-write happens. So identify cow pages in
> > advance before any process tries to write to a cow
> > page.
> >
> > I have checked the do_fork(), copy_process() and
> > copy_mm() function to try to identify cow pages during
> > the process creation, but no success. In copy_mm(),
> > just the mm (of current process) is provided to the
> > child process, but there are no references to struct
> > pages related to mm and its VMAs.
> >
> > So when a page struct is considered a cow in the
> > kernel and its count variable is updated? Certainly
> > the counter page (page->_count) is updated when a page
> > is shared because of copy-on-write feature.
> > How can I identify cow pages when it becomes cow? Is
> > there any feasible way to perform that?
> Franky, one cannot predict which pages will get copied on
> write since that is related to the behaviour of the process:
> if the process writes, then the corresponding page gets copied.
> If the vma has the VM_WRITE flag set, and the pte is read-only,
> the page is a candidate to become subject to copy on write.

So the only way to identify copy-on-write pages is when page fault
related to copy-on-write happens, right? I mean in the
handle_pte_fault() that calls do_wp_page().

BR,

Mauricio Lin.

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

* Re: How to identify cow (copy-on-write) pages during kernel execution?
  2005-06-20 11:30   ` Mauricio Lin
@ 2005-06-20 11:35     ` Carsten Otte
  0 siblings, 0 replies; 5+ messages in thread
From: Carsten Otte @ 2005-06-20 11:35 UTC (permalink / raw)
  To: Mauricio Lin; +Cc: linux-kernel

On 6/20/05, Mauricio Lin <mauriciolin@gmail.com> wrote:
> So the only way to identify copy-on-write pages is when page fault
> related to copy-on-write happens, right? I mean in the
> handle_pte_fault() that calls do_wp_page().
That shows you at the time of copy, and at a given time later you can
also walk the mm and look that the pte's to see if they are writable.

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

end of thread, other threads:[~2005-06-20 11:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-20  5:45 How to identify cow (copy-on-write) pages during kernel execution? Mauricio Lin
2005-06-20  6:33 ` Nick Piggin
2005-06-20 11:09 ` Carsten Otte
2005-06-20 11:30   ` Mauricio Lin
2005-06-20 11:35     ` Carsten Otte

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