1,214
questions
0
votes
0
answers
20
views
Difference between 1 and 2 in /proc/sys/kernel/randomize_va_space (ASLR)
This source explains each value:
0
Disable ASLR. This setting is applied if the kernel is booted with
the norandmaps boot parameter.
1
Randomize the positions of the stack, virtual dynamic shared ...
-2
votes
1
answer
54
views
What exactly is the "Kernel Master Page Global Directory"?
I once heard my OS lecturer discuss a data structure in the kernel space called the "Kernel Master Page Global Directory" (KMPGD for short), which is used to manage kernel pages alongside ...
0
votes
1
answer
31
views
Is lazy binding of shared library achieved using lazy allocation of virtual memory by OS?
In Linux ( unsure for Windows, any knowledge regarding is appreciated too ), a technique named lazy binding is used for boosting performance when only a small portion of shared library is required, ...
0
votes
1
answer
39
views
Can Arm Trusted Firmware access physical memory directly?
I found the mmio access api in arm-tf/include/lib/mmio.h, it access the addr to perform I/O operations like many other privileged softwares (linux, optee-os, etc.):
static inline void mmio_write_32(...
0
votes
2
answers
80
views
Do processes share the read-only sections of common dynamically loaded libraries?
I would like to verify how the memory consumption works when I have two different executables that depend on the same dynamically loaded library and the library has both "state" (i.e., ...
0
votes
1
answer
104
views
Virtual memory size increases considerably with thread count
In the below C++ code example, each time the user presses the Enter key, a new thread will be created. The thread waits for 10 minutes and then exits. The thread has a std::string object with some ...
0
votes
0
answers
79
views
How to analyse cause of memory usage not shown by htop
How can I best debug the following issue from here on?
I have a
python application
running in a podman container which has
plenty disk I/O due to a numpy memmap of two huge files, one input file ...
0
votes
0
answers
15
views
Why malloc return a very higher address than user space and not in /proc/pid/maps?
I have a demo that run in Android 13 with linux Linux version 5.15.41.
#include <iostream>
#include <stdlib.h>
#include <unistd.h>
int print(const char *parr)
{
if (nullptr !...
0
votes
1
answer
84
views
Stack size in relation to virtual memory
In our Operating Systems class we mentioned virtual memory as a mechanism that abstracts physical memory to a process, and that it looks something like this (per process):
The stack grows down the ...
1
vote
0
answers
119
views
What is the typical cache size of MMU paging-structures?
Typical TLB sizes are well known for different page sizes (4KB, 2MiB, etc) however there is very little known about the page table cache sizes (E.g. Paging-Structure Caches from Sec 4.10.3 Vol 3A of ...
0
votes
1
answer
87
views
about "preprocessing" in PintOS compiling(C programming), There are 2-questions for referencing headers and incomplete type error
I'm student in practicing PintOS Project.
In Programming Project 3(Virtual Memory), I got ploblems about "preprocess in compiling" (C program).
I had tried all attempt that do my best, but I'...
1
vote
2
answers
84
views
Why are pre-allocated stacks expensive, given 64-bit virtual memory?
As https://without.boats/blog/why-async-rust/ puts it,
OS threads have a large pre-allocated stack, which increases per-thread memory overhead.
And the article goes on to argue that much of the ...
5
votes
1
answer
85
views
Using page-table remapping to avoid data-copying during array-reallocation
Say you have a std::vector-like container class, and that vector is already filled to 100% of its capacity with data items, and the calling code calls push_back() to add one more data item.
At the ...
0
votes
0
answers
36
views
Is there a better way in Linux to query a memory mapping than text parsing /proc/self/maps?
In Linux/Android, is there a way to get information about a virtual address in the current process--such as the base address of the mapping--without writing a complicated text parser to understand /...
0
votes
0
answers
34
views
Converting virtual address to real address - in hexadecimal
question for converting virtual address to real address
I looked through stack overflow for similar questions but I unfortunately did not know how to apply the same steps to this question, therefor I ...
0
votes
1
answer
71
views
Can AWS Sagemaker training instances swap virtual memory to disk?
I have a training algorithm that needs to load a huge dataset into memory and then translate it into another format. After this operation I can free the memory used to hold the first copy of the ...
2
votes
4
answers
290
views
Is it possible to write at virtual 0x0 on a classical OS?
I'm not sure if I'm asking the question right, but I'm wondering if it's possible for a C or ASM program to write at the virtual adress 0x0 ?
I know the kernel don't allow write/read at virtual 0x0, ...
1
vote
0
answers
55
views
How does a TLB manage memory translation for addresses that cross page boundaries?
Let's say we have a page size of 4096 Bytes, and we have two contiguous virtual memory pages mapped to discontinuous physical pages, i.e
[x , x + 4096 * 2] - Maps to -> [A, A + 4096], [B, B + 4096]
...
0
votes
0
answers
65
views
Using psutil.virtual_memory() to calculated the memory consumption of a module within a program
I have the following code:
initial_memory_usage = psutil.virtual_memory()[1]
prediction = model.predict(img)
final_memory_usage = psutil.virtual_memory()[1]
total_mem_usage = initial_memory_usage - ...
0
votes
1
answer
33
views
Who and how generate the virtual/logical addresses? Confusion if it's the compiler, the linker, the loader
I know that when I compile a program and then I inspect with objdump, I have addresses. These are relative addresses.
But if it's a C program and I printf with %p a pointer, that is a virtual/logical ...
-1
votes
1
answer
30
views
Number of segments that can be in main memory at certain instant
"Consider a memory management system based on segments, with 32 bits of virtual addressing space, with 3 bits (the most significant) for segment identification. Is it possible for the total ...
2
votes
1
answer
189
views
What is the difference Between 'Dirty Memory' and 'Dirty Size' in iOS VM Tracker?
In the WWDC 2022 session(https://developer.apple.com/videos/play/wwdc2022/10106/), they explained that memory allocation can be categorized into three types: Dirty, Compressed Dirty, and Clean. And ...
3
votes
1
answer
83
views
Allocate region of virtual address space upfront
I have several files that I want to map into a virtual address space consecutively with mmap(). Each file length is a multiple of the page size.
For the first file, I call mmap() with the addr ...
3
votes
2
answers
175
views
Assumptions about dwPageSize on different systems
Can we make any assumptions about SYSTEM_INFO dwPageSize on different systems, when targeting the same architecture (ie. x86_64)?
I generate some custom native code, that is loaded alongside a C++-...
0
votes
1
answer
257
views
How is the physical address of the page table calculated from page directory
I'm trying to understand paging and one thing that messes up my brain is how you can find the page table. Every resource says that the page directory contains a pointer to the page table, but how ...
0
votes
0
answers
78
views
Segfault on mprotect increasing memory
I am working on a computer with 8GB of memory with Ubuntu 20.04. I read a 4 GB file into memory, and now I want to create a virtual memory buffer using the memory that remains after the 4GB file. ...
1
vote
1
answer
124
views
How does memory splitting work with mmap() and virtual memory?
Forepart:
Assume we're on a 32bit Linux OS, with 4GB of physical memory.
There is no swap partition!
There's a kernel, reserving 200MB of non-pageable memory which cannot be taken by anyone else (...
2
votes
1
answer
186
views
Linux Kernel Virtual memory space, Address Handling and Virtual Memory Confusion
I am trying to implement the Meltdown vulnerability on a linux intel x86 laptop for a class demo. In the machine I am using I have nokaslr and pti=off in the kernel parameters.
I have created a kernel ...
0
votes
0
answers
35
views
Virtual memory increases when importing a module from multiple threads
I have a module "script" and while importing a class from it, consumes some memory ~450 MB (virt) and 100 MB (rss)
But with threads, the virtual memory usage is abnormally high - 13 GB.
My ...
-1
votes
1
answer
216
views
How does the OS know what virtual page a specific memory address references?
I am trying to understand how variables allocated in programs (such as with the new keyword in C++) translate to virtual pages.
My understanding is that each process will have its own virtual memory ...
1
vote
3
answers
207
views
Why malloc doesn't malloc?
Here's a C program to introduce the problem.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[]) {
if(argc != 2) {
printf("...
0
votes
1
answer
209
views
Page table in memory addressing vs page table in virtual memory
memory addressing = concept in which when os gives cpu a process to execute, it allocates a portion of ram for that process and cpu generates virtual addresses for that portion. the mapping between ...
0
votes
0
answers
49
views
How to get an accurate value of VSZ for a cgroup tree?
--- Summary ---
One can get some memory values from the cgroup interface. For example, in cgroup v2 memory.current interface we have a value in bytes of the current anon and pagecache memory used by ...
0
votes
0
answers
85
views
How to properly configure Paging to work in 64-bit mode?
I created 4 KiB pages:
section .bss
align 4096
page_map_level_4:
resb 4096
page_directory_pointer_table:
resb 4096
page_directory:
resb 4096
page_table:
resb 4096
I then wrote a ...
-1
votes
3
answers
2k
views
How to calculate the memory size of a page table for a single process?
In a given system with a 32-bit address space and 4KB page size, the main memory is 16MB. The page table is a single-level page table that is always allocated in the main memory. Each entry in the ...
4
votes
2
answers
146
views
Why do we need one jump after changing `PG` with `mov CR0, ...` when using non-completely serializing instruction?
In the Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 3A 9.3 SERIALIZING INSTRUCTIONS
When an instruction is executed that enables or disables paging (that is, changes the PG ...
0
votes
0
answers
59
views
where is the atomic count increase when swapping in page from the swap area in linux 2.4.18?
so I'm looking deeper into virtual memory subject, particularly into the functionality of swapping in and out pages.
The use case I want to examine is the following, assume we have 3 tasks, each has ...
0
votes
0
answers
50
views
Can I use a subset of the bits of a uint64_t to store a pointer to reliably access locations in an mmaped buffer in an x64 system?
I'm building a custom dynamic memory allocator that uses a mmaped buffer of size 8<<20 as the heap.
My mmaped buffer:
memory_buffer::memory_buffer() {
void* buf = mmap(nullptr, // maybe set a ...
1
vote
1
answer
118
views
Is there an equivalent to cuMemAddressReserve and cuMemMap in OpenCL?
I want to implement some functionality like what is described in Introducing Low-Level GPU Virtual Memory Management (Nvidia Developer blog) on OpenCL. Specifically, I want to be able to reserve a ...
0
votes
0
answers
152
views
What factors increases VmRSS of a process in linux
I come across a situation in my project in which VmRSS of my application increases in irregular intervals. In the background there are Heap memory allocations using malloc/calloc/realloc calls and ...
0
votes
0
answers
72
views
Can copy semantics cause a Linux system to crash due to huge syscall buffers?
Before I start, I'm informing you guys that this question is about a hypothetical situation and not one that I would think will happen regularly on modern desktops, and I cannot find a similar ...
1
vote
0
answers
144
views
How to check/detect for page faults in application level functions?
Suppose I am running a virtual machine or container, and I am allowed to run e.g. Java programs inside. Is there a way to detect page faults that occur when accessing the guest memory at the ...
0
votes
1
answer
27
views
virtual memory size while multiple processes are running
My question is about the virtual memory size while lots of processes are running
Are identical amounts of virtual memory provided to every process?
If not, can the virtual memory size be changed ...
1
vote
0
answers
636
views
Understanding the specifics of CUDA virtual memory
I am learning CUDA and I am trying to understand how virtual memory works and I was reading the relevant nvidia documentation.
In CPU land the CPU holds some virtual-physical page mappings in the TLB ...
0
votes
1
answer
54
views
Calculating total page table size of a process (with pid) in 4-level x64-64 linux machine using/proc/pid/maps and /proc/pid/pagemap
I need to programmatically calculate the total page table size of a given process in Linux using the /proc/pid/maps and /proc/pid/pagemap interfaces in C.
I now how to get a page entry and calculate ...
0
votes
1
answer
48
views
Physical pages offset check
The page table is used to translate from virtual to physical pages.
Assuming 4KB pages (PAGE_SHIFT=12), the address 0xA100 is composed of:
Virtual address: 0xA100
Virtual page number: 0xA
Offset: ...
0
votes
1
answer
131
views
While excuting the next instruction of writing satp, it showed in gdb: Cannot access memory at address
I'm trying to implement virtual memory of a kernel under RISC-V (RV64 Sv39) with QEMU and OpenSBI, but fail to enable MMU.
map_pages(&base_pgdir, 0, KERNBASE, KERNBASE, 0x0000000002000000, ...
-1
votes
1
answer
197
views
Can virtual memory size be larger than disk?
I have learned that virtual memory size cannot be larger than disk size since otherwise there might be a page that does not reside in the disk, needless to say, memory (*)
But, when we say the 64bit ...
0
votes
3
answers
99
views
Why do `sbrk`, `mmap` etc. return very long addresses?
When I mmap a block of memory, the returned pointer might be something like 2607194112 or 3614339072 (both actual values I've gotten).
Why are these values seemingly so random? It's all virtual anyway,...
1
vote
1
answer
390
views
Question about Context Switching in xv6 OS x86
I'm reading OSTEP for my Operating Systems course, and I have a question from Chp.6.3:
Note that there are two types of register saves/restores that happen
during this protocol. The first is when the ...