page fault handle


 
Thread Tools Search this Thread
Operating Systems Linux page fault handle
# 1  
Old 09-28-2009
page fault handle

For zero-copy communication among the processor, I allocated a pool in the kernel. From user space, it may mmap the virtual memory device into user space i.e 0x80000000. the client may send a message to the server, it may request a buffer, kernel will allocate a block for it and register it into the pool. After that, the client(user space) will got an address(that has been translated into user space address) for example: it will be 0x80003ffe4, the kernel will record the offset 0x3ffe4 into pool. But during write the the user space address 0x80003ffe4, I track the memory fault handle process, I got the vmf->virtual_address - vma->start = 0x3f000, I follow the offset 0x3f000 to find the page, in fact, the offset is not right.
So, why is the offset 0x3f000 other than 0x3ffe4?

The call flow:

char *buf = ipczalloc(6); // buf = 0x80003ffe4.
memcpy(buf, "12345", 5); // will enter vma fault handle


The code as below:
static int ipcmem_vm_nopage(struct vm_area_struct* vma, struct vm_fault * vmf)
{
unsigned long offset;
offset = vmf->virtual_address - vma->start;
printk("the offset is %x.\n", offset);
}

---------- Post updated 09-28-09 at 12:52 AM ---------- Previous update was 09-27-09 at 11:23 PM ----------

I got the answer, since the kernel before do the page fault,
the vmf.virtual_address = (void __user *)(address & PAGE_MASK)


PAGE_MASK = ~(0xFFF)

From the kernel source code, there is no way to get the real user address from vm fault handler.

So, are there any better to handle that?
a2156z
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

2. Shell Programming and Scripting

script for adding page number before page breaks

Hi, If there is an expert that can help: I have many txt files that are produced from pdftotext that include page breaks the page breaks seem to be unix style hex 0C. I want to add page numbers before each page break as in : Page XXXX Regards antman (9 Replies)
Discussion started by: antman
9 Replies

3. Shell Programming and Scripting

Print multiple copies page by page using lp command

Hi I have a pdf file that is being generated using the rwrun command in the shell script. I then have the lp command in the shell script to print the same pdf file. Suppose there are 4 pages in the pdf file , I need to print 2 copies of the first page, 2 copies of the second page , then 2... (7 Replies)
Discussion started by: megha2525
7 Replies

4. Web Development

Page load time- local page

Hi Is there a way to calculate the page load time, I am trying to calculate the load time of a page locally. I found tools to do this over http or https but none that work locally. Any ideas? Thanks. (4 Replies)
Discussion started by: jamie_123
4 Replies

5. UNIX for Dummies Questions & Answers

Difference between handle to the thread HANDLE and thread identifier pthread_t

This question might be silly but its confusing me a bit: What is the difference between handle to the thread HANDLE and thread identifier pthread_t? ---------- Post updated at 01:52 PM ---------- Previous update was at 01:48 PM ---------- Sorry I saw details and HANDLE is in windows and... (0 Replies)
Discussion started by: rupeshkp728
0 Replies

6. UNIX for Dummies Questions & Answers

Page Fault + Memory

I am not sure where to post this so i will put it in the newbie section. I have set up a bog standard debain 6, LAMP environment in the cloud. The specs 1 core at 2GH 2.5gb Memory running Jommla, with about 1.6K visitors a day. I am using AppFirst (appfirst.com) to monitor the... (2 Replies)
Discussion started by: waseem
2 Replies

7. UNIX for Advanced & Expert Users

Page fault in kernel

