From: Hillf Danton <hdanton@sina.com>
To: Song Liu <songliubraving@fb.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
matthew.wilcox@oracle.com, kirill.shutemov@linux.intel.com,
peterz@infradead.org, oleg@redhat.com, rostedt@goodmis.org,
kernel-team@fb.com, william.kucharski@oracle.com
Subject: Re: [PATCH v6 6/6] uprobe: collapse THP pmd after removing all uprobes
Date: Mon, 24 Jun 2019 21:58:10 +0800 [thread overview]
Message-ID: <20190623054829.4018117-7-songliubraving@fb.com> (raw)
Message-ID: <20190624135810.1WihIgcH-2N9m6E702XV30ZnDoe2hk7yi-jytf1-aRQ@z> (raw)
In-Reply-To: <20190623054829.4018117-1-songliubraving@fb.com>
Hello
On Sat, 22 Jun 2019 22:48:29 -0700 Song Liu wrote:
>After all uprobes are removed from the huge page (with PTE pgtable), it
>is possible to collapse the pmd and benefit from THP again. This patch
>does the collapse by setting AS_COLLAPSE_PMD. khugepage would retrace
>the page table.
>
>A check for vma->anon_vma is removed from retract_page_tables(). The
>check was initially marked as "probably overkill". The code works well
>without the check.
>
>An issue on earlier version was discovered by kbuild test robot.
>
>Reported-by: kbuild test robot <lkp@intel.com>
>Signed-off-by: Song Liu <songliubraving@fb.com>
>---
> kernel/events/uprobes.c | 6 +++++-
> mm/khugepaged.c | 3 ---
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
>diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
>index a20d7b43a056..418382259f61 100644
>--- a/kernel/events/uprobes.c
>+++ b/kernel/events/uprobes.c
>@@ -474,6 +474,7 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
> struct page *old_page, *new_page;
> struct vm_area_struct *vma;
> int ret, is_register, ref_ctr_updated = 0;
>+ struct page *orig_page = NULL;
>
> is_register = is_swbp_insn(&opcode);
> uprobe = container_of(auprobe, struct uprobe, arch);
>@@ -512,7 +513,6 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
> copy_to_page(new_page, vaddr, &opcode, UPROBE_SWBP_INSN_SIZE);
>
> if (!is_register) {
>- struct page *orig_page;
> pgoff_t index;
>
> index = vaddr_to_offset(vma, vaddr & PAGE_MASK) >> PAGE_SHIFT;
>@@ -540,6 +540,10 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
> if (ret && is_register && ref_ctr_updated)
> update_ref_ctr(uprobe, mm, -1);
>
>+ if (!ret && orig_page && PageTransCompound(orig_page))
>+ set_bit(AS_COLLAPSE_PMD,
>+ &compound_head(orig_page)->mapping->flags);
>+
orig_page may be invalid if it is not identical to new_page for instance.
> return ret;
> }
>
>diff --git a/mm/khugepaged.c b/mm/khugepaged.c
>index 9b980327fd9b..2e277a2d731f 100644
>--- a/mm/khugepaged.c
>+++ b/mm/khugepaged.c
>@@ -1302,9 +1302,6 @@ static void retract_page_tables(struct address_space *mapping, pgoff_t pgoff,
>
> i_mmap_lock_write(mapping);
> vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
>- /* probably overkill */
>- if (vma->anon_vma)
>- continue;
> addr = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
> if (addr & ~HPAGE_PMD_MASK)
> continue;
>--
>2.17.1
>
>
Hillf
next prev parent reply other threads:[~2019-06-24 13:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-23 5:48 [PATCH v6 0/6] THP aware uprobe Song Liu
2019-06-23 5:48 ` [PATCH v6 1/6] mm: move memcmp_pages() and pages_identical() Song Liu
2019-06-23 5:48 ` [PATCH v6 2/6] uprobe: use original page when all uprobes are removed Song Liu
2019-06-23 5:48 ` [PATCH v6 3/6] mm, thp: introduce FOLL_SPLIT_PMD Song Liu
2019-06-23 5:48 ` [PATCH v6 4/6] uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT Song Liu
2019-06-23 5:48 ` [PATCH v6 5/6] khugepaged: enable collapse pmd for pte-mapped THP Song Liu
2019-06-24 13:19 ` Kirill A. Shutemov
2019-06-24 14:25 ` Song Liu
2019-06-25 10:34 ` Kirill A. Shutemov
2019-06-25 12:33 ` Song Liu
2019-06-25 14:12 ` Kirill A. Shutemov
2019-06-25 15:10 ` Song Liu
2019-06-24 22:06 ` Song Liu
2019-06-23 5:48 ` Song Liu [this message]
2019-06-24 13:58 ` [PATCH v6 6/6] uprobe: collapse THP pmd after removing all uprobes Hillf Danton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190623054829.4018117-7-songliubraving@fb.com \
--to=hdanton@sina.com \
--cc=kernel-team@fb.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.wilcox@oracle.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=william.kucharski@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox