linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: David Rientjes <rientjes@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Minchan Kim <minchan@kernel.org>, Hugh Dickins <hughd@google.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [patch] fs, proc: unconditional cond_resched when reading smaps
Date: Tue, 22 Aug 2017 00:41:50 +0300	[thread overview]
Message-ID: <20170821214150.pgv3ulpicnacslak@node.shutemov.name> (raw)
In-Reply-To: <alpine.DEB.2.10.1708211405520.131071@chino.kir.corp.google.com>

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2017-08-21 21:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 21:06 [patch] fs, proc: unconditional cond_resched when reading smaps David Rientjes
2017-08-21 21:41 ` Kirill A. Shutemov [this message]

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=20170821214150.pgv3ulpicnacslak@node.shutemov.name \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=rientjes@google.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;
as well as URLs for NNTP newsgroup(s).