From patchwork Mon Oct 28 22:14:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Song Liu X-Patchwork-Id: 11216725 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 1F8991390 for ; Mon, 28 Oct 2019 22:14:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D3C7921835 for ; Mon, 28 Oct 2019 22:14:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="oMY63gGi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3C7921835 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 01C806B0005; Mon, 28 Oct 2019 18:14:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EE7E76B0006; Mon, 28 Oct 2019 18:14:33 -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 DAF6B6B0007; Mon, 28 Oct 2019 18:14:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id B21336B0005 for ; Mon, 28 Oct 2019 18:14:33 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 339A4689A for ; Mon, 28 Oct 2019 22:14:33 +0000 (UTC) X-FDA: 76094598426.08.power83_7efdfffa1832a X-Spam-Summary: 2,0,0,86ef59ec5e1f6a71,d41d8cd98f00b204,prvs=5204af4217=songliubraving@fb.com,:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:matthew.wilcox@oracle.com:kernel-team@fb.com:william.kucharski@oracle.com:kirill.shutemov@linux.intel.com:songliubraving@fb.com:hannes@cmpxchg.org:hughd@google.com,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1261:1277:1313:1314:1345:1431:1437:1516:1518:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3868:3870:3871:3872:4419:5007:6261:6653:8660:10004:10400:10450:10455:11658:11914:12043:12296:12297:12438:12555:12679:12895:13069:13141:13148:13221:13229:13230:13311:13357:14093:14096:14097:14181:14394:14721:19904:19999:21080:21324:21451:21627:21740:30054:30064,0,RBL:67.231.153.30:@fb.com:.lbl8.mailshell.net-62.2.0.100 64.100.201.201,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:27,LUA_SUMMARY:none X-HE-Tag: power83_7efdfffa1832a X-Filterd-Recvd-Size: 4174 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Mon, 28 Oct 2019 22:14:32 +0000 (UTC) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.42/8.16.0.42) with SMTP id x9SJcqQn024688 for ; Mon, 28 Oct 2019 15:14:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=Bw61RvUeSt9VNy7+1JLmIxhGU2iP6hPAzoxy1ZqvJxw=; b=oMY63gGir0KBr8MtiFGbx8ob022AEWHr05oWHbxiyPKBh814KA/APENpXYuKHB9T2gxY F2NhRU4fb369erWmTKI4LKjgNmCqDyOxs6zKIHZJAhss8TQY5gfqfQuaDbFUPrRaBN91 bOH68Sa3rbHZOz91bji/713np3jvVDZhxY4= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by m0089730.ppops.net with ESMTP id 2vx1jnarg4-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 28 Oct 2019 15:14:31 -0700 Received: from 2401:db00:2050:5076:face:0:1f:0 (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Mon, 28 Oct 2019 15:14:16 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id 058A762E2077; Mon, 28 Oct 2019 15:14:15 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , , , , Song Liu , Johannes Weiner , Hugh Dickins Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH] mm/thp: fix deadlock in collapse_file() Date: Mon, 28 Oct 2019 15:14:14 -0700 Message-ID: <20191028221414.3685035-1-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-28_05:2019-10-25,2019-10-28 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 mlxlogscore=882 mlxscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910280143 X-FB-Internal: deliver 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: As syzbot reported, we cannot call filemap_flush() with the page locked. Remove the filemap_flush() as it is not required. khugepaged would just wait until the page is flushed naturally. Reported-by: syzbot+efb9e48b9fbdc49bb34a@syzkaller.appspotmail.com Fixes: 9d840e58caa0 ("mmthp-recheck-each-page-before-collapsing-file-thp-v4") Cc: Johannes Weiner Cc: Kirill A. Shutemov Cc: Hugh Dickins Cc: William Kucharski Cc: Andrew Morton Signed-off-by: Song Liu --- mm/khugepaged.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index cd480dce92c6..3ec5333ae94d 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1640,16 +1640,8 @@ static void collapse_file(struct mm_struct *mm, /* * khugepaged only works on read-only fd, so this * page is dirty because it hasn't been flushed - * since first write. There won't be new dirty - * pages. - * - * Trigger async flush here and hope the writeback - * is done when khugepaged revisits this page. - * - * This is a one-off situation. We are not forcing - * writeback in loop. + * since first write. */ - filemap_flush(mapping); result = SCAN_FAIL; goto out_unlock; }