Skip to content

Commit 5a52c9d

Browse files
liu-song-6torvalds
authored andcommitted
uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT
Use the newly added FOLL_SPLIT_PMD in uprobe. This preserves the huge page when the uprobe is enabled. When the uprobe is disabled, newer instances of the same application could still benefit from huge page. For the next step, we will enable khugepaged to regroup the pmd, so that existing instances of the application could also benefit from huge page after the uprobe is disabled. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Reviewed-by: Srikar Dronamraju <[email protected]> Reviewed-by: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent bfe7b00 commit 5a52c9d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

kernel/events/uprobes.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
155155
{
156156
struct mm_struct *mm = vma->vm_mm;
157157
struct page_vma_mapped_walk pvmw = {
158-
.page = old_page,
158+
.page = compound_head(old_page),
159159
.vma = vma,
160160
.address = addr,
161161
};
@@ -166,8 +166,6 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
166166
mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, mm, addr,
167167
addr + PAGE_SIZE);
168168

169-
VM_BUG_ON_PAGE(PageTransHuge(old_page), old_page);
170-
171169
if (new_page) {
172170
err = mem_cgroup_try_charge(new_page, vma->vm_mm, GFP_KERNEL,
173171
&memcg, false);
@@ -481,7 +479,7 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
481479
retry:
482480
/* Read the page with vaddr into memory */
483481
ret = get_user_pages_remote(NULL, mm, vaddr, 1,
484-
FOLL_FORCE | FOLL_SPLIT, &old_page, &vma, NULL);
482+
FOLL_FORCE | FOLL_SPLIT_PMD, &old_page, &vma, NULL);
485483
if (ret <= 0)
486484
return ret;
487485

0 commit comments

Comments
 (0)