Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1270111 > unrolled thread
| Started by | mhocko@kernel.org |
|---|---|
| First post | 2015-11-16 14:30 +0100 |
| Last post | 2015-11-18 15:50 +0100 |
| Articles | 14 — 6 participants |
Back to article view | Back to linux.kernel
[PATCH 0/2] get rid of __alloc_pages_high_priority mhocko@kernel.org - 2015-11-16 14:30 +0100
[PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim mhocko@kernel.org - 2015-11-16 14:30 +0100
Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim David Rientjes <rientjes@google.com> - 2015-11-16 22:20 +0100
Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2015-11-17 12:00 +0100
Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim Michal Hocko <mhocko@kernel.org> - 2015-11-18 10:20 +0100
Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim Michal Hocko <mhocko@kernel.org> - 2015-11-18 10:30 +0100
Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim Vlastimil Babka <vbabka@suse.cz> - 2015-11-18 16:00 +0100
Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim Vlastimil Babka <vbabka@suse.cz> - 2015-11-18 16:20 +0100
Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim Michal Hocko <mhocko@kernel.org> - 2015-11-18 16:20 +0100
Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim Michal Hocko <mhocko@kernel.org> - 2015-11-23 10:40 +0100
[PATCH 1/2] mm: get rid of __alloc_pages_high_priority mhocko@kernel.org - 2015-11-16 14:30 +0100
Re: [PATCH 1/2] mm: get rid of __alloc_pages_high_priority Mel Gorman <mgorman@suse.de> - 2015-11-16 19:50 +0100
Re: [PATCH 1/2] mm: get rid of __alloc_pages_high_priority David Rientjes <rientjes@google.com> - 2015-11-16 22:20 +0100
Re: [PATCH 1/2] mm: get rid of __alloc_pages_high_priority Vlastimil Babka <vbabka@suse.cz> - 2015-11-18 15:50 +0100
| From | mhocko@kernel.org |
|---|---|
| Date | 2015-11-16 14:30 +0100 |
| Subject | [PATCH 0/2] get rid of __alloc_pages_high_priority |
| Message-ID | <qvs14-7Qv-5@gated-at.bofh.it> |
Hi, this has been posted http://lkml.kernel.org/r/1447343618-19696-1-git-send-email-mhocko%40kernel.org last week. David has requested to split the patch into two parts one to removed and opencode __alloc_pages_high_priority without any functional changes and the other one which changes the retry behavior for __GFP_NOFAIL with ALLOC_NO_WATERMARKS allocation context. This was reflected in this submission. The end result is very same so I've kept Mel's Acked-by. Let me know if you do not agree with this Mel and I will drop it. mm/page_alloc.c | 48 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | mhocko@kernel.org |
|---|---|
| Date | 2015-11-16 14:30 +0100 |
| Subject | [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qvs15-7Qv-39@gated-at.bofh.it> |
| In reply to | #1270111 |
From: Michal Hocko <mhocko@suse.com>
__alloc_pages_slowpath is looping over ALLOC_NO_WATERMARKS requests if
__GFP_NOFAIL is requested. This is fragile because we are basically
relying on somebody else to make the reclaim (be it the direct reclaim
or OOM killer) for us. The caller might be holding resources (e.g.
locks) which block other other reclaimers from making any progress for
example. Remove the retry loop and rely on __alloc_pages_slowpath to
invoke all allowed reclaim steps and retry logic.
We have to be careful about __GFP_NOFAIL allocations from the
PF_MEMALLOC context even though this is a very bad idea to begin with
because no progress can be gurateed at all. We shouldn't break the
__GFP_NOFAIL semantic here though. It could be argued that this is
essentially GFP_NOWAIT context which we do not support but PF_MEMALLOC
is much harder to check for existing users because they might happen
deep down the code path performed much later after setting the flag
so we cannot really rule out there is no kernel path triggering this
combination.
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
mm/page_alloc.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b153fa3d0b9b..df7746280427 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3046,32 +3046,36 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
* allocations are system rather than user orientated
*/
ac->zonelist = node_zonelist(numa_node_id(), gfp_mask);
- do {
- page = get_page_from_freelist(gfp_mask, order,
- ALLOC_NO_WATERMARKS, ac);
- if (page)
- goto got_pg;
-
- if (gfp_mask & __GFP_NOFAIL)
- wait_iff_congested(ac->preferred_zone,
- BLK_RW_ASYNC, HZ/50);
- } while (gfp_mask & __GFP_NOFAIL);
+ page = get_page_from_freelist(gfp_mask, order,
+ ALLOC_NO_WATERMARKS, ac);
+ if (page)
+ goto got_pg;
}
/* Caller is not willing to reclaim, we can't balance anything */
if (!can_direct_reclaim) {
/*
- * All existing users of the deprecated __GFP_NOFAIL are
- * blockable, so warn of any new users that actually allow this
- * type of allocation to fail.
+ * All existing users of the __GFP_NOFAIL are blockable, so warn
+ * of any new users that actually allow this type of allocation
+ * to fail.
*/
WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL);
goto nopage;
}
/* Avoid recursion of direct reclaim */
- if (current->flags & PF_MEMALLOC)
+ if (current->flags & PF_MEMALLOC) {
+ /*
+ * __GFP_NOFAIL request from this context is rather bizarre
+ * because we cannot reclaim anything and only can loop waiting
+ * for somebody to do a work for us.
+ */
+ if (WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL)) {
+ cond_resched();
+ goto retry;
+ }
goto nopage;
+ }
/* Avoid allocations with no watermarks from looping endlessly */
if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask & __GFP_NOFAIL))
--
2.6.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2015-11-16 22:20 +0100 |
| Subject | Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qvzlT-48E-11@gated-at.bofh.it> |
| In reply to | #1270118 |
On Mon, 16 Nov 2015, mhocko@kernel.org wrote: > From: Michal Hocko <mhocko@suse.com> > > __alloc_pages_slowpath is looping over ALLOC_NO_WATERMARKS requests if > __GFP_NOFAIL is requested. This is fragile because we are basically > relying on somebody else to make the reclaim (be it the direct reclaim > or OOM killer) for us. The caller might be holding resources (e.g. > locks) which block other other reclaimers from making any progress for > example. Remove the retry loop and rely on __alloc_pages_slowpath to > invoke all allowed reclaim steps and retry logic. > > We have to be careful about __GFP_NOFAIL allocations from the > PF_MEMALLOC context even though this is a very bad idea to begin with > because no progress can be gurateed at all. We shouldn't break the > __GFP_NOFAIL semantic here though. It could be argued that this is > essentially GFP_NOWAIT context which we do not support but PF_MEMALLOC > is much harder to check for existing users because they might happen > deep down the code path performed much later after setting the flag > so we cannot really rule out there is no kernel path triggering this > combination. > > Acked-by: Mel Gorman <mgorman@suse.de> > Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: David Rientjes <rientjes@google.com> It'll be scary if anything actually relies on this, but I think it's more correct. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> |
|---|---|
| Date | 2015-11-17 12:00 +0100 |
| Subject | Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qvM9s-3UK-17@gated-at.bofh.it> |
| In reply to | #1270118 |
Michal Hocko wrote:
> __alloc_pages_slowpath is looping over ALLOC_NO_WATERMARKS requests if
> __GFP_NOFAIL is requested. This is fragile because we are basically
> relying on somebody else to make the reclaim (be it the direct reclaim
> or OOM killer) for us. The caller might be holding resources (e.g.
> locks) which block other other reclaimers from making any progress for
> example. Remove the retry loop and rely on __alloc_pages_slowpath to
> invoke all allowed reclaim steps and retry logic.
This implies invoking OOM killer, doesn't it?
> /* Avoid recursion of direct reclaim */
> - if (current->flags & PF_MEMALLOC)
> + if (current->flags & PF_MEMALLOC) {
> + /*
> + * __GFP_NOFAIL request from this context is rather bizarre
> + * because we cannot reclaim anything and only can loop waiting
> + * for somebody to do a work for us.
> + */
> + if (WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL)) {
> + cond_resched();
> + goto retry;
I think that this "goto retry;" omits call to out_of_memory() which is allowed
for __GFP_NOFAIL allocations. Even if this is what you meant, current thread
can be a workqueue, which currently need a short sleep (as with
wait_iff_congested() changes), can't it?
> + }
> goto nopage;
> + }
>
> /* Avoid allocations with no watermarks from looping endlessly */
> if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask & __GFP_NOFAIL))
>
Well, is it cond_resched() which should include
if (current->flags & PF_WQ_WORKER)
schedule_timeout(1);
than wait_iff_congested() because not all yield calls use wait_iff_congested()
and giving pending workqueue jobs a chance to be processed is anyway preferable?
int __sched _cond_resched(void)
{
if (should_resched(0)) {
if ((current->flags & PF_WQ_WORKER) && workqueue_has_pending_jobs())
schedule_timeout(1);
else
preempt_schedule_common();
return 1;
}
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2015-11-18 10:20 +0100 |
| Subject | Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qw74e-WO-27@gated-at.bofh.it> |
| In reply to | #1271070 |
On Tue 17-11-15 19:58:09, Tetsuo Handa wrote:
> Michal Hocko wrote:
> > __alloc_pages_slowpath is looping over ALLOC_NO_WATERMARKS requests if
> > __GFP_NOFAIL is requested. This is fragile because we are basically
> > relying on somebody else to make the reclaim (be it the direct reclaim
> > or OOM killer) for us. The caller might be holding resources (e.g.
> > locks) which block other other reclaimers from making any progress for
> > example. Remove the retry loop and rely on __alloc_pages_slowpath to
> > invoke all allowed reclaim steps and retry logic.
>
> This implies invoking OOM killer, doesn't it?
It does and the changelog is explicit about this.
> > /* Avoid recursion of direct reclaim */
> > - if (current->flags & PF_MEMALLOC)
> > + if (current->flags & PF_MEMALLOC) {
> > + /*
> > + * __GFP_NOFAIL request from this context is rather bizarre
> > + * because we cannot reclaim anything and only can loop waiting
> > + * for somebody to do a work for us.
> > + */
> > + if (WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL)) {
> > + cond_resched();
> > + goto retry;
>
> I think that this "goto retry;" omits call to out_of_memory() which is allowed
> for __GFP_NOFAIL allocations.
It wasn't called for PF_MEMALLOC requests though. Whether invoking OOM
killer is a good idea for this case is a harder question and out of
scope of this patch.
> Even if this is what you meant, current thread
> can be a workqueue, which currently need a short sleep (as with
> wait_iff_congested() changes), can't it?
As the changelog tries to clarify PF_MEMALLOC with __GFP_NOFAIL is
basically a bug. That is the reason I am adding WARN_ON there. I do not
think making this code more complex for abusers/buggy code is really
worthwhile. Besides that I fail to see why a work item would ever
want to set PF_MEMALLOC for legitimate reasons. I have done a quick git
grep over the tree and there doesn't seem to be any user.
>
> > + }
> > goto nopage;
> > + }
> >
> > /* Avoid allocations with no watermarks from looping endlessly */
> > if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask & __GFP_NOFAIL))
> >
>
> Well, is it cond_resched() which should include
>
> if (current->flags & PF_WQ_WORKER)
> schedule_timeout(1);
I believe you are getting off-topic here.
--
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2015-11-18 10:30 +0100 |
| Subject | Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qw7dU-10j-31@gated-at.bofh.it> |
| In reply to | #1272016 |
On Wed 18-11-15 10:11:01, Michal Hocko wrote: > Besides that I fail to see why a work item would ever > want to set PF_MEMALLOC for legitimate reasons. I have done a quick git > grep over the tree and there doesn't seem to be any user. OK, I have missed one case. xfs_btree_split_worker is really setting PF_MEMALLOC from the worker context basically to inherit the flag from kswapd. This is a legitimate use but it doesn't affect the allocation path so it is not related to this discussion. -- Michal Hocko SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2015-11-18 16:00 +0100 |
| Subject | Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qwcnh-4gQ-33@gated-at.bofh.it> |
| In reply to | #1270118 |
On 11/16/2015 02:22 PM, mhocko@kernel.org wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> __alloc_pages_slowpath is looping over ALLOC_NO_WATERMARKS requests if
> __GFP_NOFAIL is requested. This is fragile because we are basically
> relying on somebody else to make the reclaim (be it the direct reclaim
> or OOM killer) for us. The caller might be holding resources (e.g.
> locks) which block other other reclaimers from making any progress for
> example. Remove the retry loop and rely on __alloc_pages_slowpath to
> invoke all allowed reclaim steps and retry logic.
>
> We have to be careful about __GFP_NOFAIL allocations from the
> PF_MEMALLOC context even though this is a very bad idea to begin with
> because no progress can be gurateed at all. We shouldn't break the
> __GFP_NOFAIL semantic here though. It could be argued that this is
> essentially GFP_NOWAIT context which we do not support but PF_MEMALLOC
> is much harder to check for existing users because they might happen
> deep down the code path performed much later after setting the flag
> so we cannot really rule out there is no kernel path triggering this
> combination.
>
> Acked-by: Mel Gorman <mgorman@suse.de>
> Signed-off-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/page_alloc.c | 32 ++++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index b153fa3d0b9b..df7746280427 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3046,32 +3046,36 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
> * allocations are system rather than user orientated
> */
> ac->zonelist = node_zonelist(numa_node_id(), gfp_mask);
> - do {
> - page = get_page_from_freelist(gfp_mask, order,
> - ALLOC_NO_WATERMARKS, ac);
> - if (page)
> - goto got_pg;
> -
> - if (gfp_mask & __GFP_NOFAIL)
> - wait_iff_congested(ac->preferred_zone,
> - BLK_RW_ASYNC, HZ/50);
I've been thinking if the lack of unconditional wait_iff_congested() can affect
something negatively. I guess not?
> - } while (gfp_mask & __GFP_NOFAIL);
> + page = get_page_from_freelist(gfp_mask, order,
> + ALLOC_NO_WATERMARKS, ac);
> + if (page)
> + goto got_pg;
> }
>
> /* Caller is not willing to reclaim, we can't balance anything */
> if (!can_direct_reclaim) {
> /*
> - * All existing users of the deprecated __GFP_NOFAIL are
> - * blockable, so warn of any new users that actually allow this
> - * type of allocation to fail.
> + * All existing users of the __GFP_NOFAIL are blockable, so warn
> + * of any new users that actually allow this type of allocation
> + * to fail.
> */
> WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL);
> goto nopage;
> }
>
> /* Avoid recursion of direct reclaim */
> - if (current->flags & PF_MEMALLOC)
> + if (current->flags & PF_MEMALLOC) {
> + /*
> + * __GFP_NOFAIL request from this context is rather bizarre
> + * because we cannot reclaim anything and only can loop waiting
> + * for somebody to do a work for us.
> + */
> + if (WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL)) {
> + cond_resched();
> + goto retry;
> + }
> goto nopage;
> + }
>
> /* Avoid allocations with no watermarks from looping endlessly */
> if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask & __GFP_NOFAIL))
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2015-11-18 16:20 +0100 |
| Subject | Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qwcGC-4D5-5@gated-at.bofh.it> |
| In reply to | #1272266 |
On 11/18/2015 04:11 PM, Michal Hocko wrote:
> On Wed 18-11-15 15:57:45, Vlastimil Babka wrote:
> [...]
>> > --- a/mm/page_alloc.c
>> > +++ b/mm/page_alloc.c
>> > @@ -3046,32 +3046,36 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
>> > * allocations are system rather than user orientated
>> > */
>> > ac->zonelist = node_zonelist(numa_node_id(), gfp_mask);
>> > - do {
>> > - page = get_page_from_freelist(gfp_mask, order,
>> > - ALLOC_NO_WATERMARKS, ac);
>> > - if (page)
>> > - goto got_pg;
>> > -
>> > - if (gfp_mask & __GFP_NOFAIL)
>> > - wait_iff_congested(ac->preferred_zone,
>> > - BLK_RW_ASYNC, HZ/50);
>>
>> I've been thinking if the lack of unconditional wait_iff_congested() can affect
>> something negatively. I guess not?
>
> Considering that the wait_iff_congested is removed only for PF_MEMALLOC
> with __GFP_NOFAIL which should be non-existent in the kernel then I
Hm that one won't reach it indeed, but also not loop, so that wasn't my concern.
I was referring to:
/* Keep reclaiming pages as long as there is reasonable progress */
pages_reclaimed += did_some_progress;
if ((did_some_progress && order <= PAGE_ALLOC_COSTLY_ORDER) ||
((gfp_mask & __GFP_REPEAT) && pages_reclaimed < (1 << order))) {
/* Wait for some write requests to complete then retry */
wait_iff_congested(ac->preferred_zone, BLK_RW_ASYNC, HZ/50);
goto retry;
}
Here we might skip the wait_iff_congested and go straight for oom. But it's true
that ordinary allocations that fail to make progress will also not wait, so I
guess it's fine.
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> think the risk is really low. Even if there was a caller _and_ there
> was a congestion then the behavior wouldn't be much more worse than
> what we have currently. The system is out of memory hoplessly if
> ALLOC_NO_WATERMARKS allocation fails.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2015-11-18 16:20 +0100 |
| Subject | Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qwcGC-4D5-7@gated-at.bofh.it> |
| In reply to | #1272266 |
On Wed 18-11-15 15:57:45, Vlastimil Babka wrote:
[...]
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -3046,32 +3046,36 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
> > * allocations are system rather than user orientated
> > */
> > ac->zonelist = node_zonelist(numa_node_id(), gfp_mask);
> > - do {
> > - page = get_page_from_freelist(gfp_mask, order,
> > - ALLOC_NO_WATERMARKS, ac);
> > - if (page)
> > - goto got_pg;
> > -
> > - if (gfp_mask & __GFP_NOFAIL)
> > - wait_iff_congested(ac->preferred_zone,
> > - BLK_RW_ASYNC, HZ/50);
>
> I've been thinking if the lack of unconditional wait_iff_congested() can affect
> something negatively. I guess not?
Considering that the wait_iff_congested is removed only for PF_MEMALLOC
with __GFP_NOFAIL which should be non-existent in the kernel then I
think the risk is really low. Even if there was a caller _and_ there
was a congestion then the behavior wouldn't be much more worse than
what we have currently. The system is out of memory hoplessly if
ALLOC_NO_WATERMARKS allocation fails.
--
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2015-11-23 10:40 +0100 |
| Subject | Re: [PATCH 2/2] mm: do not loop over ALLOC_NO_WATERMARKS without triggering reclaim |
| Message-ID | <qxVLl-8n9-45@gated-at.bofh.it> |
| In reply to | #1270118 |
It seems this patch hasn't reached the mmotm tree. Are there any
unresolved concerns left?
On Mon 16-11-15 14:22:19, mhocko@kernel.org wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> __alloc_pages_slowpath is looping over ALLOC_NO_WATERMARKS requests if
> __GFP_NOFAIL is requested. This is fragile because we are basically
> relying on somebody else to make the reclaim (be it the direct reclaim
> or OOM killer) for us. The caller might be holding resources (e.g.
> locks) which block other other reclaimers from making any progress for
> example. Remove the retry loop and rely on __alloc_pages_slowpath to
> invoke all allowed reclaim steps and retry logic.
>
> We have to be careful about __GFP_NOFAIL allocations from the
> PF_MEMALLOC context even though this is a very bad idea to begin with
> because no progress can be gurateed at all. We shouldn't break the
> __GFP_NOFAIL semantic here though. It could be argued that this is
> essentially GFP_NOWAIT context which we do not support but PF_MEMALLOC
> is much harder to check for existing users because they might happen
> deep down the code path performed much later after setting the flag
> so we cannot really rule out there is no kernel path triggering this
> combination.
>
> Acked-by: Mel Gorman <mgorman@suse.de>
> Signed-off-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/page_alloc.c | 32 ++++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index b153fa3d0b9b..df7746280427 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3046,32 +3046,36 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
> * allocations are system rather than user orientated
> */
> ac->zonelist = node_zonelist(numa_node_id(), gfp_mask);
> - do {
> - page = get_page_from_freelist(gfp_mask, order,
> - ALLOC_NO_WATERMARKS, ac);
> - if (page)
> - goto got_pg;
> -
> - if (gfp_mask & __GFP_NOFAIL)
> - wait_iff_congested(ac->preferred_zone,
> - BLK_RW_ASYNC, HZ/50);
> - } while (gfp_mask & __GFP_NOFAIL);
> + page = get_page_from_freelist(gfp_mask, order,
> + ALLOC_NO_WATERMARKS, ac);
> + if (page)
> + goto got_pg;
> }
>
> /* Caller is not willing to reclaim, we can't balance anything */
> if (!can_direct_reclaim) {
> /*
> - * All existing users of the deprecated __GFP_NOFAIL are
> - * blockable, so warn of any new users that actually allow this
> - * type of allocation to fail.
> + * All existing users of the __GFP_NOFAIL are blockable, so warn
> + * of any new users that actually allow this type of allocation
> + * to fail.
> */
> WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL);
> goto nopage;
> }
>
> /* Avoid recursion of direct reclaim */
> - if (current->flags & PF_MEMALLOC)
> + if (current->flags & PF_MEMALLOC) {
> + /*
> + * __GFP_NOFAIL request from this context is rather bizarre
> + * because we cannot reclaim anything and only can loop waiting
> + * for somebody to do a work for us.
> + */
> + if (WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL)) {
> + cond_resched();
> + goto retry;
> + }
> goto nopage;
> + }
>
> /* Avoid allocations with no watermarks from looping endlessly */
> if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask & __GFP_NOFAIL))
> --
> 2.6.2
>
--
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | mhocko@kernel.org |
|---|---|
| Date | 2015-11-16 14:30 +0100 |
| Subject | [PATCH 1/2] mm: get rid of __alloc_pages_high_priority |
| Message-ID | <qvs15-7Qv-53@gated-at.bofh.it> |
| In reply to | #1270111 |
From: Michal Hocko <mhocko@suse.com>
__alloc_pages_high_priority doesn't do anything special other than it
calls get_page_from_freelist and loops around GFP_NOFAIL allocation
until it succeeds. It would be better if the first part was done in
__alloc_pages_slowpath where we modify the zonelist because this would
be easier to read and understand. Opencoding the function into its only
caller allows to simplify it a bit as well.
This patch doesn't introduce any functional changes.
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
mm/page_alloc.c | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8034909faad2..b153fa3d0b9b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2902,28 +2902,6 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
return page;
}
-/*
- * This is called in the allocator slow-path if the allocation request is of
- * sufficient urgency to ignore watermarks and take other desperate measures
- */
-static inline struct page *
-__alloc_pages_high_priority(gfp_t gfp_mask, unsigned int order,
- const struct alloc_context *ac)
-{
- struct page *page;
-
- do {
- page = get_page_from_freelist(gfp_mask, order,
- ALLOC_NO_WATERMARKS, ac);
-
- if (!page && gfp_mask & __GFP_NOFAIL)
- wait_iff_congested(ac->preferred_zone, BLK_RW_ASYNC,
- HZ/50);
- } while (!page && (gfp_mask & __GFP_NOFAIL));
-
- return page;
-}
-
static void wake_all_kswapds(unsigned int order, const struct alloc_context *ac)
{
struct zoneref *z;
@@ -3068,12 +3046,16 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
* allocations are system rather than user orientated
*/
ac->zonelist = node_zonelist(numa_node_id(), gfp_mask);
+ do {
+ page = get_page_from_freelist(gfp_mask, order,
+ ALLOC_NO_WATERMARKS, ac);
+ if (page)
+ goto got_pg;
- page = __alloc_pages_high_priority(gfp_mask, order, ac);
-
- if (page) {
- goto got_pg;
- }
+ if (gfp_mask & __GFP_NOFAIL)
+ wait_iff_congested(ac->preferred_zone,
+ BLK_RW_ASYNC, HZ/50);
+ } while (gfp_mask & __GFP_NOFAIL);
}
/* Caller is not willing to reclaim, we can't balance anything */
--
2.6.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mel Gorman <mgorman@suse.de> |
|---|---|
| Date | 2015-11-16 19:50 +0100 |
| Subject | Re: [PATCH 1/2] mm: get rid of __alloc_pages_high_priority |
| Message-ID | <qvx0J-2t2-9@gated-at.bofh.it> |
| In reply to | #1270124 |
On Mon, Nov 16, 2015 at 02:22:18PM +0100, mhocko@kernel.org wrote: > From: Michal Hocko <mhocko@suse.com> > > __alloc_pages_high_priority doesn't do anything special other than it > calls get_page_from_freelist and loops around GFP_NOFAIL allocation > until it succeeds. It would be better if the first part was done in > __alloc_pages_slowpath where we modify the zonelist because this would > be easier to read and understand. Opencoding the function into its only > caller allows to simplify it a bit as well. > > This patch doesn't introduce any functional changes. > > Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Mel Gorman <mgorman@suse.de> -- Mel Gorman SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2015-11-16 22:20 +0100 |
| Subject | Re: [PATCH 1/2] mm: get rid of __alloc_pages_high_priority |
| Message-ID | <qvzlT-48E-3@gated-at.bofh.it> |
| In reply to | #1270124 |
On Mon, 16 Nov 2015, mhocko@kernel.org wrote: > From: Michal Hocko <mhocko@suse.com> > > __alloc_pages_high_priority doesn't do anything special other than it > calls get_page_from_freelist and loops around GFP_NOFAIL allocation > until it succeeds. It would be better if the first part was done in > __alloc_pages_slowpath where we modify the zonelist because this would > be easier to read and understand. Opencoding the function into its only > caller allows to simplify it a bit as well. > > This patch doesn't introduce any functional changes. > > Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: David Rientjes <rientjes@google.com> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Vlastimil Babka <vbabka@suse.cz> |
|---|---|
| Date | 2015-11-18 15:50 +0100 |
| Subject | Re: [PATCH 1/2] mm: get rid of __alloc_pages_high_priority |
| Message-ID | <qwcdz-4dg-1@gated-at.bofh.it> |
| In reply to | #1270124 |
On 11/16/2015 02:22 PM, mhocko@kernel.org wrote: > From: Michal Hocko <mhocko@suse.com> > > __alloc_pages_high_priority doesn't do anything special other than it > calls get_page_from_freelist and loops around GFP_NOFAIL allocation > until it succeeds. It would be better if the first part was done in > __alloc_pages_slowpath where we modify the zonelist because this would > be easier to read and understand. Opencoding the function into its only > caller allows to simplify it a bit as well. > > This patch doesn't introduce any functional changes. > > Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web