* question on memory mapping one page at a time
@ 2011-09-20 18:23 Sri Ram Vemulpali
2011-09-20 20:54 ` Jeff Haran
0 siblings, 1 reply; 5+ messages in thread
From: Sri Ram Vemulpali @ 2011-09-20 18:23 UTC (permalink / raw)
To: kernelnewbies
Hi all,
can anyone please explain the following code, what it is doing. I want
the first few statements of the code, as they are calculating page
frame number. This is little confusing, thanks in advance.
struct page *simple_vma_nopage(struct vm_area_struct *vma,
unsigned long address, int *type)
{
struct page *pageptr;
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
unsigned long physaddr = address - vma->vm_start + offset;
unsigned long pageframe = physaddr >> PAGE_SHIFT;
if (!pfn_valid(pageframe))
return NOPAGE_SIGBUS;
pageptr = pfn_to_page(pageframe);
get_page(pageptr);
if (type)
*type = VM_FAULT_MINOR;
return pageptr;
}
--
Regards,
Sri.
^ permalink raw reply [flat|nested] 5+ messages in thread
* question on memory mapping one page at a time
2011-09-20 18:23 question on memory mapping one page at a time Sri Ram Vemulpali
@ 2011-09-20 20:54 ` Jeff Haran
2011-09-21 3:42 ` rohan puri
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Haran @ 2011-09-20 20:54 UTC (permalink / raw)
To: kernelnewbies
> -----Original Message-----
> From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-
> bounces at kernelnewbies.org] On Behalf Of Sri Ram Vemulpali
> Sent: Tuesday, September 20, 2011 11:24 AM
> To: kernelnewbies
> Subject: question on memory mapping one page at a time
>
> Hi all,
>
> can anyone please explain the following code, what it is doing. I want
> the first few statements of the code, as they are calculating page
> frame number. This is little confusing, thanks in advance.
>
> struct page *simple_vma_nopage(struct vm_area_struct *vma,
> unsigned long address, int *type)
> {
> struct page *pageptr;
> unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
> unsigned long physaddr = address - vma->vm_start + offset;
> unsigned long pageframe = physaddr >> PAGE_SHIFT;
> if (!pfn_valid(pageframe))
> return NOPAGE_SIGBUS;
> pageptr = pfn_to_page(pageframe);
> get_page(pageptr);
> if (type)
> *type = VM_FAULT_MINOR;
> return pageptr;
> }
>
> --
> Regards,
> Sri.
Do a search on "Understanding the Linux Virtual Memory Manager" by Mel
Gorman. The PDF is out there for free or you can buy the hardcopy.
I think you will find the above code clearer after you've read the
above.
Jeff Haran
^ permalink raw reply [flat|nested] 5+ messages in thread
* question on memory mapping one page at a time
2011-09-20 20:54 ` Jeff Haran
@ 2011-09-21 3:42 ` rohan puri
2011-09-21 18:06 ` Sri Ram Vemulpali
0 siblings, 1 reply; 5+ messages in thread
From: rohan puri @ 2011-09-21 3:42 UTC (permalink / raw)
To: kernelnewbies
On Wed, Sep 21, 2011 at 2:24 AM, Jeff Haran <jharan@bytemobile.com> wrote:
> > -----Original Message-----
> > From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-
> > bounces at kernelnewbies.org] On Behalf Of Sri Ram Vemulpali
> > Sent: Tuesday, September 20, 2011 11:24 AM
> > To: kernelnewbies
> > Subject: question on memory mapping one page at a time
> >
> > Hi all,
> >
> > can anyone please explain the following code, what it is doing. I want
> > the first few statements of the code, as they are calculating page
> > frame number. This is little confusing, thanks in advance.
> >
> > struct page *simple_vma_nopage(struct vm_area_struct *vma,
> > unsigned long address, int *type)
> > {
> > struct page *pageptr;
> > unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
> > unsigned long physaddr = address - vma->vm_start + offset;
> > unsigned long pageframe = physaddr >> PAGE_SHIFT;
> > if (!pfn_valid(pageframe))
> > return NOPAGE_SIGBUS;
> > pageptr = pfn_to_page(pageframe);
> > get_page(pageptr);
> > if (type)
> > *type = VM_FAULT_MINOR;
> > return pageptr;
> > }
> >
> > --
> > Regards,
> > Sri.
>
> Do a search on "Understanding the Linux Virtual Memory Manager" by Mel
> Gorman. The PDF is out there for free or you can buy the hardcopy.
>
> I think you will find the above code clearer after you've read the
> above.
>
> Jeff Haran
>
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
Also you can go through the second chapter of understanding linux kernel.
Regards,
Rohan Puri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110921/d3ca9144/attachment.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* question on memory mapping one page at a time
2011-09-21 3:42 ` rohan puri
@ 2011-09-21 18:06 ` Sri Ram Vemulpali
2011-09-22 16:42 ` Ezequiel García
0 siblings, 1 reply; 5+ messages in thread
From: Sri Ram Vemulpali @ 2011-09-21 18:06 UTC (permalink / raw)
To: kernelnewbies
thanks for the replies.
On Tue, Sep 20, 2011 at 11:42 PM, rohan puri <rohan.puri15@gmail.com> wrote:
>
>
> On Wed, Sep 21, 2011 at 2:24 AM, Jeff Haran <jharan@bytemobile.com> wrote:
>>
>> > -----Original Message-----
>> > From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-
>> > bounces at kernelnewbies.org] On Behalf Of Sri Ram Vemulpali
>> > Sent: Tuesday, September 20, 2011 11:24 AM
>> > To: kernelnewbies
>> > Subject: question on memory mapping one page at a time
>> >
>> > Hi all,
>> >
>> > can anyone please explain the following code, what it is doing. I want
>> > the first few statements of the code, ?as they are calculating page
>> > frame number. This is little confusing, thanks in advance.
>> >
>> > struct page *simple_vma_nopage(struct vm_area_struct *vma,
>> > ? ? ? ? ? ? ? ? unsigned long address, int *type)
>> > {
>> > ? ? struct page *pageptr;
>> > ? ? unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
>> > ? ? unsigned long physaddr = address - vma->vm_start + offset;
>> > ? ? unsigned long pageframe = physaddr >> PAGE_SHIFT;
>> > ? ? if (!pfn_valid(pageframe))
>> > ? ? ? ? return NOPAGE_SIGBUS;
>> > ? ? pageptr = pfn_to_page(pageframe);
>> > ? ? get_page(pageptr);
>> > ? ? if (type)
>> > ? ? ? ? *type = VM_FAULT_MINOR;
>> > ? ? return pageptr;
>> > }
>> >
>> > --
>> > Regards,
>> > Sri.
>>
>> Do a search on "Understanding the Linux Virtual Memory Manager" by Mel
>> Gorman. The PDF is out there for free or you can buy the hardcopy.
>>
>> I think you will find the above code clearer after you've read the
>> above.
>>
>> Jeff Haran
>>
>>
>>
>>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
> Also you can go through the second chapter of understanding linux kernel.
>
> Regards,
> Rohan Puri
>
--
Regards,
Sri.
^ permalink raw reply [flat|nested] 5+ messages in thread
* question on memory mapping one page at a time
2011-09-21 18:06 ` Sri Ram Vemulpali
@ 2011-09-22 16:42 ` Ezequiel García
0 siblings, 0 replies; 5+ messages in thread
From: Ezequiel García @ 2011-09-22 16:42 UTC (permalink / raw)
To: kernelnewbies
--- El mi? 21-sep-11, Sri Ram Vemulpali <sri.ram.gmu06@gmail.com> escribi?:
> De: Sri Ram Vemulpali <sri.ram.gmu06@gmail.com>
> Asunto: Re: question on memory mapping one page at a time
> Para: "rohan puri" <rohan.puri15@gmail.com>
> Cc: "Jeff Haran" <jharan@bytemobile.com>, "kernelnewbies" <kernelnewbies@kernelnewbies.org>
> Fecha: mi?rcoles, 21 de septiembre de 2011, 15:06
> thanks for the replies.
>
> On Tue, Sep 20, 2011 at 11:42 PM, rohan puri <rohan.puri15@gmail.com>
> wrote:
> >
> >
> > On Wed, Sep 21, 2011 at 2:24 AM, Jeff Haran <jharan@bytemobile.com>
> wrote:
> >>
> >> > -----Original Message-----
> >> > From: kernelnewbies-bounces at kernelnewbies.org
> [mailto:kernelnewbies-
> >> > bounces at kernelnewbies.org]
> On Behalf Of Sri Ram Vemulpali
> >> > Sent: Tuesday, September 20, 2011 11:24 AM
> >> > To: kernelnewbies
> >> > Subject: question on memory mapping one page
> at a time
> >> >
> >> > Hi all,
> >> >
> >> > can anyone please explain the following code,
> what it is doing. I want
> >> > the first few statements of the code, ?as
> they are calculating page
> >> > frame number. This is little confusing,
> thanks in advance.
> >> >
> >> > struct page *simple_vma_nopage(struct
> vm_area_struct *vma,
> >> > ? ? ? ? ? ? ? ? unsigned long
> address, int *type)
> >> > {
> >> > ? ? struct page *pageptr;
> >> > ? ? unsigned long offset = vma->vm_pgoff
> << PAGE_SHIFT;
> >> > ? ? unsigned long physaddr = address -
> vma->vm_start + offset;
> >> > ? ? unsigned long pageframe = physaddr
> >> PAGE_SHIFT;
> >> > ? ? if (!pfn_valid(pageframe))
> >> > ? ? ? ? return NOPAGE_SIGBUS;
> >> > ? ? pageptr = pfn_to_page(pageframe);
> >> > ? ? get_page(pageptr);
> >> > ? ? if (type)
> >> > ? ? ? ? *type = VM_FAULT_MINOR;
> >> > ? ? return pageptr;
> >> > }
> >> >
> >> > --
> >> > Regards,
> >> > Sri.
> >>
> >> Do a search on "Understanding the Linux Virtual
> Memory Manager" by Mel
> >> Gorman. The PDF is out there for free or you can
> buy the hardcopy.
Does this means that Gorman's book is still useful? I thought it was too outdated.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-09-22 16:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-20 18:23 question on memory mapping one page at a time Sri Ram Vemulpali
2011-09-20 20:54 ` Jeff Haran
2011-09-21 3:42 ` rohan puri
2011-09-21 18:06 ` Sri Ram Vemulpali
2011-09-22 16:42 ` Ezequiel García
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).