All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-mm@kvack.org, Ondrej Kozina <okozina@redhat.com>,
	David Rientjes <rientjes@google.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Mel Gorman <mgorman@suse.de>, Neil Brown <neilb@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	dm-devel@redhat.com
Subject: Re: [RFC PATCH 1/2] mempool: do not consume memory reserves from the reclaim path
Date: Wed, 20 Jul 2016 08:44:29 +0200	[thread overview]
Message-ID: <20160720064429.GB11249@dhcp22.suse.cz> (raw)
In-Reply-To: <alpine.LRH.2.02.1607191749330.1437@file01.intranet.prod.int.rdu2.redhat.com>

On Tue 19-07-16 17:50:29, Mikulas Patocka wrote:
> 
> 
> On Mon, 18 Jul 2016, Michal Hocko wrote:
> 
> > From: Michal Hocko <mhocko@suse.com>
> > 
> > There has been a report about OOM killer invoked when swapping out to
> > a dm-crypt device. The primary reason seems to be that the swapout
> > out IO managed to completely deplete memory reserves. Mikulas was
> > able to bisect and explained the issue by pointing to f9054c70d28b
> > ("mm, mempool: only set __GFP_NOMEMALLOC if there are free elements").
> > 
> > The reason is that the swapout path is not throttled properly because
> > the md-raid layer needs to allocate from the generic_make_request path
> > which means it allocates from the PF_MEMALLOC context. dm layer uses
> > mempool_alloc in order to guarantee a forward progress which used to
> > inhibit access to memory reserves when using page allocator. This has
> > changed by f9054c70d28b ("mm, mempool: only set __GFP_NOMEMALLOC if
> > there are free elements") which has dropped the __GFP_NOMEMALLOC
> > protection when the memory pool is depleted.
> > 
> > If we are running out of memory and the only way forward to free memory
> > is to perform swapout we just keep consuming memory reserves rather than
> > throttling the mempool allocations and allowing the pending IO to
> > complete up to a moment when the memory is depleted completely and there
> > is no way forward but invoking the OOM killer. This is less than
> > optimal.
> > 
> > The original intention of f9054c70d28b was to help with the OOM
> > situations where the oom victim depends on mempool allocation to make a
> > forward progress. We can handle that case in a different way, though. We
> > can check whether the current task has access to memory reserves ad an
> > OOM victim (TIF_MEMDIE) and drop __GFP_NOMEMALLOC protection if the pool
> > is empty.
> > 
> > David Rientjes was objecting that such an approach wouldn't help if the
> > oom victim was blocked on a lock held by process doing mempool_alloc. This
> > is very similar to other oom deadlock situations and we have oom_reaper
> > to deal with them so it is reasonable to rely on the same mechanism
> > rather inventing a different one which has negative side effects.
> > 
> > Fixes: f9054c70d28b ("mm, mempool: only set __GFP_NOMEMALLOC if there are free elements")
> > Bisected-by: Mikulas Patocka <mpatocka@redhat.com>
> 
> Bisect was done by Ondrej Kozina.

OK, fixed

> > Signed-off-by: Michal Hocko <mhocko@suse.com>
> 
> Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
> Tested-by: Mikulas Patocka <mpatocka@redhat.com>

Let's see whether we decide to go with this patch or a plain revert. In
any case I will mark the patch for stable so it will end up in both 4.6
and 4.7

Anyway thanks for your and Ondrejs help here!
-- 
Michal Hocko
SUSE Labs

WARNING: multiple messages have this Message-ID (diff)
From: Michal Hocko <mhocko@kernel.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-mm@kvack.org, Ondrej Kozina <okozina@redhat.com>,
	David Rientjes <rientjes@google.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Mel Gorman <mgorman@suse.de>, Neil Brown <neilb@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	dm-devel@redhat.com
Subject: Re: [RFC PATCH 1/2] mempool: do not consume memory reserves from the reclaim path
Date: Wed, 20 Jul 2016 08:44:29 +0200	[thread overview]
Message-ID: <20160720064429.GB11249@dhcp22.suse.cz> (raw)
In-Reply-To: <alpine.LRH.2.02.1607191749330.1437@file01.intranet.prod.int.rdu2.redhat.com>

On Tue 19-07-16 17:50:29, Mikulas Patocka wrote:
> 
> 
> On Mon, 18 Jul 2016, Michal Hocko wrote:
> 
> > From: Michal Hocko <mhocko@suse.com>
> > 
> > There has been a report about OOM killer invoked when swapping out to
> > a dm-crypt device. The primary reason seems to be that the swapout
> > out IO managed to completely deplete memory reserves. Mikulas was
> > able to bisect and explained the issue by pointing to f9054c70d28b
> > ("mm, mempool: only set __GFP_NOMEMALLOC if there are free elements").
> > 
> > The reason is that the swapout path is not throttled properly because
> > the md-raid layer needs to allocate from the generic_make_request path
> > which means it allocates from the PF_MEMALLOC context. dm layer uses
> > mempool_alloc in order to guarantee a forward progress which used to
> > inhibit access to memory reserves when using page allocator. This has
> > changed by f9054c70d28b ("mm, mempool: only set __GFP_NOMEMALLOC if
> > there are free elements") which has dropped the __GFP_NOMEMALLOC
> > protection when the memory pool is depleted.
> > 
> > If we are running out of memory and the only way forward to free memory
> > is to perform swapout we just keep consuming memory reserves rather than
> > throttling the mempool allocations and allowing the pending IO to
> > complete up to a moment when the memory is depleted completely and there
> > is no way forward but invoking the OOM killer. This is less than
> > optimal.
> > 
> > The original intention of f9054c70d28b was to help with the OOM
> > situations where the oom victim depends on mempool allocation to make a
> > forward progress. We can handle that case in a different way, though. We
> > can check whether the current task has access to memory reserves ad an
> > OOM victim (TIF_MEMDIE) and drop __GFP_NOMEMALLOC protection if the pool
> > is empty.
> > 
> > David Rientjes was objecting that such an approach wouldn't help if the
> > oom victim was blocked on a lock held by process doing mempool_alloc. This
> > is very similar to other oom deadlock situations and we have oom_reaper
> > to deal with them so it is reasonable to rely on the same mechanism
> > rather inventing a different one which has negative side effects.
> > 
> > Fixes: f9054c70d28b ("mm, mempool: only set __GFP_NOMEMALLOC if there are free elements")
> > Bisected-by: Mikulas Patocka <mpatocka@redhat.com>
> 
> Bisect was done by Ondrej Kozina.

OK, fixed

> > Signed-off-by: Michal Hocko <mhocko@suse.com>
> 
> Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
> Tested-by: Mikulas Patocka <mpatocka@redhat.com>

Let's see whether we decide to go with this patch or a plain revert. In
any case I will mark the patch for stable so it will end up in both 4.6
and 4.7

Anyway thanks for your and Ondrejs help here!
-- 
Michal Hocko
SUSE Labs

--
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:[~2016-07-20  6:44 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18  8:39 [RFC PATCH 0/2] mempool vs. page allocator interaction Michal Hocko
2016-07-18  8:39 ` Michal Hocko
2016-07-18  8:41 ` [RFC PATCH 1/2] mempool: do not consume memory reserves from the reclaim path Michal Hocko
2016-07-18  8:41   ` Michal Hocko
2016-07-18  8:41   ` [RFC PATCH 2/2] mm, mempool: do not throttle PF_LESS_THROTTLE tasks Michal Hocko
2016-07-18  8:41     ` Michal Hocko
2016-07-19 21:50     ` Mikulas Patocka
2016-07-19 21:50       ` Mikulas Patocka
2016-07-22  8:46     ` NeilBrown
2016-07-22  9:04       ` NeilBrown
2016-07-22  9:15       ` Michal Hocko
2016-07-22  9:15         ` Michal Hocko
2016-07-23  0:12         ` NeilBrown
2016-07-25  8:32           ` Michal Hocko
2016-07-25  8:32             ` Michal Hocko
2016-07-25 19:23             ` Michal Hocko
2016-07-25 19:23               ` Michal Hocko
2016-07-25 19:23               ` Michal Hocko
2016-07-26  7:07               ` Michal Hocko
2016-07-26  7:07                 ` Michal Hocko
2016-07-27  3:43             ` [dm-devel] " NeilBrown
2016-07-27 18:24               ` Michal Hocko
2016-07-27 18:24                 ` Michal Hocko
2016-07-27 21:33                 ` NeilBrown
2016-07-28  7:17                   ` Michal Hocko
2016-07-28  7:17                     ` Michal Hocko
2016-08-03 12:53                     ` Mikulas Patocka
2016-08-03 12:53                       ` Mikulas Patocka
2016-08-03 14:34                       ` Michal Hocko
2016-08-03 14:34                         ` Michal Hocko
2016-08-04 18:49                         ` Mikulas Patocka
2016-08-04 18:49                           ` Mikulas Patocka
2016-08-12 12:32                           ` Michal Hocko
2016-08-12 12:32                             ` Michal Hocko
2016-08-13 17:34                             ` Mikulas Patocka
2016-08-13 17:34                               ` Mikulas Patocka
2016-08-14 10:34                               ` Michal Hocko
2016-08-14 10:34                                 ` Michal Hocko
2016-08-15 16:15                                 ` Mikulas Patocka
2016-08-15 16:15                                   ` Mikulas Patocka
2016-11-23 21:11                                 ` Mikulas Patocka
2016-11-23 21:11                                   ` Mikulas Patocka
2016-11-24 13:29                                   ` Michal Hocko
2016-11-24 13:29                                     ` Michal Hocko
2016-11-24 17:10                                     ` Mikulas Patocka
2016-11-24 17:10                                       ` Mikulas Patocka
2016-11-28 14:06                                       ` Michal Hocko
2016-11-28 14:06                                         ` Michal Hocko
2016-07-25 21:52           ` Mikulas Patocka
2016-07-25 21:52             ` Mikulas Patocka
2016-07-26  7:25             ` Michal Hocko
2016-07-26  7:25               ` Michal Hocko
2016-07-27  4:02             ` [dm-devel] " NeilBrown
2016-07-27 14:28               ` Mikulas Patocka
2016-07-27 14:28                 ` Mikulas Patocka
2016-07-27 18:40                 ` Michal Hocko
2016-07-27 18:40                   ` Michal Hocko
2016-08-03 13:59                   ` Mikulas Patocka
2016-08-03 13:59                     ` Mikulas Patocka
2016-08-03 14:42                     ` Michal Hocko
2016-08-03 14:42                       ` Michal Hocko
2016-08-04 18:46                       ` Mikulas Patocka
2016-08-04 18:46                         ` Mikulas Patocka
2016-07-27 21:36                 ` NeilBrown
2016-07-19  2:00   ` [RFC PATCH 1/2] mempool: do not consume memory reserves from the reclaim path David Rientjes
2016-07-19  2:00     ` David Rientjes
2016-07-19  7:49     ` Michal Hocko
2016-07-19  7:49       ` Michal Hocko
2016-07-19 13:54   ` Johannes Weiner
2016-07-19 13:54     ` Johannes Weiner
2016-07-19 14:19     ` Michal Hocko
2016-07-19 14:19       ` Michal Hocko
2016-07-19 22:01       ` Mikulas Patocka
2016-07-19 22:01         ` Mikulas Patocka
2016-07-19 20:45     ` David Rientjes
2016-07-19 20:45       ` David Rientjes
2016-07-20  8:15       ` Michal Hocko
2016-07-20  8:15         ` Michal Hocko
2016-07-20 21:06         ` David Rientjes
2016-07-20 21:06           ` David Rientjes
2016-07-21  8:52           ` Michal Hocko
2016-07-21  8:52             ` Michal Hocko
2016-07-21 12:13             ` Johannes Weiner
2016-07-21 12:13               ` Johannes Weiner
2016-07-21 14:53               ` Michal Hocko
2016-07-21 14:53                 ` Michal Hocko
2016-07-21 14:53                 ` Michal Hocko
2016-07-21 15:26                 ` Johannes Weiner
2016-07-21 15:26                   ` Johannes Weiner
2016-07-22  1:41                 ` NeilBrown
2016-07-22  6:37                 ` Michal Hocko
2016-07-22  6:37                   ` Michal Hocko
2016-07-22 12:26                   ` Vlastimil Babka
2016-07-22 12:26                     ` Vlastimil Babka
2016-07-22 19:44                     ` Andrew Morton
2016-07-22 19:44                       ` Andrew Morton
2016-07-23 18:52                       ` Vlastimil Babka
2016-07-23 18:52                         ` Vlastimil Babka
2016-07-19 21:50   ` Mikulas Patocka
2016-07-19 21:50     ` Mikulas Patocka
2016-07-20  6:44     ` Michal Hocko [this message]
2016-07-20  6:44       ` Michal Hocko

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=20160720064429.GB11249@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mpatocka@redhat.com \
    --cc=neilb@suse.de \
    --cc=okozina@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.