From patchwork Wed Jun 10 20:48:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 11598895 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 4937D913 for ; Wed, 10 Jun 2020 20:49:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 130E42072E for ; Wed, 10 Jun 2020 20:49:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RaWatV1s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 130E42072E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 25C2A8D0047; Wed, 10 Jun 2020 16:49:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 20C058D0033; Wed, 10 Jun 2020 16:49:18 -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 0FB3D8D0047; Wed, 10 Jun 2020 16:49:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id E7F1F8D0033 for ; Wed, 10 Jun 2020 16:49:17 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A7204180AD806 for ; Wed, 10 Jun 2020 20:49:17 +0000 (UTC) X-FDA: 76914492354.23.hope02_180d3f426dce Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 75BFF1696C for ; Wed, 10 Jun 2020 20:49:17 +0000 (UTC) X-Spam-Summary: 2,0,0,37e81c680e9bedcf,d41d8cd98f00b204,hughd@google.com,,RULES_HIT:41:355:379:800:960:966:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2689:2731:2904:3138:3139:3140:3141:3142:3152:3353:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4321:4385:5007:6117:6261:6653:7875:7903:10004:10400:11026:11658:11914:12296:12297:12517:12519:12555:12679:12740:12895:12986:13069:13161:13229:13311:13357:13439:14096:14097:14181:14394:14659:14721:14877:21080:21324:21444:21451:21627:21990:30054:30070:30091,0,RBL:209.85.210.68:@google.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:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: hope02_180d3f426dce X-Filterd-Recvd-Size: 4531 Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Jun 2020 20:49:16 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id t6so2833154otk.9 for ; Wed, 10 Jun 2020 13:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=EVxKu+JQQ0AaGxjH7fjwRdxLG0JYbBBXs2fIjSw2Wtk=; b=RaWatV1sTeTqWcbTgYCsWky/yn3DSdIV8wrejh2LPMIh4GKeFW1iUp8V9/UIYZTzpL FHt6rBwFlkXlnuVmDDJesuJTdx9sHJaZPktK+aaCCIvERQlCuUKQgq3lrxLK+cJRhMUc RJJyGhvueSnRqjpAwIUnosfdaV4tNWwMWCre+GSkYfX7LQRWkecaYghD71N+E5a/N6eW 4EeVF6+yICAX7MYrZKlUFKCpG6OfFB8kupjG8YxXnjb9gOFXlDvK7kyg3MdsZLo5aECu VG9Y4CI9k/feSusFbU89Fkha5jNo9lzxTx3uY0aEbxh+7LQaW7g/gICYF3C9k25RJa3l HStg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=EVxKu+JQQ0AaGxjH7fjwRdxLG0JYbBBXs2fIjSw2Wtk=; b=MVapABQkY8PQPf1TNLCVWYWi0Uwi7aeU+At9swvv8mvOH7uM/Ah09yEzqB9QwnbFdh OnLQ7R0fTevJkfqPfeG7BvTxXrSp7L/5swlgNqTymBkqqDiP+Cnfx1mWOVl/fnI0jnVc jlBNGIGKdekyNncTkZdayGJI6TdmhGOVH9jKnkpjsVmm01R41YXzCzxrS6EIJUww82QR 5X99uchjnp5Nix6E+B2c1SdN42111X/y+K6Mh9SivZBX5TcufzVT3nHz2KT70g/Vq/dh NEYQKzZXmasKef9myrttMwZ5dcIV9whkeDqGwW5NPk9H5ImZz8pIhEgmuKJqGJccThp2 VwcA== X-Gm-Message-State: AOAM533NK1CjkjqtiGqjC8/++qnUQ5DWFqAtRU4tq9vZzzBoAoLgicPw 1ptLqNndqEdJh1RdNt34VgN7ww== X-Google-Smtp-Source: ABdhPJxs13x8C/VK5321zEF/iFQMfsx+z7VP3oruxCRutwqhy4mKzxt3MxEGjo4e13oQO/JCNZBv4g== X-Received: by 2002:a9d:6394:: with SMTP id w20mr3885173otk.71.1591822155954; Wed, 10 Jun 2020 13:49:15 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id h189sm209731oif.10.2020.06.10.13.49.14 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 10 Jun 2020 13:49:14 -0700 (PDT) Date: Wed, 10 Jun 2020 13:48:59 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Mel Gorman cc: Andrew Morton , Vlastimil Babka , Li Wang , Alex Shi , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH] mm, page_alloc: capture page in task context only Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 X-Rspamd-Queue-Id: 75BFF1696C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: While stressing compaction, one run oopsed on NULL capc->cc in __free_one_page()'s task_capc(zone): compact_zone_order() had been interrupted, and a page was being freed in the return from interrupt. Though you would not expect it from the source, both gccs I was using (a 4.8.1 and a 7.5.0) had chosen to compile compact_zone_order() with the ".cc = &cc" implemented by mov %rbx,-0xb0(%rbp) immediately before callq compact_zone - long after the "current->capture_control = &capc". An interrupt in between those finds capc->cc NULL (zeroed by an earlier rep stos). This could presumably be fixed by a barrier() before setting current->capture_control in compact_zone_order(); but would also need more care on return from compact_zone(), in order not to risk leaking a page captured by interrupt just before capture_control is reset. Maybe that is the preferable fix, but I felt safer for task_capc() to exclude the rather surprising possibility of capture at interrupt time. Fixes: 5e1f0f098b46 ("mm, compaction: capture a page under direct compaction") Cc: stable@vger.kernel.org # 5.1+ Signed-off-by: Hugh Dickins Acked-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+) --- 5.8-rc0/mm/page_alloc.c 2020-06-08 14:38:47.298625588 -0700 +++ linux/mm/page_alloc.c 2020-06-10 12:12:34.982950441 -0700 @@ -814,6 +814,7 @@ static inline struct capture_control *ta struct capture_control *capc = current->capture_control; return capc && + in_task() && !(current->flags & PF_KTHREAD) && !capc->page && capc->cc->zone == zone &&