page-fault

What happens when a mov instruction causes a page fault with interrupts disabled on x86?

情到浓时终转凉″ 提交于 2019-12-04 16:33:01
问题 I recently encountered an issue in a custom Linux kernel (2.6.31.5, x86) driver where copy_to_user would periodically not copy any bytes to user space. It would return the count of bytes passed to it, indicating that it had not copied anything. After code inspection we found that the code was disabling interrupts while calling copy_to_user which violates it's contract. After correcting this, the issue stopped occurring. Because the issue happened so infrequently, I need to prove that

How to Disable Copy-on-write and zero filled on demand for mmap()

笑着哭i 提交于 2019-12-04 05:22:53
I am implementing cp(file copy) command using mmap(). For that I mapped the source file in MAP_PRIVATE (As I just want to read)mode and destination file in MAP_SHARED mode(As I have to writeback the changed content of destination file). While doing this I have observed performance penalty due to lots of minor page faults that occurs due to 2 reason. 1) Zero fill on demand while calling mmap(MAP_PRIVATE) for source file. 2) Copy on write while calling mmap(MAP_SHARED) for destination file. Is there any way to disable Zero-fill-on-demand and Copy-on-write ? Thanks, Harish There is MMAP_POPULATE

Calculating number of page faults for 2-d array

心不动则不痛 提交于 2019-12-03 16:51:56
问题 I am trying to study for an exam..and I found this example but can't understand how they got the answer. Can anyone explain it please? Question: Consider the two-dimensional array A: int A[][] = new int[100][100]; where A[0][0] is at location 200 in a paged memory system with pages of size 200. A small process that manipulates the matrix resides in the page 0 (location 0 to 199). Thus every instruction fetch will be from page 0. For two page frames, how many page faults are generated by the

Minimizing page faults (and TLB faults) while “walking” a large graph

我与影子孤独终老i 提交于 2019-12-01 11:55:48
Problem (think of the mark phase of a GC) I have a graph of “objects” that I need to walk, visiting all objects. I can store in each object if it has been visited. All the objects are stored in memory and linked together using normal pointers. The objects are not all the same size. Sometimes there is not enough ram in the system to hold all the objects in memory at the same time, and I wish to avoid “page thrashing”. I also wish to avoid TLB faults Other times, there is more than enough ram. I do not mind writing low-level code. I do not mind different code for windows and linux. The code must

Getting External Exception C0000006 in D2006 app - how can I force delphi to load the whole executable?

雨燕双飞 提交于 2019-12-01 11:39:05
I get this occasionally when exiting my app - my app is running the EXE over a network. I understand it's a page fault when part of the EXE is loaded on demand. I have also observed it in the OnDrawCell method of a TDrawGrid, so I'm mystified how that might have caused a page load. Also, the exception kept happening. So my questions: Can Error C0000006 result from other causes? I have made fairly major changes to the way the app manages memory, though nothing out of the ordinary, and I'm confident the code is behaving. How can you make the app load all of itself into memory on startup (in

Linux, will zeroed page pagefault on first read or on first write?

牧云@^-^@ 提交于 2019-11-30 04:11:02
问题 My question is Linux specific and needs understanding of kernel, virtual memory, mmap, pagefaults. I have C program with large static arrays, which will go into bss section (memory, initialized to zero). When program starts, this memory is not physically allocated, there is only virtual memory, and every page of virtual memory is mapped to the special zero page (the page of all zeroes). When application access this page, the pagefault will be generated and physical page will be allocated. The

segmentation fault vs page fault

北城以北 提交于 2019-11-29 20:42:57
I was wondering what differences and relations are between segmentation fault and page fault? Does segmentation fault only belong to segmented memory model? Does page fault only belong to paged memory model? If both are yes, since most computer systems such as x86 and Linux use paged memory model instead of segmented memory model, why does GCC C compiler sometimes report segmentation fault error? Thanks and regards! These two things are very dissimilar, actually. A segmentation fault means a program tried to access an invalid or illegal memory address: for example, 0, or a value larger than

Measure page faults from a c program

天涯浪子 提交于 2019-11-28 07:03:22
I am comparing a few system calls where I read/write from/to memory. Is there any API defined to measure page faults (pages in/out) in C ? I found this library libperfstat.a but it is for AIX , I couldn't find anything for linux. Edit: I am aware of time & perf-stat commands in linux, just exploring if there is anything available for me to use inside the C program. osgx There is getrusage function (SVr4, 4.3BSD. POSIX.1-2001; but not all fields are defined in standard). In linux there are several broken fields , but man getrusage lists several interesting fields: long ru_minflt; /* page

Measure page faults from a c program

非 Y 不嫁゛ 提交于 2019-11-27 01:41:49
问题 I am comparing a few system calls where I read/write from/to memory. Is there any API defined to measure page faults (pages in/out) in C ? I found this library libperfstat.a but it is for AIX , I couldn't find anything for linux. Edit: I am aware of time & perf-stat commands in linux, just exploring if there is anything available for me to use inside the C program. 回答1: There is getrusage function (SVr4, 4.3BSD. POSIX.1-2001; but not all fields are defined in standard). In linux there are