LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-20-2015, 02:01 PM   #1
nhua
LQ Newbie
 
Registered: Apr 2015
Posts: 2

Rep: Reputation: Disabled
The address mapping from Virtual to Physical memory


I used valloc in user mode to get the memory. The valloc address returned is 0. Does Linux user mode have API can get this physical address? For testing and debugging purpose, I need to know where the virtual address 0 is mapped into physical memory.
Thanks,
-Nelson

Last edited by nhua; 04-20-2015 at 02:12 PM.
 
Old 04-20-2015, 04:16 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora 34
Posts: 3,695

Rep: Reputation: 1075Reputation: 1075Reputation: 1075Reputation: 1075Reputation: 1075Reputation: 1075Reputation: 1075Reputation: 1075
valloc allocates virtual memory. There may not be any physical memory assigned until you attempt to use it and cause a page fault (lazy allocation), so there may not be any mapping. In any case, the mapping can change at any time depending on the demands on physical memory.
 
Old 04-20-2015, 04:47 PM   #3
nhua
LQ Newbie
 
Registered: Apr 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
The return address value of valloc

Thanks!
I am trying to evaluate the performance of Intel E5, so I called fork{} to generate child process, then inside child process, valloc and mlock to allocate memory for each CPU's thread, but what I got all of 20 thread's virtual memory addresses from the return of valloc were 0. They sounded incorrectly, didn't they?
Thanks,
-Nelson
 
Old 04-20-2015, 04:51 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
0 is not a correct virtual address. 0 is a reserved virtual address. As a return from valloc, 0 means the request failed.


It is correct that each fork would tend to return the same virtual address. That represents different memory, because each process has its own mapping of virtual to physical. But 0 is not correct.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mapping Kernel virtual address space to Physical memory zones (ZONE_DMA, ZONE_NORMAL) kumart Linux - Newbie 2 04-03-2012 10:11 AM
Is there a way to insert an arbitrary virtual to physical address mapping? Joe Loos Linux - Kernel 1 04-20-2011 08:58 PM
Find virtual to physical address mapping in Kernel? bkankru Linux - Kernel 2 11-09-2009 03:15 PM
API for mapping Physical Address to Virtual Address Lakshman_smt Linux - Software 2 10-15-2006 10:08 PM
Memory Mapping (same physical address = virtual address) skd.tech Linux - Kernel 7 07-25-2006 12:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration