From: Michal Hocko <mhocko@kernel.org>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
Eric Wheeler <linux-mm@lists.ewheeler.net>
Subject: Re: [PATCH] mm/thp: Do not wait for lock_page() in deferred_split_scan()
Date: Thu, 15 Mar 2018 19:30:31 +0100 [thread overview]
Message-ID: <20180315183031.GS23100@dhcp22.suse.cz> (raw)
In-Reply-To: <20180315150747.31945-1-kirill.shutemov@linux.intel.com>
On Thu 15-03-18 18:07:47, Kirill A. Shutemov wrote:
> deferred_split_scan() gets called from reclaim path. Waiting for page
> lock may lead to deadlock there.
>
> Replace lock_page() with trylock_page() and skip the page if we failed
> to lock it. We will get to the page on the next scan.
>
Fixes: 9a982250f773 ("thp: introduce deferred_split_huge_page()")
and maybe even Cc: stable as this can lead to deadlocks AFAICS.
Btw. other THP shrinker does suffer from the same problem and a deadlock
has been reported[1]. Thanks for Tetsuo to point that out [2].
[1] http://lkml.kernel.org/r/alpine.LRH.2.11.1801242349220.30642@mail.ewheeler.net
[2] http://lkml.kernel.org/r/04bbbd39-a1c0-b84b-28a2-0a3876be1054@i-love.sakura.ne.jp
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Anyway feel free to add
Acked-by: Michal Hocko <mhocko@suse.com>
to this patch but a deeper audit is due I suspect
> ---
> mm/huge_memory.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 87ab9b8f56b5..529cf36b7edb 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2783,11 +2783,13 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
>
> list_for_each_safe(pos, next, &list) {
> page = list_entry((void *)pos, struct page, mapping);
> - lock_page(page);
> + if (!trylock_page(page))
> + goto next;
> /* split_huge_page() removes page from list on success */
> if (!split_huge_page(page))
> split++;
> unlock_page(page);
> +next:
> put_page(page);
> }
>
> --
> 2.16.1
--
Michal Hocko
SUSE Labs
prev parent reply other threads:[~2018-03-15 18:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 15:07 Kirill A. Shutemov
2018-03-15 18:30 ` Michal Hocko [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=20180315183031.GS23100@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-mm@lists.ewheeler.net \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
/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