Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1493215 > unrolled thread
| Started by | Michal Hocko <mhocko@kernel.org> |
|---|---|
| First post | 2016-09-29 10:50 +0200 |
| Last post | 2016-09-29 11:20 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/2] mm: warn about allocations which stall for too long Michal Hocko <mhocko@kernel.org> - 2016-09-29 10:50 +0200
Re: [PATCH 2/2] mm: warn about allocations which stall for too long Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> - 2016-09-29 11:10 +0200
Re: [PATCH 2/2] mm: warn about allocations which stall for too long Michal Hocko <mhocko@kernel.org> - 2016-09-29 11:20 +0200
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2016-09-29 10:50 +0200 |
| Subject | [PATCH 2/2] mm: warn about allocations which stall for too long |
| Message-ID | <smFct-1IL-5@gated-at.bofh.it> |
From: Michal Hocko <mhocko@suse.com>
Currently we do warn only about allocation failures but small
allocations are basically nofail and they might loop in the page
allocator for a long time. Especially when the reclaim cannot make
any progress - e.g. GFP_NOFS cannot invoke the oom killer and rely on
a different context to make a forward progress in case there is a lot
memory used by filesystems.
Give us at least a clue when something like this happens and warn about
allocations which take more than 10s. Print the basic allocation context
information along with the cumulative time spent in the allocation as
well as the allocation stack. Repeat the warning after every 10 seconds so
that we know that the problem is permanent rather than ephemeral.
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
mm/page_alloc.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 969ffc97045b..73f60ad6315f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3495,6 +3495,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
enum compact_result compact_result;
int compaction_retries = 0;
int no_progress_loops = 0;
+ unsigned long alloc_start = jiffies;
+ unsigned int stall_timeout = 10 * HZ;
/*
* In the slowpath, we sanity check order to avoid ever trying to
@@ -3650,6 +3652,14 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_REPEAT))
goto nopage;
+ /* Make sure we know about allocations which stall for too long */
+ if (time_after(jiffies, alloc_start + stall_timeout)) {
+ warn_alloc(gfp_mask,
+ "page alloction stalls for %ums, order:%u\n",
+ jiffies_to_msecs(jiffies-alloc_start), order);
+ stall_timeout += 10 * HZ;
+ }
+
if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
did_some_progress > 0, &no_progress_loops))
goto retry;
--
2.9.3
[toc] | [next] | [standalone]
| From | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> |
|---|---|
| Date | 2016-09-29 11:10 +0200 |
| Message-ID | <smFvP-250-19@gated-at.bofh.it> |
| In reply to | #1493215 |
Michal Hocko wrote:
> From: Michal Hocko <mhocko@suse.com>
>
> Currently we do warn only about allocation failures but small
> allocations are basically nofail and they might loop in the page
> allocator for a long time. Especially when the reclaim cannot make
> any progress - e.g. GFP_NOFS cannot invoke the oom killer and rely on
> a different context to make a forward progress in case there is a lot
> memory used by filesystems.
>
> Give us at least a clue when something like this happens and warn about
> allocations which take more than 10s. Print the basic allocation context
> information along with the cumulative time spent in the allocation as
> well as the allocation stack. Repeat the warning after every 10 seconds so
> that we know that the problem is permanent rather than ephemeral.
>
> Signed-off-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/page_alloc.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 969ffc97045b..73f60ad6315f 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3495,6 +3495,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
> enum compact_result compact_result;
> int compaction_retries = 0;
> int no_progress_loops = 0;
> + unsigned long alloc_start = jiffies;
> + unsigned int stall_timeout = 10 * HZ;
>
> /*
> * In the slowpath, we sanity check order to avoid ever trying to
> @@ -3650,6 +3652,14 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
> if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_REPEAT))
> goto nopage;
>
> + /* Make sure we know about allocations which stall for too long */
> + if (time_after(jiffies, alloc_start + stall_timeout)) {
> + warn_alloc(gfp_mask,
I expect "gfp_mask & ~__GFP_NOWARN" rather than "gfp_mask" here.
Otherwise, we can't get a clue for __GFP_NOWARN allocations.
> + "page alloction stalls for %ums, order:%u\n",
> + jiffies_to_msecs(jiffies-alloc_start), order);
> + stall_timeout += 10 * HZ;
> + }
> +
> if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
> did_some_progress > 0, &no_progress_loops))
> goto retry;
> --
> 2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Date | 2016-09-29 11:20 +0200 |
| Message-ID | <smFFw-28g-21@gated-at.bofh.it> |
| In reply to | #1493224 |
On Thu 29-09-16 18:02:44, Tetsuo Handa wrote:
[...]
> > @@ -3650,6 +3652,14 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
> > if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_REPEAT))
> > goto nopage;
> >
> > + /* Make sure we know about allocations which stall for too long */
> > + if (time_after(jiffies, alloc_start + stall_timeout)) {
> > + warn_alloc(gfp_mask,
>
> I expect "gfp_mask & ~__GFP_NOWARN" rather than "gfp_mask" here.
> Otherwise, we can't get a clue for __GFP_NOWARN allocations.
If there is an explicit __GFP_NOWARN then I believe we should obey it
same way we do for the allocation failure. If you believe this is not
the best way then feel free to send a patch with an example where a
__GFP_NOWARN user would really like to see about the stall.
--
Michal Hocko
SUSE Labs
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web