virtual-memory

Win32 memory allocation with large alignment

半城伤御伤魂 提交于 2019-12-01 07:57:45
问题 I need to allocate large regions of memory (megabytes) with large alignments (also potentially in the megabyte range). The VirtualAlloc family of functions don't seem to provide options to do this. What I do on Linux to achieve this is to mmap a larger region - large enough to guarantee that a sufficiently large region with the required alignment will be contained in it - and then munmap the regions at the beginning and the end of the large region that are not needed. As an example, let's say

Traversing all the physical pages of a process

末鹿安然 提交于 2019-11-30 19:18:53
问题 In a kernel module (2.6.32-358.el6.x86_64) I'd like to print out all the physical addresses, which are mapped into a process' virtual memory. Given task->mm , I attempt to traverse the process' struct page 's as follows: int i, j, k, l; for (i = 0; i < PTRS_PER_PGD; ++i) { pgd_t *pgd = mm->pgd + i; if (pgd_none(*pgd) || pgd_bad(*pgd)) continue; for (j = 0; j < PTRS_PER_PUD; ++j) { pud_t *pud = (pud_t *)pgd_page_vaddr(*pgd) + j; if (pud_none(*pud) || pud_bad(*pud)) continue; for (k = 0; k <

Allocating copy on write memory within a process

十年热恋 提交于 2019-11-30 10:28:35
问题 I have a memory segment which was obtained via mmap with MAP_ANONYMOUS . How can I allocate a second memory segment of the same size which references the first one and make both copy-on write in Linux (Working Linux 2.6.36 at the moment)? I want to have exactly the same effect as fork , just without creating a new process. I want the new mapping to stay in the same process. The whole process has to be repeatable on both the origin and copy pages (as if parent and child would continue to fork

Java program with 16GB virtual memory and growing: is it a problem?

喜欢而已 提交于 2019-11-30 09:58:27
On Mac OSX 5.8 I have a Java program that runs at 100% CPU for a very long time -- several days or more (it's a model checker analyzing a concurrent program, so that's more or less expected). However, its virtual memory size, as shown in OSX's Activity Monitor, becomes enormous after a day or so: right now it's 16GB and growing. Physical memory usage is roughly stable at 1.1GB or so. I would like to know: is the 16GB (and growing) a sign of problems that could be slowing my program? I start the program with "java -Xmx1024m -ea" java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6

fork() failing with Out of memory error

浪尽此生 提交于 2019-11-30 09:13:51
The parent process fails with errno=12(Out of memory) when it tries to fork a child. The parent process runs on Linux 3.0 kernel - SLES 11. At the point of forking the child, the parent process has already used up around 70% of the RAM(180GB/256GB). Is there any workaround for this problem? The application is written in C++, compiled with g++ 4.6.3. Maybe virtual memory over commit is prevented in your system. If it is prevented, then the virtual memory can not be bigger than sizeof physical RAM + swap. If it is allowed, then virtual memory can be bigger than RAM+swap. When your process forks,

Convert logical (virtual) address to physical address

风格不统一 提交于 2019-11-30 08:03:17
I have the following page table of process1 : Assuming that the paging system works with 16bit addresses and page size is 4k And I want to convert the logical address 16000 to a physical address . I'm a little bit new in this topic so go easy on me : Partial solution : The address 16000 fits cell number 3 in the page table , so I guess that I need to work with that cell and its stored frame - 2 . How can I find the offset and the physical address now ? Thanks In your case process 1 currently can access upto 4 * 4k bytes of virtual memory. Generally a process can access upto 4gb of virtual

Pointer implementation details in C

百般思念 提交于 2019-11-30 06:40:36
I would like to know architectures which violate the assumptions I've listed below. Also, I would like to know if any of the assumptions are false for all architectures (that is, if any of them are just completely wrong). sizeof(int *) == sizeof(char *) == sizeof(void *) == sizeof(func_ptr *) The in-memory representation of all pointers for a given architecture is the same regardless of the data type pointed to. The in-memory representation of a pointer is the same as an integer of the same bit length as the architecture. Multiplication and division of pointer data types are only forbidden by

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

Allocating copy on write memory within a process

混江龙づ霸主 提交于 2019-11-29 21:02:59
I have a memory segment which was obtained via mmap with MAP_ANONYMOUS . How can I allocate a second memory segment of the same size which references the first one and make both copy-on write in Linux (Working Linux 2.6.36 at the moment)? I want to have exactly the same effect as fork , just without creating a new process. I want the new mapping to stay in the same process. The whole process has to be repeatable on both the origin and copy pages (as if parent and child would continue to fork ). The reason why I don't want to allocate a straight copy of the whole segment is because they are

Physical or virtual addressing is used in processors x86/x86_64 for caching in the L1, L2 and L3?

余生长醉 提交于 2019-11-29 20:11:30
Which addressing is used in processors x86/x86_64 for caching in the L1, L2 and L3(LLC) - physical or virtual(using PT/PTE and TLB ) and somehow does PAT(page attribute table) affect to it? And is there difference between the drivers(kernel-space) and applications(user-space) in this case? Short answer - Intel uses virtually indexed, physically tagged (VIPT) L1 caches: What will be used for data exchange between threads are executing on one Core with HT? L1 - Virtual addressing (in 8-way cache for define Set is required low 12 bits which are the same in virt & phys) L2 - Physical addressing