Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1716885 > unrolled thread
| Started by | David Rientjes <rientjes@google.com> |
|---|---|
| First post | 2017-08-21 23:10 +0200 |
| Last post | 2017-08-21 23:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[patch] fs, proc: unconditional cond_resched when reading smaps David Rientjes <rientjes@google.com> - 2017-08-21 23:10 +0200
Re: [patch] fs, proc: unconditional cond_resched when reading smaps "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-08-21 23:50 +0200
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2017-08-21 23:10 +0200 |
| Subject | [patch] fs, proc: unconditional cond_resched when reading smaps |
| Message-ID | <uh27o-12T-31@gated-at.bofh.it> |
If there are large numbers of hugepages to iterate while reading
/proc/pid/smaps, the page walk never does cond_resched(). On archs
without split pmd locks, there can be significant and observable
contention on mm->page_table_lock which cause lengthy delays without
rescheduling.
Always reschedule in smaps_pte_range() if necessary since the pagewalk
iteration can be expensive.
Signed-off-by: David Rientjes <rientjes@google.com>
---
fs/proc/task_mmu.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -599,11 +599,11 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
if (ptl) {
smaps_pmd_entry(pmd, addr, walk);
spin_unlock(ptl);
- return 0;
+ goto out;
}
if (pmd_trans_unstable(pmd))
- return 0;
+ goto out;
/*
* The mmap_sem held all the way back in m_start() is what
* keeps khugepaged out of here and from collapsing things
@@ -613,6 +613,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
for (; addr != end; pte++, addr += PAGE_SIZE)
smaps_pte_entry(pte, addr, walk);
pte_unmap_unlock(pte - 1, ptl);
+out:
cond_resched();
return 0;
}
[toc] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill@shutemov.name> |
|---|---|
| Date | 2017-08-21 23:50 +0200 |
| Message-ID | <uh2K6-1hN-23@gated-at.bofh.it> |
| In reply to | #1716885 |
On Mon, Aug 21, 2017 at 02:06:45PM -0700, David Rientjes wrote:
> If there are large numbers of hugepages to iterate while reading
> /proc/pid/smaps, the page walk never does cond_resched(). On archs
> without split pmd locks, there can be significant and observable
> contention on mm->page_table_lock which cause lengthy delays without
> rescheduling.
>
> Always reschedule in smaps_pte_range() if necessary since the pagewalk
> iteration can be expensive.
>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
> fs/proc/task_mmu.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -599,11 +599,11 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
> if (ptl) {
> smaps_pmd_entry(pmd, addr, walk);
> spin_unlock(ptl);
> - return 0;
> + goto out;
> }
>
> if (pmd_trans_unstable(pmd))
> - return 0;
> + goto out;
> /*
> * The mmap_sem held all the way back in m_start() is what
> * keeps khugepaged out of here and from collapsing things
> @@ -613,6 +613,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
> for (; addr != end; pte++, addr += PAGE_SIZE)
> smaps_pte_entry(pte, addr, walk);
> pte_unmap_unlock(pte - 1, ptl);
> +out:
> cond_resched();
> return 0;
> }
Maybe just call cond_resched() at the beginning of the function and don't
bother with gotos?
--
Kirill A. Shutemov
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web