I have a query (Don't know whether its the right folder to ask) ................. What happens when page fault happens in Kernel ..(as the kernel mode is non-preemptive)... any guesses... Thanks in advance (2 Replies)
Discussion started by: yash0101
2 Replies

8. Solaris

Page Fault very high

Hi, We are running SUN sparc 5.8, notice frequent "Page Faults" message from our monitor s/w "ServerVantage" coming but no message display in SUN syslog or messages log. Any ideas why or what to check? thanks, Ahmad (2 Replies)
Discussion started by: Ahmad
2 Replies

9. HP-UX

Data page fault

What causes 'page data fault' or 'data memory protection fault' under HP-UX 11. The server crashes and the shutdownlog reports the above error. For your info, Oracle 8i is running . Appreciate your fast response, Wobitu :confused: (2 Replies)
Discussion started by: wobitu
2 Replies
Login or Register to Ask a Question
ost::MemPager(3)					     Library Functions Manual						  ost::MemPager(3)

NAME
ost::MemPager - The memory pager is used to allocate cumulative memory pages for storing object specific 'persistant' data that is presumed to persist during the life of a given derived object. SYNOPSIS
#include <misc.h> Inherited by ost::Keydata [protected], ost::SharedMemPager, and ost::StackPager [protected]. Classes struct _page Public Member Functions int getPages (void) Return the total number of pages that have been allocated for this memory pool. Protected Member Functions virtual void * first (size_t size) Allocate first workspace from paged memory. virtual void * alloc (size_t size) Allocate memory from either the currently active page, or allocate a new page for the object. char * first (char *str) Allocate a string from the memory pager pool and copy the string into it's new memory area. char * alloc (const char *str) Allocate a string from the memory pager pool and copy the string inti it's new memory area. MemPager (size_t pagesize=4096) Create a paged memory pool for cumulative storage. void purge (void) purge the current memory pool. void clean (void) Clean for memory cleanup before exiting. virtual ~MemPager () Delete the memory pool and all allocated memory. Friends class String class MemPagerObject Detailed Description The memory pager is used to allocate cumulative memory pages for storing object specific 'persistant' data that is presumed to persist during the life of a given derived object. When the object is destroyed, all accumulated data is automatically purged. There are a number of odd and specialized utility classes found in Common C++. The most common of these is the 'MemPager' class. This is basically a class to enable page-grouped 'cumulative' memory allocation; all accumulated allocations are dropped during the destructor. This class has found it's way in a lot of other utility classes in Common C++. Author: David Sugar dyfet@ostel.com Accumulative object memory allocator. Constructor &; Destructor Documentation ost::MemPager::MemPager (size_tpagesize = 4096) [protected] Create a paged memory pool for cumulative storage. This pool allocates memory in fixed 'pagesize' chunks. Ideal performance is achived when the pool size matches the system page size. This pool can only exist in derived objects. Parameters: pagesize page size to allocate chunks. virtual ost::MemPager::~MemPager () [protected], [virtual] Delete the memory pool and all allocated memory. Member Function Documentation virtual void* ost::MemPager::alloc (size_tsize) [protected], [virtual] Allocate memory from either the currently active page, or allocate a new page for the object. Parameters: size size of memory to allocate. Returns: pointer to allocated memory. Reimplemented in ost::SharedMemPager. char* ost::MemPager::alloc (const char *str) [protected] Allocate a string from the memory pager pool and copy the string inti it's new memory area. This checks only the last active page for available space before allocating a new page. Parameters: str string to allocate and copy into paged memory pool. Returns: copy of string from allocated memory. void ost::MemPager::clean (void) [protected] Clean for memory cleanup before exiting. virtual void* ost::MemPager::first (size_tsize) [protected], [virtual] Allocate first workspace from paged memory. This method scans all currently allocated blocks for available space before adding new pages and hence is both slower and more efficient. Parameters: size size of memory to allocate. Returns: pointer to allocated memory. Reimplemented in ost::SharedMemPager. char* ost::MemPager::first (char *str) [protected] Allocate a string from the memory pager pool and copy the string into it's new memory area. This method allocates memory by first searching for an available page, and then allocating a new page if no space is found. Parameters: str string to allocate and copy into paged memory pool. Returns: copy of string from allocated memory. int ost::MemPager::getPages (void) [inline] Return the total number of pages that have been allocated for this memory pool. Returns: number of pages allocated. void ost::MemPager::purge (void) [protected] purge the current memory pool. Reimplemented in ost::SharedMemPager, and ost::StackPager. Friends And Related Function Documentation friend class MemPagerObject [friend] friend class String [friend] Author Generated automatically by Doxygen for GNU CommonC++ from the source code. GNU CommonC++ Sat Jun 23 2012 ost::MemPager(3)