2005-03-13 01:05:15

by Allison

[permalink] [raw]
Subject: Linux 2.6 : physical memory address and pid

Hi,

With the 2.6 Linux kernel, I want to find, from the physical page
frame, the virtual address of the page loaded in the frame and the
process id of the process owning it.

I know that 2.6 kernel implements rmap where the page points to a pte
chain. But how to I get to the pid and virtual address from pte entry?

I have tried to become a member of this list. But don't have a confirmation yet.
So, please cc the replies to me.

thanks,
Allison


2005-03-13 01:23:50

by Matt Mackall

[permalink] [raw]
Subject: Re: Linux 2.6 : physical memory address and pid

On Sat, Mar 12, 2005 at 08:05:11PM -0500, firefly blue wrote:
> Hi,
>
> With the 2.6 Linux kernel, I want to find, from the physical page
> frame, the virtual address of the page loaded in the frame and the
> process id of the process owning it.

Follow struct page->mapping to struct address_space. A page can be
mapped into any number of processes and multiple times per process so
you'll need to walk the data structures there.

--
Mathematics is the supreme nostalgia of our time.

2005-03-13 04:17:17

by Allison

[permalink] [raw]
Subject: Re: Linux 2.6 : physical memory address and pid

Thanks for the answer!

Another related question :

I need to gather all application pages by reading the page tables.
The hard part is, I need to do this from a PCI device using DMA. As I
understand it, when a DMA is being performed, the pages are pinned in
memory . Since the PCI device has grabbed the bus, the processor is
not able to access memory to perform page replacement right ?
So, this is a form of mutual exclusion.

However, if I have to fetch the page struct, the process address space
of the process owning the page (I am ignoring shared pages to make
things simpler) and the page itself, will a scatter gather DMA make
sure that the processor cannot modify any of these data structures
till the DMA is complete ? I am using Linux 2.6 and the i386
architecture.

thanks,
Allison





On Sat, 12 Mar 2005 17:23:23 -0800, Matt Mackall <[email protected]> wrote:
> On Sat, Mar 12, 2005 at 08:05:11PM -0500, firefly blue wrote:
> > Hi,
> >
> > With the 2.6 Linux kernel, I want to find, from the physical page
> > frame, the virtual address of the page loaded in the frame and the
> > process id of the process owning it.
>
> Follow struct page->mapping to struct address_space. A page can be
> mapped into any number of processes and multiple times per process so
> you'll need to walk the data structures there.
>
> --
> Mathematics is the supreme nostalgia of our time.
>

2005-03-13 07:44:36

by Robert Hancock

[permalink] [raw]
Subject: Re: Linux 2.6 : physical memory address and pid

Allison wrote:
> Thanks for the answer!
>
> Another related question :
>
> I need to gather all application pages by reading the page tables.
> The hard part is, I need to do this from a PCI device using DMA. As I
> understand it, when a DMA is being performed, the pages are pinned in
> memory . Since the PCI device has grabbed the bus, the processor is
> not able to access memory to perform page replacement right ?
> So, this is a form of mutual exclusion.

I don't think it works this way - if the system is modifying the pages
which you're trying to do DMA reads on, you'll just read whatever data
happens to be in memory at the time. The CPU is not "locked out" just
because that memory is being read by a DMA transfer.

>
> However, if I have to fetch the page struct, the process address space
> of the process owning the page (I am ignoring shared pages to make
> things simpler) and the page itself, will a scatter gather DMA make
> sure that the processor cannot modify any of these data structures
> till the DMA is complete ? I am using Linux 2.6 and the i386
> architecture.

As above, I don't think anything ensures this. Doing DMA reads on pages
that could potentially be being modified during the transfer isn't
something that is typically done..