vmalloc()返回的地址是PAGE_SIZE的倍数吗?

Is the address returned by vmalloc() a multiple of PAGE_SIZE?

我想问一个关于 vmalloc() 的问题。

根据 kernel.org 的 documentation,它说:

Allocate enough pages to cover size from the page level allocator and map them into contiguous kernel virtual space.

这是否意味着 vmalloc() 返回的(起始)地址将是 PAGE_SIZE 的倍数?

以下是我的想法:

我试过调用vmalloc()并打印出十六进制地址。最后三位全为零,PAGE_SIZE 的值在我的系统上是 4096,这在某种程度上证明了我的假设。此外,在mmap()

void *mmap(void *addr, size_t length, int prot, int flags,
                  int fd, off_t offset);

联机帮助页还说,

If addr is NULL, then the kernel chooses the (page-aligned) address at which to create the mapping; this is the most portable method of creating a new mapping. If addr is not NULL, then the kernel takes it as a hint about where to place the mapping; on Linux, the kernel will pick a nearby page boundary (but always above or equal to the value specified by /proc/sys/vm/mmap_min_addr) and attempt to create the mapping there.

offset must be a multiple of the page size

A file is mapped in multiples of the page size.

以上似乎证明了我的假设,但我不太确定。如有任何想法,我们将不胜感激。

vmalloc分配页面,returns分配内存的起始地址。每个页面都必须页面对齐。因此起始地址是页面大小的倍数。