在 2022/11/21 23:28, Jason Gunthorpe 写道:
On Sat, Nov 19, 2022 at 08:29:38PM -0500, Zhu Yanjun wrote:
From: Zhu Yanjun <yanjun.zhu@xxxxxxxxx>
In ib_umem_get, sgt_append is allocated from the function
sg_alloc_append_table_from_pages. And it is not from highmem.
You've confused the allocation of the SGL table itself with the
page_address called on the struct page * stored inside the SGL table.
Think of the SGL as an array of 'struct page *'
About "The page_address() can return NULL because the 'struct page *' it
contains came from userspace and could very will be highmem.",
From the function ib_umem *ib_umem_get(struct ib_device *device,
unsigned long addr,size_t size, int access), I agree with you that
struct page comes from user space.
But from "Understanding the Linux Kernel", third edition - sections
"8.1.3. Memory Zones" and "8.1.6. Kernel Mappings of High-Memory Page
Frames".
In the process' virtual address space, the user space occupies the first
3GB, and the kernel space the 4th GB of this linear address space.
The first 896MB of the kernel space (not only kernel code, but its data
also) is "directly" mapped to the first 896 MB of the physical memory.
The last 128MB part of the virtual kernel space is where are mapped some
pieces of the physical "high memory" (> 896MB) : thus it can only map no
more than 128MB of "high memory" at a time.
It seems that page_address of these "128MB high memory" will return NULL.
But can user space access these high memory? From "Understanding the
Linux Kernel", third edition, it seems that it is in kernel space.
Thanks and Regards,
Zhu Yanjun
Jason