From: Thomas Hellstrom <thellstrom@vmware.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: "dri-devel@lists.freedesktop.org" <dri-devel@lists.freedesktop.org>
Subject: Fwd: Re: [PATCH] gpu/drm/ttm: Use mutex_lock_killable() for shrinker functions.
Date: Tue, 20 May 2014 09:38:07 +0100 [thread overview]
Message-ID: <537B146F.6040102@vmware.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1405200140010.20503@skynet.skynet.ie>
Konrad,
This looks OK to me, but do you have a chance to take a look?
/Thomas
-------- Original Message --------
Return-Path: <dri-devel-bounces@lists.freedesktop.org>
X-Original-To: thomas@shipmail.org
Delivered-To: thomas@shipmail.org
Received: from mail.shipmail.org (lin0.kontor.shipmail.org [127.0.0.1])
by mail.shipmail.org (Postfix) with ESMTP id 7EB6A33807A for
<thomas@shipmail.org>; Tue, 20 May 2014 02:40:25 +0200 (CEST)
Received: from lin0.kontor.shipmail.org [127.0.0.1] by BitDefender SMTP
Proxy on lin0.kontor.shipmail.org [127.0.0.1] for
lin0.kontor.shipmail.org [127.0.0.1]; Tue, 20 May 2014 02:40:25 +0200
(CEST)
Received: from gabe.freedesktop.org (gabe.freedesktop.org
[131.252.210.177]) by mail.shipmail.org (Postfix) with ESMTP id
1D7B0338079 for <thomas@shipmail.org>; Tue, 20 May 2014 02:40:25 +0200
(CEST)
Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by
gabe.freedesktop.org (Postfix) with ESMTP id B14C16E104; Mon, 19 May
2014 17:40:25 -0700 (PDT)
X-Original-To: dri-devel@lists.freedesktop.org
Delivered-To: dri-devel@lists.freedesktop.org
Received: from gir.skynet.ie (gir.skynet.ie [193.1.99.77]) by
gabe.freedesktop.org (Postfix) with ESMTP id E6E276E104 for
<dri-devel@lists.freedesktop.org>; Mon, 19 May 2014 17:40:23 -0700 (PDT)
Received: from skynet.skynet.ie (skynet.skynet.ie [193.1.99.74]) (using
TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client
certificate requested) by gir.skynet.ie (Postfix) with ESMTPS id
C819612529; Tue, 20 May 2014 01:40:21 +0100 (IST)
Date: Tue, 20 May 2014 01:40:21 +0100 (IST)
From: Dave Airlie <airlied@linux.ie>
X-X-Sender: airlied@skynet.skynet.ie
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Subject: Re: [PATCH] gpu/drm/ttm: Use mutex_lock_killable() for
shrinker functions.
In-Reply-To: <201405192339.JIJ04144.FHQFVFOtOSLJOM@I-love.SAKURA.ne.jp>
Message-ID: <alpine.DEB.2.00.1405200140010.20503@skynet.skynet.ie>
References: <201405192339.JIJ04144.FHQFVFOtOSLJOM@I-love.SAKURA.ne.jp>
User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
MIME-Version: 1.0
Cc: linux-kernel@vger.kernel.org, glommer@openvz.org, mgorman@suse.de,
DRI mailing list <dri-devel@lists.freedesktop.org>, dchinner@redhat.com
X-BeenThere: dri-devel@lists.freedesktop.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Direct Rendering Infrastructure - Development
<dri-devel.lists.freedesktop.org>
List-Unsubscribe:
<http://lists.freedesktop.org/mailman/options/dri-devel>,
<mailto:dri-devel-request@lists.freedesktop.org?subject=unsubscribe>
List-Archive: <http://lists.freedesktop.org/archives/dri-devel>
List-Post: <mailto:dri-devel@lists.freedesktop.org>
List-Help: <mailto:dri-devel-request@lists.freedesktop.org?subject=help>
List-Subscribe:
<http://lists.freedesktop.org/mailman/listinfo/dri-devel>,
<mailto:dri-devel-request@lists.freedesktop.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: dri-devel-bounces@lists.freedesktop.org
Sender: "dri-devel" <dri-devel-bounces@lists.freedesktop.org>
X-BitDefender-Scanner: Mail not scanned due to license constraints
cc'ing dri-devel.
> >From e314a1a1583e585d062dfc30c8aad8bf5380510b Mon Sep 17 00:00:00 2001
> From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Date: Mon, 19 May 2014 18:43:21 +0900
> Subject: [PATCH] gpu/drm/ttm: Use mutex_lock_killable() for shrinker functions.
>
> I can observe that RHEL7 environment stalls with 100% CPU usage when a
> certain type of memory pressure is given. While the shrinker functions
> are called by shrink_slab() before the OOM killer is triggered, the stall
> lasts for many minutes.
>
> I added debug printk() and observed that many threads are blocked for more
> than 10 seconds at ttm_dma_pool_shrink_count()/ttm_dma_pool_shrink_scan()
> functions. Since the kswapd can call these functions later, the current
> thread can return from these functions as soon as chosen by the OOM killer.
>
> This patch changes "mutex_lock();" to "if (mutex_lock_killable()) return ...;"
> so that any threads can promptly give up. (By the way, as far as I tested,
> changing to "if (!mutex_trylock()) return ...;" likely shortens the duration
> of stall. Maybe we don't need to wait for mutex if someone is already calling
> these functions.)
>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
> drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> index 1b79bf0..f75dab8 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> @@ -1012,7 +1012,8 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
> if (list_empty(&_manager->pools))
> return SHRINK_STOP;
>
> - mutex_lock(&_manager->lock);
> + if (mutex_lock_killable(&_manager->lock))
> + return SHRINK_STOP;
> pool_offset = pool_offset % _manager->npools;
> list_for_each_entry(p, &_manager->pools, pools) {
> unsigned nr_free;
> @@ -1043,7 +1044,8 @@ ttm_dma_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
> struct device_pools *p;
> unsigned long count = 0;
>
> - mutex_lock(&_manager->lock);
> + if (mutex_lock_killable(&_manager->lock))
> + return 0;
> list_for_each_entry(p, &_manager->pools, pools)
> count += p->pool->npages_free;
> mutex_unlock(&_manager->lock);
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-05-20 8:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <201405192339.JIJ04144.FHQFVFOtOSLJOM@I-love.SAKURA.ne.jp>
2014-05-20 0:40 ` [PATCH] gpu/drm/ttm: Use mutex_lock_killable() for shrinker functions Dave Airlie
2014-05-20 8:38 ` Thomas Hellstrom [this message]
2014-05-20 15:30 ` Tetsuo Handa
2014-05-24 14:22 ` Tetsuo Handa
2014-05-28 18:54 ` Konrad Rzeszutek Wilk
2014-05-28 21:47 ` Tetsuo Handa
2014-05-29 14:34 ` Tetsuo Handa
2014-05-30 16:08 ` Konrad Rzeszutek Wilk
2014-05-31 2:58 ` [PATCH 1/5] gpu/drm/ttm: Fix possible division by 0 in ttm_dma_pool_shrink_scan() Tetsuo Handa
2014-05-31 2:59 ` [PATCH 2/5] gpu/drm/ttm: Choose a pool to shrink correctly " Tetsuo Handa
2014-05-31 3:00 ` [PATCH 3/5] gpu/drm/ttm: Use mutex_trylock() to avoid deadlock inside shrinker functions Tetsuo Handa
2014-05-31 3:01 ` [PATCH 4/5] gpu/drm/ttm: Fix possible stack overflow by recursive shrinker calls Tetsuo Handa
2014-05-31 3:02 ` [PATCH 5/5] gpu/drm/ttm: Pass GFP flags in order to avoid deadlock Tetsuo Handa
2014-06-10 19:17 ` [PATCH 3/5] gpu/drm/ttm: Use mutex_trylock() to avoid deadlock inside shrinker functions Konrad Rzeszutek Wilk
2014-06-10 20:16 ` Tetsuo Handa
2014-08-03 11:14 ` [PATCH 1/5] gpu/drm/ttm: Fix possible division by 0 in ttm_dma_pool_shrink_scan() Tetsuo Handa
2014-08-03 11:14 ` [PATCH 2/5] gpu/drm/ttm: Choose a pool to shrink correctly " Tetsuo Handa
2014-08-03 11:15 ` [PATCH 3/5] gpu/drm/ttm: Use mutex_trylock() to avoid deadlock inside shrinker functions Tetsuo Handa
2014-08-03 11:16 ` [PATCH 4/5] gpu/drm/ttm: Fix possible stack overflow by recursive shrinker calls Tetsuo Handa
2014-08-03 11:16 ` [PATCH 5/5] gpu/drm/ttm: Pass GFP flags in order to avoid deadlock Tetsuo Handa
2014-05-30 16:06 ` [PATCH] gpu/drm/ttm: Use mutex_lock_killable() for shrinker functions Konrad Rzeszutek Wilk
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=537B146F.6040102@vmware.com \
--to=thellstrom@vmware.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=konrad.wilk@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