virtual-memory

Is it possible to allocate large amount of virtual memory in linux?

喜夏-厌秋 提交于 2021-01-02 06:45:17
问题 It would be efficient for some purposes to allocate a huge amount of virtual space, and page in only pages that are accessed. Allocating a large amount of memory is instantaneous and does not actually grab pages: char* p = new char[1024*1024*1024*256]; Ok, the above was wrong as pointed out because it's a 32 bit number. I expect that new is calling malloc which calls sbrk, and that when I access a location 4Gb beyond the start, it tries to extend the task memory by that much? Here is the full

How Page Tables are stored in the main memory?

▼魔方 西西 提交于 2020-12-06 09:03:37
问题 i know that page tables are stored in memory , and each process has its own table , but each table has entries as the number of virtual pages in virtual memory so how can every process has a table and each table resides in main memory besides , the number of entries in each table is larger than the number of physical pages in main memory ...can someone explain that to me i'm very confused , Thanks in Advance. 回答1: Typically, page tables are said to be stored in the kernel-owned physical

Disabling Paging in x86 32bit

最后都变了- 提交于 2020-07-18 05:37:28
问题 I am trying to write directly to a physical memory location, so I am using an assembly function to first disable paging, write the value, and then re-enable paging, but for some reason a page fault is still triggered when trying to write the value. As I understand it, in x86-32bit, paging is set on and off by flipping bit 32 in cr0, so here is my assembly function: mov 4(%esp), %ecx //address mov 8(%esp), %edx //value mov %cr0, %eax and $0x7fffffff, %eax mov %eax, %cr0 mov %edx, (%ecx) //this

Determining page numbers and offsets for given addresses

两盒软妹~` 提交于 2020-06-22 11:41:05
问题 Consider a computer system with a 32-bit logical address and 4KB page size. The system supports up to 512MB of physical memory. How many entries are there in a conventional single-level page table? Conventional single-level page table: 2^32 / 2^12 (4000) = 2^20 = 1,048,576 Why did I have to divide 2^32 / 2^12 to get the answer? How many entries are there in an inverted page table? An inverted page table needs as many entries as there are page frames in memory. Inverted page table: 2^29 (512mb

Storing the result of .dvalloc to a variable

大憨熊 提交于 2020-06-16 05:06:07
问题 Is it possible to store the result of .dvalloc to a variable? I mean the start address of allocated memory 回答1: I don't think it's easily possible in a single command, so all options are kind of nasty: Store it manually Pro: easy to understand. Use copy/paste (right click to copy, right click to paste BTW) 0:000> .dvalloc 100000 Allocated 100000 bytes starting at 00000000`00290000 0:000> r $t9 = 00000000`00290000 0:000> ? $t9 Evaluate expression: 2686976 = 00000000`00290000 Use a WinDbg

Getting error when compiling kernel for page table walk

只愿长相守 提交于 2020-06-09 02:03:12
问题 I am doing a page table walk. When I am getting ready to update the kernel I get an error: kernel/sys.c: In function ‘__do_sys_get_page_info’: kernel/sys.c:2745:23: error: passing argument 1 of ‘pud_offset’ from incompatible pointer type [-Werror=incompatible-pointer-types] pud = pud_offset(pgd, vmpage); ^ In file included from ./include/linux/mm.h:99:0, from kernel/sys.c:19: ./arch/x86/include/asm/pgtable.h:905:22: note: expected ‘p4d_t * {aka struct <anonymous> *}’ but argument is of type

Why does ARM have 64KB Large Pages? [closed]

南笙酒味 提交于 2020-05-15 05:26:38
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . The ARM720T user manual mentions small and large pages. Since the ARM 720T requires a 64KB page table entry to be duplicated 16 times in the page table, why not place 16 small page (4KB) entries to mimic a 64KB page entry instead of using a large page in the first place? 回答1:

Why does Linux favor 0x7f mappings?

陌路散爱 提交于 2020-05-13 06:30:08
问题 By running a simple less /proc/self/maps I see that most mappings start with 55 and 7F . I also noticed these ranges to be used whenever I debug any binary. In addition this comment here suggests that the kernel has indeed some range preference. Why is that? Is there some deeper technical reason for the above ranges? Will there be a problem if I manually mmap pages outside of these prefixes? 回答1: First and foremost, assuming that you are talking about x86-64, we can see that the virtual

Memory region flags in Linux: why both VM_WRITE and VM_MAYWRITE are needed?

我只是一个虾纸丫 提交于 2020-02-25 06:22:06
问题 "Understanding the Linux Virtual Memory Manager" (2007) by Mel Gorman (here's a link to the book chapter) describes the flags of a memory region (vm_area_struct): VM_WRITE - Pages may be written VM_MAYWRITE - Allow the VM_WRITE flag to be set I don't understand why Linux needs these two flags, rather than just one of them. From the description above, it sounds like VM_MAYWRITE be set while VM_WRITE is not. In what situations? And how does the Linux kernel behave differently in these