Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752166AbbKYPg5 (ORCPT ); Wed, 25 Nov 2015 10:36:57 -0500 Received: from relay.parallels.com ([195.214.232.42]:60434 "EHLO relay.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbbKYPg4 (ORCPT ); Wed, 25 Nov 2015 10:36:56 -0500 From: Vladimir Davydov To: Andrew Morton CC: Johannes Weiner , Michal Hocko , Vlastimil Babka , Mel Gorman , , Subject: [PATCH] vmscan: do not throttle kthreads due to too_many_isolated Date: Wed, 25 Nov 2015 18:36:41 +0300 Message-ID: <1448465801-3280-1-git-send-email-vdavydov@virtuozzo.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: US-EXCH2.sw.swsoft.com (10.255.249.46) To MSK-EXCH1.sw.swsoft.com (10.67.48.55) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2286 Lines: 53 Block device drivers often hand off io request processing to kernel threads (example: device mapper). If such a thread calls kmalloc, it can dive into direct reclaim path and end up waiting for too_many_isolated to return false, blocking writeback. This can lead to a dead lock if the pages were isolated by processes performing memcg reclaim, because they call wait_on_page_writeback upon encountering a page under writeback, which will never finish if bio_endio is to be called by the kernel thread stuck in the reclaimer, waiting for the isolated pages to be put back. I've never encountered such a dead lock on vanilla kernel, neither have I tried to reproduce it. However, I faced it with an out-of-tree block device driver, which uses a kernel thread for completing bios: the kernel thread got stuck busy-checking too_many_isolated on the DMA zone, which had only 3 inactive and 68 isolated file pages (2163 pages were free); the pages were isolated by memcg processes waiting for writeback to finish. I don't see anything that could prevent this in case of e.g. device mapper. Let's fix this problem by making too_many_isolated always return false for kernel threads. Apart from fixing the possible dead lock in case of the legacy cgroup hierarchy, this makes sense even if the unified hierarchy is used, where processes performing memcg reclaim will never call wait_on_page_writeback, because kernel threads might be responsible for cleaning pages necessary for reclaim - BTW throttle_direct_reclaim never throttles kernel threads for the same reason. Signed-off-by: Vladimir Davydov --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9d553b07bb86..0f1318a52b23 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1457,7 +1457,7 @@ static int too_many_isolated(struct zone *zone, int file, { unsigned long inactive, isolated; - if (current_is_kswapd()) + if (current->flags & PF_KTHREAD) return 0; if (!sane_reclaim(sc)) -- 2.1.4 -- 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/