From patchwork Fri Apr 5 13:51:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 10887411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9EB0A1515 for ; Fri, 5 Apr 2019 13:51:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 884A921EEB for ; Fri, 5 Apr 2019 13:51:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C592281C3; Fri, 5 Apr 2019 13:51:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5DE321EEB for ; Fri, 5 Apr 2019 13:51:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1275A6B026B; Fri, 5 Apr 2019 09:51:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 097DA6B026D; Fri, 5 Apr 2019 09:51:24 -0400 (EDT) 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 EA1E66B026E; Fri, 5 Apr 2019 09:51:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 9F4276B026B for ; Fri, 5 Apr 2019 09:51:23 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id d2so3177936edo.23 for ; Fri, 05 Apr 2019 06:51:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=lzcy0m9Ct3wLhEZq/mTvC0ituY1HDTmyz8m7K/d4ouM=; b=MSiqXbnj8oPMpybEZlIkFTu1X2WEhfKxat3FzmIE7JH0ohOEjvq572+egLeusm5VfL sYElXiH8GkTt5UoWAQeoifD279nB0UsTbV6I3wgePqRRRsCp1SW2nBcUtt1dMgoqXrHW wBCCwvpE19pM9pXGwihGP9ujC4FccVbTsDbR2LeP723AC+U1rxKzgmb40cl9VErUtclI 0LVTMhEriaMQM2bdLnwmDTsL6HqtYDiISy0yJOwAp9LpE+5+a10BzzvTxZMoAf+QfSTB 6qVWHhEfVB3GUlX87zGoOC+egPNgU2Wh7DV2fu2fC9d//gkA6WK07tM7sxWVU766oedY A3zg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.41 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-Gm-Message-State: APjAAAUQ9EZAUOhXiG1UIcuoGRYC2OZd+pQlaJsXRyKYIS9SGzrqz9tP h/8l4lYr01teJNbWoiNXtOYvT+x0iqBm0sB9reC0+H/KTuUT2N/iFLU2YcaOAs3Z6l5yT/bvyPB 3l1/W/Mfru+IrYGsWTHSthun9UdM5xmqnSSF5gJR6dw4NT1kiBmfSGIkrRuGYkk9NSQ== X-Received: by 2002:a50:b3b1:: with SMTP id s46mr8330440edd.202.1554472283024; Fri, 05 Apr 2019 06:51:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjsWsECZ00WBCGMy5NP83D7jkKaH4SyzbxAuYi5FBtRK7qI+p5IvxSoFTyME6kIUMdFxeY X-Received: by 2002:a50:b3b1:: with SMTP id s46mr8330380edd.202.1554472281999; Fri, 05 Apr 2019 06:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554472281; cv=none; d=google.com; s=arc-20160816; b=oR6FWMFAfZa4Gh2UPLaZF6oiwhh7gzMVXKcfLHVbsAIBlYhAECJMr7qvkC8DF9fqNr /KlFUrZO1z12Jd2nAbE6lL0bIWgjRKIFm4LZ3X0OuTmRMYYpmIpHddxVzMdErh0TfiWe sNIOZNrqjBMojOwiS2tN3XaQpU66mPt7P2R9mlGKBdXn+AyUwjshueoZtDB8KBcAiOLw xaPk9h9is6LBdv+T0wYH7+7ebFUMUw9BLrcdtEzU0oGfeA9pr1nvUnP372l59ls8iLgi T97bZp2jd3BQMHzRl43SH+cT2DYBTBu5ifdv9efPIeA9xF2sHj/i0mxUKkVPzFj6Oq9B is8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=lzcy0m9Ct3wLhEZq/mTvC0ituY1HDTmyz8m7K/d4ouM=; b=NvY6g4I4yxSXdmEBm8XWvLosbwVnC4Fy8/p9PKuXCooxgerDhoc6uAYeI7S+lpPmxa Lz+t1Bbzna1uqy/oyzwILtk+Va/01MOktHgljFme71/A/FRzYzNBSXEe9kEuzj1lvMkb InQCwqaAsYb0s4cCxwcaqsY0j5OhoPFsKeAkI25p55CdBNId21MsUKErBWuN9XaS3VRa qlnCMZENKWAvrz5EP/tFlpKmVcEH0Su6zdvbEiWSqK0KshxNlZIeEQmYgIiblx3DcJH/ 0SBri+wPc5KlY+mxFaEAjU5u2yqxuvuGLT3LmOuyG7uxkt2AYQJjMAI3v1fz416MsrBP qfiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.41 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from outbound-smtp21.blacknight.com (outbound-smtp21.blacknight.com. [81.17.249.41]) by mx.google.com with ESMTPS id c2si934203edl.204.2019.04.05.06.51.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2019 06:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.41 as permitted sender) client-ip=81.17.249.41; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.41 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp21.blacknight.com (Postfix) with ESMTPS id 3C6DAB8B74 for ; Fri, 5 Apr 2019 14:51:21 +0100 (IST) Received: (qmail 28386 invoked from network); 5 Apr 2019 13:51:21 -0000 Received: from unknown (HELO stampy.163woodhaven.lan) (mgorman@techsingularity.net@[37.228.225.79]) by 81.17.254.9 with ESMTPA; 5 Apr 2019 13:51:21 -0000 From: Mel Gorman To: Linus Torvalds Cc: Andrew Morton , Linux-MM , LKML , Mel Gorman Subject: [GIT PULL] mm/compaction functional fixes for v5.1-rc4 Date: Fri, 5 Apr 2019 14:51:18 +0100 Message-Id: <20190405135120.27532-1-mgorman@techsingularity.net> X-Mailer: git-send-email 2.16.4 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: X-Virus-Scanned: ClamAV using ClamSMTP The following changes since commit 79a3aaa7b82e3106be97842dedfd8429248896e6: Linux 5.1-rc3 (2019-03-31 14:39:29 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/mel/linux.git tags/mm-compaction-5.1-rc4 for you to fetch changes up to 5b56d996dd50a9d2ca87c25ebb50c07b255b7e04: mm/compaction.c: abort search if isolation fails (2019-04-04 11:56:15 +0100) ---------------- Hi Linus, The merge window for 5.1 introduced a number of compaction-related patches authored by myself. There are intermittent reports of corruption and functional issues based on them due to sloppy checking of zone boundaries and a corner case where the free lists are overrun. Reports are not common but at least two users and 0-day have tripped over them. There is a chance that one of the syzbot reports are related but it has not been confirmed properly. The normal submission path is through Andrew but it's now late on a Friday and I do not know if a round of updates are coming your way or not and these patches have been floating around for a while. Given the nature of the fixes, I really would prefer to avoid another RC with corruption issues creating duplicate reports. All of these have been successfully tested on older RC windows. This will make this branch look like a rebase but they've simply been cherry-picked from Andrew's tree and placed on a fresh branch. I've no reason to believe that this has invalidated the testing given the lack of change in compaction and the nature of the fixes. Note that you may still receive these from Andrew and there are other compaction-related fixes in his tree that are less critical. I do not expect them to conflict but there is a non-zero risk of confusion. If you get a bunch of patches from Andrew then please ignore this entirely so the normal submission path is preserved. Otherwise, please either git pull this or pick up the patches directly at your discretion. Mel Gorman (1): mm/compaction.c: correct zone boundary handling when resetting pageblock skip hints Qian Cai (1): mm/compaction.c: abort search if isolation fails mm/compaction.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) From patchwork Fri Apr 5 13:51:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 10887415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7303F13B5 for ; Fri, 5 Apr 2019 13:51:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58F2B27FB3 for ; Fri, 5 Apr 2019 13:51:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D0C72842B; Fri, 5 Apr 2019 13:51:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACB3527FB3 for ; Fri, 5 Apr 2019 13:51:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77D766B026D; Fri, 5 Apr 2019 09:51:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7271E6B026E; Fri, 5 Apr 2019 09:51:24 -0400 (EDT) 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 646126B0270; Fri, 5 Apr 2019 09:51:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 132E36B026E for ; Fri, 5 Apr 2019 09:51:24 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id w3so3302918edt.2 for ; Fri, 05 Apr 2019 06:51:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=05XxbmfCAjHMhi/VtlSMkPiApWuac6A+r9QYYikljpc=; b=l0YCdaJ1sIOXyTHSASbCuIi+yseTVmj2tWgovWNGVWxubrVsBXF+49FeLom/BRGMG7 WnwNG9K+AB/nk8VaF0HhymEyRZ6fcAFX9EuEq1zwli+nyBrQzqSARFwY+4Ewb5q0r8EZ wfLxguIgTj2xvFrEXf+5JeNYMP7sZq2KWAFqHUWrZ5mhR1jjDVSekdydm/0B9tJFC3pZ SfWWLvX3ABMuhPOsSDo8R9ecKuOQMaBeCAeTOxSKr/bbGPksKSihJnMU0sb3dGhndzKu gb5kauvQqgfyvlAUIgb9jlgx31XcdVZ1cWMSNj6KULvu4hN4vrIeaQOOGWOC5jnppOaZ 0ioQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.8 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-Gm-Message-State: APjAAAW6VXkDHbmxcI6GY4tYnAcED+U9qw8sG3lHN8x0XZXsaBXtW3GS wr2l7jg6dzucd+CrjCjBPWSDEwI0XMuBolpYwVR18+aQPOFekZTU3FBaWtWrfAIVvtOmoua5j// D9EOXBgwiXpKxSzOMYFdTUN+ttrf/J7ur0QyL5paPjcUg2XAR5e+ktiiLuayiIQhA8w== X-Received: by 2002:a17:906:4453:: with SMTP id i19mr7563876ejp.39.1554472283551; Fri, 05 Apr 2019 06:51:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWErtYNv/ks6sxsjxuoVvBogJ1JNPEoZ0xa4d3+php/EZuRVWicG76pCsgUSVlds7sdcqk X-Received: by 2002:a17:906:4453:: with SMTP id i19mr7563800ejp.39.1554472282003; Fri, 05 Apr 2019 06:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554472282; cv=none; d=google.com; s=arc-20160816; b=f/olmr0vwAmceH0odu1O4hXHok1pWoIh5fNQ5/biGybeaXBB4MtQZC+7Zb0iuOxgWk zRCIcTmSrGifzjyjUBIbeyfgmymjhqVNLAkMiLMntm+30NX4NSYorXN3pXoEg5VGW6z3 Tit7IUF/xCFp64aCiacDXkqxlVsN89fB9CwlRx3pEmZJQUsJA3LS4bLvD68t+V9FEWsO e9z6EqSHw7tj47PrLdxBa8/E/WCoDMEpnDC/lYfwBZ7JGXWvRDngsIfiqMjj1s2GOqbh QdZQHkcd0JJpXYF8M/Hx8n0UTkCQ4FkIpdVauCHXcMkyZguFarKwD0b0MlFGOH9t1m3b 4UYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=05XxbmfCAjHMhi/VtlSMkPiApWuac6A+r9QYYikljpc=; b=KqqM1PYSW/ylKEa/qB72IWwSzO+CPXSY2zNNarZq6oE8N8423vP+fvoFoY5FqHP+Uo i1s49fkEHUP5NVpbBTz8nV0FOU7OYAEzal6XfYPZOssFUkBfEDeFN+h8sh0cha4vVlAT RrUu1U7E8DBf4pxLCPlCvFK6UZjki4SVdexx0FPvYDB//DqYm7GckpuZir8fPe63I4CT JELhdVCFss1ei93V1Ns2KbODYey5+woxyjY8TTcsYlTB6fLRRIVCxVLiWNVYguDk2yLb bLwuIyD1mH/RHtR9SmOGVt38yM2B9pgk3l0dRXXi7r4Wlu3beDipidYUxQHJBOz7CimO AyMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.8 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from outbound-smtp02.blacknight.com (outbound-smtp02.blacknight.com. [81.17.249.8]) by mx.google.com with ESMTPS id ce3si2496598ejb.400.2019.04.05.06.51.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2019 06:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.8 as permitted sender) client-ip=81.17.249.8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mgorman@techsingularity.net designates 81.17.249.8 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp02.blacknight.com (Postfix) with ESMTPS id 7E7D098D8C for ; Fri, 5 Apr 2019 13:51:21 +0000 (UTC) Received: (qmail 28412 invoked from network); 5 Apr 2019 13:51:21 -0000 Received: from unknown (HELO stampy.163woodhaven.lan) (mgorman@techsingularity.net@[37.228.225.79]) by 81.17.254.9 with ESMTPA; 5 Apr 2019 13:51:21 -0000 From: Mel Gorman To: Linus Torvalds Cc: Andrew Morton , Linux-MM , LKML , Mel Gorman Subject: [PATCH 2/2] mm/compaction.c: abort search if isolation fails Date: Fri, 5 Apr 2019 14:51:20 +0100 Message-Id: <20190405135120.27532-3-mgorman@techsingularity.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190405135120.27532-1-mgorman@techsingularity.net> References: <20190405135120.27532-1-mgorman@techsingularity.net> 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Qian Cai Running LTP oom01 in a tight loop or memory stress testing put the system in a low-memory situation could triggers random memory corruption like page flag corruption below due to in fast_isolate_freepages(), if isolation fails, next_search_order() does not abort the search immediately could lead to improper accesses. UBSAN: Undefined behaviour in ./include/linux/mm.h:1195:50 index 7 is out of range for type 'zone [5]' Call Trace: dump_stack+0x62/0x9a ubsan_epilogue+0xd/0x7f __ubsan_handle_out_of_bounds+0x14d/0x192 __isolate_free_page+0x52c/0x600 compaction_alloc+0x886/0x25f0 unmap_and_move+0x37/0x1e70 migrate_pages+0x2ca/0xb20 compact_zone+0x19cb/0x3620 kcompactd_do_work+0x2df/0x680 kcompactd+0x1d8/0x6c0 kthread+0x32c/0x3f0 ret_from_fork+0x35/0x40 ------------[ cut here ]------------ kernel BUG at mm/page_alloc.c:3124! invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI RIP: 0010:__isolate_free_page+0x464/0x600 RSP: 0000:ffff888b9e1af848 EFLAGS: 00010007 RAX: 0000000030000000 RBX: ffff888c39fcf0f8 RCX: 0000000000000000 RDX: 1ffff111873f9e25 RSI: 0000000000000004 RDI: ffffed1173c35ef6 RBP: ffff888b9e1af898 R08: fffffbfff4fc2461 R09: fffffbfff4fc2460 R10: fffffbfff4fc2460 R11: ffffffffa7e12303 R12: 0000000000000008 R13: dffffc0000000000 R14: 0000000000000000 R15: 0000000000000007 FS: 0000000000000000(0000) GS:ffff888ba8e80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fc7abc00000 CR3: 0000000752416004 CR4: 00000000001606a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: compaction_alloc+0x886/0x25f0 unmap_and_move+0x37/0x1e70 migrate_pages+0x2ca/0xb20 compact_zone+0x19cb/0x3620 kcompactd_do_work+0x2df/0x680 kcompactd+0x1d8/0x6c0 kthread+0x32c/0x3f0 ret_from_fork+0x35/0x40 Link: http://lkml.kernel.org/r/20190320192648.52499-1-cai@lca.pw Fixes: dbe2d4e4f12e ("mm, compaction: round-robin the order while searching the free lists for a target") Signed-off-by: Qian Cai Acked-by: Mel Gorman Cc: Daniel Jordan Cc: Mikhail Gavrilov Cc: Vlastimil Babka Cc: Pavel Tatashin Signed-off-by: Mel Gorman --- mm/compaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/compaction.c b/mm/compaction.c index b4930bf93c8a..3319e0872d01 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1370,7 +1370,7 @@ fast_isolate_freepages(struct compact_control *cc) count_compact_events(COMPACTISOLATED, nr_isolated); } else { /* If isolation fails, abort the search */ - order = -1; + order = cc->search_order + 1; page = NULL; } }