Is a "memory page" always related only to a data chunk of virtual memory?
In some sense. The kernel has pages internally used for DMA, I/O buffering, block and inode cacheing, etc. These are all physical memory pages, but they're not visible as such to any user process unless they're mmapped.
Are physical RAM addresses also split into pages?
Yes - the two have to be equivalent for paging to work sanely
[paraphrase] is a page really the smallest unit if you can allocate a char
A page is the smallest unit the kernel VM system deals in. User processes request memory from the kernel in whole pages.
Your userspace process will then have an internal mechanism for managing objects allocated inside these pages.
Note that even if you think you allocated one
char, you didn't - the allocator will add some overhead to track the allocated block.
Note also that this discussion about sub-page allocators also applies inside the kernel (in the parts that are using, rather than managing, memory).
The reasons the kernel doesn't deal in smaller units are:
- they're inefficient for pagefile purposes (anything smaller than a disk block is going to be wasteful in practice), and
each allocation incurs some fixed management overhead - the smaller the block, the more memory you need to reserve for tracking lots of little objects.
Your 1-char allocation example likely has 4-8 bytes of management overhead; if you're allocating lots of these, perhaps only 1/9th of your memory is actually useful (equivalently, your memory use just increased by a factor of 9 for a given amount of data). The same 8-bytes for a 4Kb page represent a pretty low overhead.