summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorHuan Yang <link@vivo.com>2024-09-18 05:52:30 +0300
committerVivek Kasireddy <vivek.kasireddy@intel.com>2024-09-21 00:07:35 +0300
commitc87a1268e9c589cd346e820298e5ef35f884aea0 (patch)
tree76fa427d4ba5237f79716cf1d874d039e3f2d6fb /include/linux
parent6b68b74a081b259e4a4bcbcb03d0f2e3156fe3c6 (diff)
downloadlinux-c87a1268e9c589cd346e820298e5ef35f884aea0.tar.xz
udmabuf: reuse folio array when pin folios
When invoke memfd_pin_folios, we need offer an array to save each folio which we pinned. The current way is dynamic alloc an array(use kvmalloc), get folios, save into udmabuf and then free. Depend on the size, kvmalloc can do something different: Below PAGE_SIZE, slab allocator will be used, which have good alloc performance, due to it cached page. PAGE_SIZE - PCP Order, PCP(per-cpu-pageset) also given buddy page a cache in each CPU, so different CPU no need to hold some lock(zone or some) to get the locally page. If PCP cached page, the access also fast. PAGE_SIZE - BUDDY_MAX, try to get page from buddy, due to kvmalloc adjusted the gfp flags, if zone freelist can't alloc page(fast path), we will not enter slowpath to reclaim memory. Due to need hold lock and check, may slow, but still fast than vmalloc. Anything wrong will fallback into vmalloc to alloc memory, it obtains contiguous virtual addresses by loop alloc order 0 page(PAGE_SIZE), and then map it into vmalloc area. If necessary, page alloc may enter slowpath to reclaim memory. Hence, if fallback into vmalloc, it's slow. When create, we need to iter each udmabuf item, then pin it's range folios, if each item's range folio's count is large, we may fallback each into vmalloc. This patch find the largest range folio in items, then alloc this size's folio array. When pin range folios, reuse this array. Signed-off-by: Huan Yang <link@vivo.com> Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com> Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240918025238.2957823-8-link@vivo.com
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions