From: Michal Hocko <mhocko@kernel.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: tj@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org,
mgorman@suse.de, vbabka@suse.cz
Subject: Re: [PATCH] mm: Use WQ_HIGHPRI for mm_percpu_wq.
Date: Wed, 30 Aug 2017 08:40:19 +0200 [thread overview]
Message-ID: <20170830064019.mfihbeu3mm5ygcrb@dhcp22.suse.cz> (raw)
In-Reply-To: <201708300529.HEB00599.VHtOFOLFSJOMFQ@I-love.SAKURA.ne.jp>
On Wed 30-08-17 05:29:26, Tetsuo Handa wrote:
> Tejun Heo wrote:
> > Hello,
> >
> > On Tue, Aug 29, 2017 at 03:33:25PM +0200, Michal Hocko wrote:
> > > Hmm, we have this in should_reclaim_retry
> > > /*
> > > * Memory allocation/reclaim might be called from a WQ
> > > * context and the current implementation of the WQ
> > > * concurrency control doesn't recognize that
> > > * a particular WQ is congested if the worker thread is
> > > * looping without ever sleeping. Therefore we have to
> > > * do a short sleep here rather than calling
> > > * cond_resched().
> > > */
> > > if (current->flags & PF_WQ_WORKER)
> > > schedule_timeout_uninterruptible(1);
> > >
> > > And I thought it would be susfficient for kworkers for concurrency WQ
> > > congestion thingy to jump in. Or do we need something more generic. E.g.
> > > make cond_resched special for kworkers?
> >
> > I actually think we're hitting a bug somewhere. Tetsuo's trace with
> > the patch applies doesn't add up.
> >
> > Thanks.
>
> If we are under memory pressure, __zone_watermark_ok() can return false.
> If __zone_watermark_ok() == false, when is schedule_timeout_*() called explicitly?
If all zones fail with the watermark check then we should hit the oom
path and sleep there. We do not do so for all cases though. Maybe we
should be more consistent there but even if this was a flood of GFP_NOFS
requests from the WQ context then at least some of them should fail on
the oom lock and sleep and help to make at least some progress. Moreover
Tejun suggests that some pools are idle so this might be a completely
different issue. In any case we can make an explicit reschedule point
in should_reclaim_retry. I would be really surprised if it helped but
maybe this is a better code in the end regardless.
---
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 018468a3b6b1..c93660926f24 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3699,6 +3699,7 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,
{
struct zone *zone;
struct zoneref *z;
+ int ret = false;
/*
* Costly allocations might have made a progress but this doesn't mean
@@ -3762,25 +3763,27 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order,
}
}
- /*
- * Memory allocation/reclaim might be called from a WQ
- * context and the current implementation of the WQ
- * concurrency control doesn't recognize that
- * a particular WQ is congested if the worker thread is
- * looping without ever sleeping. Therefore we have to
- * do a short sleep here rather than calling
- * cond_resched().
- */
- if (current->flags & PF_WQ_WORKER)
- schedule_timeout_uninterruptible(1);
- else
- cond_resched();
-
- return true;
+ ret = true;
+ break;
}
}
- return false;
+ /*
+ * Memory allocation/reclaim might be called from a WQ
+ * context and the current implementation of the WQ
+ * concurrency control doesn't recognize that
+ * a particular WQ is congested if the worker thread is
+ * looping without ever sleeping. Therefore we have to
+ * do a short sleep here rather than calling
+ * cond_resched().
+ */
+ if (current->flags & PF_WQ_WORKER)
+ schedule_timeout_uninterruptible(1);
+ else
+ cond_resched();
+
+
+ return ret;
}
static inline bool
--
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>
prev parent reply other threads:[~2017-08-30 6:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1503921210-4603-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>
2017-08-28 12:10 ` Michal Hocko
2017-08-28 17:06 ` Tejun Heo
2017-08-28 22:15 ` Tetsuo Handa
2017-08-28 23:02 ` Tejun Heo
2017-08-28 23:09 ` Tejun Heo
2017-08-29 11:14 ` Tetsuo Handa
2017-08-29 14:38 ` Tejun Heo
2017-08-29 21:41 ` Tejun Heo
2017-08-30 13:51 ` Tetsuo Handa
2017-08-31 1:46 ` Tejun Heo
2017-08-31 14:52 ` Tetsuo Handa
2017-08-31 15:25 ` Michal Hocko
2017-08-31 22:07 ` Tetsuo Handa
2017-09-01 13:47 ` Tejun Heo
2017-09-01 14:29 ` Tetsuo Handa
2017-08-29 13:33 ` Michal Hocko
2017-08-29 14:33 ` Tejun Heo
2017-08-29 20:29 ` Tetsuo Handa
2017-08-30 6:40 ` Michal Hocko [this message]
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=20170830064019.mfihbeu3mm5ygcrb@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=tj@kernel.org \
--cc=vbabka@suse.cz \
/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