linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Luke Dashjr <luke@dashjr.org>, Christoph Lameter <cl@linux.com>,
	Ming Lei <ming.lei@canonical.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>, Mel Gorman <mel@csn.ul.ie>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Pauli Nieminen <suokkos@gmail.com>,
	Dave Airlie <airlied@linux.ie>,
	bugzilla-daemon@bugzilla.kernel.org,
	luke-jr+linuxbugs@utopios.org, dri-devel@lists.freedesktop.org,
	linux-mm@kvack.org, Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: Re: [Bug 87891] New: kernel BUG at mm/slab.c:2625!
Date: Tue, 11 Nov 2014 20:38:59 -0800	[thread overview]
Message-ID: <20141111203859.3c578f5d.akpm@linux-foundation.org> (raw)
In-Reply-To: <201411120408.sAC48tTa029031@www262.sakura.ne.jp>

On Wed, 12 Nov 2014 13:08:55 +0900 Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:

> Andrew Morton wrote:
> > Poor ttm guys - this is a bit of a trap we set for them.
> 
> Commit a91576d7916f6cce (\"drm/ttm: Pass GFP flags in order to avoid deadlock.\")
> changed to use sc->gfp_mask rather than GFP_KERNEL.
> 
> -       pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
> -                       GFP_KERNEL);
> +       pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), gfp);
> 
> But this bug is caused by sc->gfp_mask containing some flags which are not
> in GFP_KERNEL, right? Then, I think
> 
> -       pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), gfp);
> +       pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), gfp & GFP_KERNEL);
> 
> would hide this bug.
> 
> But I think we should use GFP_ATOMIC (or drop __GFP_WAIT flag)

Well no - ttm_page_pool_free() should stop calling kmalloc altogether. 
Just do

	struct page *pages_to_free[16];

and rework the code to free 16 pages at a time.  Easy.

Apart from all the other things we're discussing here, it should do
this because kmalloc() isn't very reliable within a shrinker.


> for
> two reasons when __alloc_pages_nodemask() is called from shrinker functions.
> 
> (1) Stack usage by __alloc_pages_nodemask() is large. If we unlimitedly allow
>     recursive __alloc_pages_nodemask() calls, kernel stack could overflow
>     under extreme memory pressure.
> 
> (2) Some shrinker functions are using sleepable locks which could make kswapd
>     sleep for unpredictable duration. If kswapd is unexpectedly blocked inside
>     shrinker functions and somebody is expecting that kswapd is running for
>     reclaiming memory, it is a memory allocation deadlock.
> 
> Speak of ttm module, commit 22e71691fd54c637 (\"drm/ttm: Use mutex_trylock() to
> avoid deadlock inside shrinker functions.\") prevents unlimited recursive
> __alloc_pages_nodemask() calls.

Yes, there are such problems.

Shrinkers do all sorts of surprising things - some of the filesystem
ones do disk writes!  And these involve all sorts of locking and memory
allocations.  But they won't be directly using scan_control.gfp_mask. 
They may be using open-coded __GFP_NOFS for the allocations.  The
complicated ones pass the IO over to kernel threads and wait for them
to complete, which addresses the stack consumption concerns (at least).


--
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:[~2014-11-12  4:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-87891-27@https.bugzilla.kernel.org/>
2014-11-11 23:31 ` [Bug 87891] New: kernel BUG at mm/slab.c:2625! Andrew Morton
2014-11-12  0:36   ` Christoph Lameter
2014-11-12  0:49     ` Andrew Morton
2014-11-12  0:54       ` Luke Dashjr
2014-11-12  1:02         ` Andrew Morton
2014-11-12  1:22           ` Joonsoo Kim
2014-11-12  1:44             ` Andrew Morton
2014-11-12  2:13               ` Joonsoo Kim
2014-11-12  4:08               ` Tetsuo Handa
2014-11-12  4:38                 ` Andrew Morton [this message]
2014-11-13 13:43                   ` [PATCH] drm/ttm: Avoid memory allocation from shrinker functions Tetsuo Handa
2014-11-12  1:22       ` [Bug 87891] New: kernel BUG at mm/slab.c:2625! Kirill A. Shutemov
2014-11-12  1:47         ` Kirill A. Shutemov
2014-11-12  1:56           ` Andrew Morton
2014-11-12  2:07             ` Kirill A. Shutemov
2014-11-12  2:17         ` Joonsoo Kim
2014-11-12  2:37           ` Kirill A. Shutemov
2014-11-12  8:21             ` Joonsoo Kim
2014-11-12 10:39           ` Mel Gorman
2014-11-13  6:37             ` Joonsoo Kim
2014-11-12  0:44   ` Joonsoo Kim
2014-11-12  0:53     ` Andrew Morton
2014-11-12  1:04       ` Christoph Lameter
2014-11-13  7:04   ` Vlastimil Babka

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=20141111203859.3c578f5d.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=airlied@linux.ie \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=cl@linux.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hannes@cmpxchg.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-mm@kvack.org \
    --cc=luke-jr+linuxbugs@utopios.org \
    --cc=luke@dashjr.org \
    --cc=mel@csn.ul.ie \
    --cc=ming.lei@canonical.com \
    --cc=penberg@kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=rientjes@google.com \
    --cc=suokkos@gmail.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).