From patchwork Tue Mar 10 23:58:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qian Cai X-Patchwork-Id: 11430465 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 972DF92A for ; Wed, 11 Mar 2020 00:00:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 57EC824658 for ; Wed, 11 Mar 2020 00:00:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="pbwHjYC6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57EC824658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6892B6B0003; Tue, 10 Mar 2020 20:00:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 642326B0006; Tue, 10 Mar 2020 20:00:14 -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 5023C6B0007; Tue, 10 Mar 2020 20:00:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id 351EB6B0003 for ; Tue, 10 Mar 2020 20:00:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id ECC8F4428 for ; Wed, 11 Mar 2020 00:00:13 +0000 (UTC) X-FDA: 76581123906.30.oil68_7625e905fa718 X-Spam-Summary: 2,0,0,ac5f2a39be3c3791,d41d8cd98f00b204,cai@lca.pw,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1542:1711:1712:1730:1747:1777:1792:2198:2199:2393:2559:2562:2731:3138:3139:3140:3141:3142:3352:3608:3865:3866:3867:3870:4250:4321:5007:6119:6261:6653:7903:8957:10004:11026:11473:11638:11658:11914:12043:12114:12297:12517:12519:12555:12660:12679:12895:12986:13161:13229:13870:13894:14018:14093:14096:14181:14394:14721:21080:21324:21444:21451:21524:21627:21740:21990:30054:30065:30070,0,RBL:209.85.160.194:@lca.pw:.lbl8.mailshell.net-66.201.201.201 62.14.0.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:41,LUA_SUMMARY:none X-HE-Tag: oil68_7625e905fa718 X-Filterd-Recvd-Size: 4984 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Mar 2020 00:00:11 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id 59so330126qtb.1 for ; Tue, 10 Mar 2020 17:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6LrB/QDB8/+9bMeHbl1G5SHGJAWHX7k/1TXkj1uMy8U=; b=pbwHjYC6HIZiGsiNaSQogQyA8mwPFjrSsCN/p9MqJR5r4PIE+X+600DpIax/EpnnMD owUdmxNGULtRKav7JAzvOxDo+e214//K51jHYQ+1r/wJi4qkaGagA80V4MbFb1z4XDre TSsUpCq5w1gq9118Vy4P0pglXDMHE9W9jLFtX+iUs7wC3/wZwiNR0pc6VwbwtKcuYucj 7NTN2qBrYKdKRCxPy+nmC5Xhh5E4WPiAarBUhaQDH/vpm+JrTcxYDmbxNXojUbdJ/EHC 0JWAiRIk+1SRppVBZPWvIVTTvRGdc2CTci6uIzm0eXci7sds6BzvDwKOHnREksVmE+xB pwrQ== 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=6LrB/QDB8/+9bMeHbl1G5SHGJAWHX7k/1TXkj1uMy8U=; b=Bfe3gVE2PXN5NG1EeF+DHmTK57jcKmd1Kwdg/wpNJbxfmmTUckJOFKy3TyKxTHI4/Q MDDfV2if6acHhDlSg1bfGtW5ecEd5Y8KujOqzI7NKjipIBjGKSqq/1b8tWpiybPDue8v pgiUVMUgb5kT3S/JvioRXaYFLFfO29dtZFezzTqpmShi5cVuGBf0rwtnw2UT5bDS0aCm Ltu6Uvc9Bu9SC6uetEIngUa/Z0CAGNW/4sMVZ2ck2aWALljKvxrjFjYvaIIK9aLDR+pv +EG8Yg+oE4eH693+uFVGfdHHZJ1nMBbgsaOnVC5ItvzNbrpr5qIUklyXBvi4GscB9beq CTfA== X-Gm-Message-State: ANhLgQ3fC6POFaqPCfnVNY03xFvQgTyFx8y1sd85Ne0ZRY47CObtQQyD kYJ6rllhi1k6wL3gMp8WbbbVOw== X-Google-Smtp-Source: ADFU+vtdB+LdcSVR1g0nETbAZ5AkLI725z4xGiRbhfDsBZb6WqkxKXfMOcA/1mJnXQLZLw5g0L9XYg== X-Received: by 2002:ac8:41c9:: with SMTP id o9mr422919qtm.156.1583884810848; Tue, 10 Mar 2020 17:00:10 -0700 (PDT) Received: from ovpn-121-75.rdu2.redhat.com (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id r29sm3431503qtj.76.2020.03.10.17.00.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2020 17:00:10 -0700 (PDT) From: Qian Cai To: akpm@linux-foundation.org Cc: ying.huang@intel.com, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qian Cai , stable@vger.kernel.org Subject: [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP) Date: Tue, 10 Mar 2020 19:58:46 -0400 Message-Id: <20200310235846.1319-1-cai@lca.pw> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) 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: The commit bd4c82c22c36 ("mm, THP, swap: delay splitting THP after swapped out") supported writing THP to a swap device but forgot to upgrade an older commit df8c94d13c7e ("page-flags: define behavior of FS/IO-related flags on compound pages") which could trigger a crash during THP swapping out with DEBUG_VM_PGFLAGS=y, kernel BUG at include/linux/page-flags.h:317! page dumped because: VM_BUG_ON_PAGE(1 && PageCompound(page)) page:fffff3b2ec3a8000 refcount:512 mapcount:0 mapping:000000009eb0338c index:0x7f6e58200 head:fffff3b2ec3a8000 order:9 compound_mapcount:0 compound_pincount:0 anon flags: 0x45fffe0000d8454(uptodate|lru|workingset|owner_priv_1|writeback|head|reclaim|swapbacked) end_swap_bio_write() SetPageError(page) VM_BUG_ON_PAGE(1 && PageCompound(page)) bio_endio+0x297/0x560 dec_pending+0x218/0x430 [dm_mod] clone_endio+0xe4/0x2c0 [dm_mod] bio_endio+0x297/0x560 blk_update_request+0x201/0x920 scsi_end_request+0x6b/0x4b0 scsi_io_completion+0x509/0x7e0 scsi_finish_command+0x1ed/0x2a0 scsi_softirq_done+0x1c9/0x1d0 __blk_mqnterrupt+0xf/0x20 Fix by checking PF_NO_TAIL in those places instead. Fixes: bd4c82c22c36 ("mm, THP, swap: delay splitting THP after swapped out") Cc: Signed-off-by: Qian Cai Acked-by: "Huang, Ying" Reviewed-by: David Hildenbrand Acked-by: Rafael Aquini --- include/linux/page-flags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 1bf83c8fcaa7..77de28bfefb0 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -311,7 +311,7 @@ static inline int TestClearPage##uname(struct page *page) { return 0; } __PAGEFLAG(Locked, locked, PF_NO_TAIL) PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) -PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND) +PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL) PAGEFLAG(Referenced, referenced, PF_HEAD) TESTCLEARFLAG(Referenced, referenced, PF_HEAD) __SETPAGEFLAG(Referenced, referenced, PF_HEAD)