Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PFN to Base Address

10 views
Skip to first unread message

Bithika Khargharia

unread,
Nov 15, 2006, 12:34:38 PM11/15/06
to
Hi,

1. Given the PFN, how do I obtain the base physical address for the PFN.

I use
             'pfn <<12'.

Is this correct?

2. Does the kernel generate PFN serailly from 0 to TOTAL_PHYS or are there breaks in between?

Thanks
Bithika

Fawad Lateef

unread,
Nov 16, 2006, 12:18:14 AM11/16/06
to
On 11/15/06, Bithika Khargharia <bit...@gmail.com> wrote:
> Hi,
>
> 1. Given the PFN, how do I obtain the base physical address for the PFN.
>
> I use
> 'pfn <<12'.
>
> Is this correct?

Yes 'pfn << PAGE_SHIFT' gives physical-base-address although its
better to use page_to_phys macro

>
> 2. Does the kernel generate PFN serailly from 0 to TOTAL_PHYS or are there
> breaks in between?
>

Yes serially for x86 from 0UL but might contain some starting offset
according to some architectures. Take a look at page_to_phys macro
(http://lxr.free-electrons.com/source/include/asm-i386/io.h#101) and
__page_to_pfn macro
(http://lxr.free-electrons.com/source/include/asm-generic/memory_model.h#032)


--
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/


Bithika Khargharia

unread,
Nov 16, 2006, 2:24:17 PM11/16/06
to
Hi,

1. I checked the ARCH_PFN_OFFSET variable for my kernel and it was set to 0. In that case the kernel should generate PFN serially from 0 to TOTAL_PHYS. Am I right?

2. What confuses me is the following. I know that I have 8 GB of memory physically installed on my System. 8 GB should translate to a PFN of 2097152
(8 * 2^30)/4 where 4KB is the PAGE_SIZE in my system. However the kernel gives a TOTAL_PHYS value of 2411724 which is almost equal to 9.2 GB of memory. If PFNs are generated serially why do I have this problem of higher PFNs that 8 GB?

Thanks
Bithika

On 11/15/06, Fawad Lateef <fawad...@gmail.com> wrote:
On 11/15/06, Bithika Khargharia <bit...@gmail.com> wrote:
> Hi,
>
> 1. Given the PFN, how do I obtain the base physical address for the PFN.
>
> I use
>              'pfn <<12'.
>
> Is this correct?

Yes 'pfn << PAGE_SHIFT' gives physical-base-address although its
better to use page_to_phys macro

>
> 2. Does the kernel generate PFN serailly from 0 to TOTAL_PHYS or are there
> breaks in between?
>

Yes serially for x86 from 0UL but might contain some starting offset
according to some architectures. Take a look at page_to_phys macro



--
O for a Life of Sensations rather than of Thoughts!-- Keats

Fawad Lateef

unread,
Nov 17, 2006, 3:05:54 AM11/17/06
to
On 11/17/06, Bithika Khargharia <bit...@gmail.com> wrote:
> Hi,
>
> 1. I checked the ARCH_PFN_OFFSET variable for my kernel and it was set to 0.
> In that case the kernel should generate PFN serially from 0 to TOTAL_PHYS.
> Am I right?
>

Yes, Right. In kernel/protected_mode the memory is referenced/accessed
through pages not from physical addresses and pages have pfn which is
directly associated with physical address by PAGE_SHIFT bits

> 2. What confuses me is the following. I know that I have 8 GB of memory
> physically installed on my System. 8 GB should translate to a PFN of 2097152
> (8 * 2^30)/4 where 4KB is the PAGE_SIZE in my system. However the kernel
> gives a TOTAL_PHYS value of 2411724 which is almost equal to 9.2 GB of
> memory. If PFNs are generated serially why do I have this problem of higher
> PFNs that 8 GB?
>

The PFNs AFAIK must be 2097152 for 8GB RAM, have you tried to do
read/kmap physical-memory representing by PFN greater-than 2097152 ?
TOTAL_PHYS is the term you are referring for total-physical-memory or
its used in the kernel too ? as I not able to find-out that TOTAL_PHYS
in kernel sources. AFAIR max_mapnr variable (if CONFIG_DISCONTIGMEM
isn't defined) can tell maximum number of pages (of physical-memory)
available in system/kernel which actually calculated during memory
initialization at boot-time.

If still not able to get things correctly then please provide you
kernel version number and config file.

Bithika Khargharia

unread,
Nov 21, 2006, 11:47:05 AM11/21/06
to
Thanks Fawad,

On 11/18/06, Fawad Lateef <fawad...@gmail.com> wrote:

Your complete system information to know will be good for better
understanding of your ptoblem. Means output of 'uname -a' and
processor/motherboard model.

uname -a gives Linux dhcp-233.ece.arizona.edu 2.6.18 #131 SMP Fri Nov 17 16:38:34 MST 2006 i686 i686 i386 GNU/Linux.I have dual core Intel xeon processor and the motherboard is Intel® Server Board S5000PAL

I can't say exactly what is happening on your side, might be some
in-compatiblity of your motherboard (bios) with Linux Kernel. But the
thing which you can see is: point 8. Total usable pfns =  2070237 =
~8GB memory, so might possible your bios is telling IO-Devices mapped
region as some more memory available (but I am not sure about this).
 
That's a good point. Also with total usable pfns = 2070237 and last usable pfn 2490368
there must be some PFNs in between that are IO-Devices mapped as you mentioned perhaps.

Have you tried to read/write/kmap on pages whose pfns are giving
physical address after 8GB ? Is it working ? and what memory size 'cat
/proc/meminfo' is mentioning ?

No I have not. I will try that and let you know what happens. cat /proc/meminfo actually gives  MemTotal: 8280948 kB !!
 
Its better is you also do CC to kernelnewbies, so that some other
person might give you some better idea too. And please don't do
top-posting, rather do bottom-posting (search google for it) on
mailing-list while replying.

Thanks Fawad or introducing me to the lists'  netiquettes


Bithika

Fawad Lateef

unread,
Nov 21, 2006, 12:43:54 PM11/21/06
to
On 11/21/06, Bithika Khargharia <bit...@gmail.com> wrote:
> Thanks Fawad,
>
> On 11/18/06, Fawad Lateef <fawad...@gmail.com> wrote:
>
>
> > Your complete system information to know will be good for better
> > understanding of your ptoblem. Means output of 'uname -a' and
> > processor/motherboard model.
> >
>
> uname -a gives Linux dhcp-233.ece.arizona.edu 2.6.18 #131 SMP Fri Nov 17
> 16:38:34 MST 2006 i686 i686 i386 GNU/Linux.I have dual core Intel xeon
> processor and the motherboard is Intel(r) Server Board S5000PAL

>
> > I can't say exactly what is happening on your side, might be some
> > in-compatiblity of your motherboard (bios) with Linux Kernel. But the
> > thing which you can see is: point 8. Total usable pfns = 2070237 =
> > ~8GB memory, so might possible your bios is telling IO-Devices mapped
> > region as some more memory available (but I am not sure about this).
>
>
> That's a good point. Also with total usable pfns = 2070237 and last usable
> pfn 2490368
> there must be some PFNs in between that are IO-Devices mapped as you
> mentioned perhaps.
>

Yes, this might be the case. Try google for your possible bios related issues.


> > Have you tried to read/write/kmap on pages whose pfns are giving
> > physical address after 8GB ? Is it working ? and what memory size 'cat
> > /proc/meminfo' is mentioning ?
>
> No I have not. I will try that and let you know what happens. cat
> /proc/meminfo actually gives MemTotal: 8280948 kB !!
>

This means Linux/Kernel actually knows ~8GB memory so will use only
8GB, now as I said might be your memory mapped IO devices is also
counted in your total_pfns. Someone might give more/correct details

> > Its better is you also do CC to kernelnewbies, so that some other
> > person might give you some better idea too. And please don't do
> > top-posting, rather do bottom-posting (search google for it) on
> > mailing-list while replying.
>
> Thanks Fawad or introducing me to the lists' netiquettes
>

No problem :)

0 new messages