From patchwork Thu Jan 9 22:56:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 11326427 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B1BF1871 for ; Thu, 9 Jan 2020 22:57:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 03D3C2073A for ; Thu, 9 Jan 2020 22:57:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YuimSzZu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03D3C2073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3C0B58E0005; Thu, 9 Jan 2020 17:57:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 370098E0001; Thu, 9 Jan 2020 17:57:15 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 285C88E0005; Thu, 9 Jan 2020 17:57:15 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 12C678E0001 for ; Thu, 9 Jan 2020 17:57:15 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id D4DFD21FA for ; Thu, 9 Jan 2020 22:57:14 +0000 (UTC) X-FDA: 76359608388.23.crow11_5c531e6423a33 X-Spam-Summary: 2,0,0,fc9ad8fbc0394de0,d41d8cd98f00b204,xiyou.wangcong@gmail.com,:linux-kernel@vger.kernel.org:xiyou.wangcong@gmail.com:akpm@linux-foundation.org:mhocko@suse.com:,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1311:1314:1345:1431:1437:1515:1534:1542:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3866:3867:3871:3872:4321:4385:4605:5007:6261:6653:7514:7653:7904:8660:8957:9108:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:12986:13095:13148:13230:13846:13894:14096:14181:14394:14687:14721:21080:21324:21433:21444:21451:21524:21627:21666:21740:21983:30054:30070:30075,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: crow11_5c531e6423a33 X-Filterd-Recvd-Size: 4990 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Thu, 9 Jan 2020 22:57:14 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id x7so8775pgl.11 for ; Thu, 09 Jan 2020 14:57:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2a7Ek0VQLsAuhJ+XYFWJA3fva0Kgdtmci7QB6XNEMP0=; b=YuimSzZu1y5m9DZaeBFiFrcs4NDuyX4BeY681gPjsn3V/IeAf/sqbRvUwwcTyHtfNN umoLWe6WPMlrcdGJ0FrwedEmxnj53t9E1Cdld15ykhcJvlxI7rswAM6ZMAB2sOMehdgC n4cCwi7DocM+8RUKnFb9CiTA5vocgtyXiruGGYWC6tqBKzgrHYoSAnTKqKCqc0I5c1Pc jufAvkwoMSdUDwgwLke6LXNVyHmELFolGkhiPBQPNeVYpIFnGd4dwhSBNfYiqY3a4DNq t5qEToWYutjIhZZqIhZsh+ckC2MNihKpjPtIb68mlV7X5EjaftY3uKqzrIOfV7nRu4EA zyHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2a7Ek0VQLsAuhJ+XYFWJA3fva0Kgdtmci7QB6XNEMP0=; b=gYJD3tusevH6HaHLYenpAQ9EP4PUPOUCAwsZe5zLXVcEsH6QFQjDt0OcBwnlcakXBj kvs4ceFTJaWnMhMWZjhgvvcxh8eWuxrD+MmC7cGtQ6hXDWwzyuRSGVXKahuxyqQV55W5 iNtC2WREl1nxO5hxbbS72CHnlv3XyMiw2rGV0I57DcW2JFytcz10Om2gi+Z0cZQnGBmG 4Uq1OzSRE11fXxB2S5/2yZxzVwNTweWC0nyrech2GjvOQtWEYzIRkKREz8AzoVK2cNp1 2mi5VM4XAL1oQlziCmE0hLk4uqLztJ3oa0TNJtiyFSN4KPmg88PtOmF8gUGqPmSRCLnO VBbA== X-Gm-Message-State: APjAAAVZYW10zf0MeDngkL+Cw3yNhOc7qrzgnT8cgc43VQbnHiHJ+cXe o6qpdutEKoCyNGhs8cstLyk= X-Google-Smtp-Source: APXvYqySJ6jZ9DdfLLZGXudWsLWOQEN++HZ/J0SXS8CbNiwlcs4ZPLLbJ21gQqbWU1f5s62O3Fxn2g== X-Received: by 2002:a65:4c8b:: with SMTP id m11mr453079pgt.208.1578610633203; Thu, 09 Jan 2020 14:57:13 -0800 (PST) Received: from tw-172-25-31-76.office.twttr.net ([8.25.197.24]) by smtp.gmail.com with ESMTPSA id v9sm65662pja.26.2020.01.09.14.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 14:57:12 -0800 (PST) From: Cong Wang To: linux-kernel@vger.kernel.org Cc: Cong Wang , Andrew Morton , Michal Hocko , linux-mm@kvack.org Subject: [PATCH] mm: avoid blocking lock_page() in kcompactd Date: Thu, 9 Jan 2020 14:56:46 -0800 Message-Id: <20200109225646.22983-1-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We observed kcompactd hung at __lock_page(): INFO: task kcompactd0:57 blocked for more than 120 seconds. Not tainted 4.19.56.x86_64 #1 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kcompactd0 D 0 57 2 0x80000000 Call Trace: ? __schedule+0x236/0x860 schedule+0x28/0x80 io_schedule+0x12/0x40 __lock_page+0xf9/0x120 ? page_cache_tree_insert+0xb0/0xb0 ? update_pageblock_skip+0xb0/0xb0 migrate_pages+0x88c/0xb90 ? isolate_freepages_block+0x3b0/0x3b0 compact_zone+0x5f1/0x870 kcompactd_do_work+0x130/0x2c0 ? __switch_to_asm+0x35/0x70 ? __switch_to_asm+0x41/0x70 ? kcompactd_do_work+0x2c0/0x2c0 ? kcompactd+0x73/0x180 kcompactd+0x73/0x180 ? finish_wait+0x80/0x80 kthread+0x113/0x130 ? kthread_create_worker_on_cpu+0x50/0x50 ret_from_fork+0x35/0x40 which faddr2line maps to: migrate_pages+0x88c/0xb90: lock_page at include/linux/pagemap.h:483 (inlined by) __unmap_and_move at mm/migrate.c:1024 (inlined by) unmap_and_move at mm/migrate.c:1189 (inlined by) migrate_pages at mm/migrate.c:1419 Sometimes kcompactd eventually got out of this situation, sometimes not. I think for memory compaction, it is a best effort to migrate the pages, so it doesn't have to wait for I/O to complete. It is fine to call trylock_page() here, which is pretty much similar to buffer_migrate_lock_buffers(). Given MIGRATE_SYNC_LIGHT is used on compaction path, just relax the check for it. Cc: Andrew Morton Cc: Michal Hocko Cc: linux-mm@kvack.org Signed-off-by: Cong Wang --- mm/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index 86873b6f38a7..df60026779d2 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1010,7 +1010,8 @@ static int __unmap_and_move(struct page *page, struct page *newpage, bool is_lru = !__PageMovable(page); if (!trylock_page(page)) { - if (!force || mode == MIGRATE_ASYNC) + if (!force || mode == MIGRATE_ASYNC + || mode == MIGRATE_SYNC_LIGHT) goto out; /*