Received: by 10.213.65.68 with SMTP id h4csp884168imn; Tue, 27 Mar 2018 10:32:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx48TJXMp6j1YH4BZY3G9LM3e4Q8uklELIKKkGqsr2i1QulNGadHnDRDKgj2IrOfU9boJh1r9 X-Received: by 2002:a17:902:850b:: with SMTP id bj11-v6mr220695plb.35.1522171974161; Tue, 27 Mar 2018 10:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522171974; cv=none; d=google.com; s=arc-20160816; b=LVE6RSC64tByiuQ2+IN8sDRYfF68D28YGQIwPQURwCxvpseX60EjlPH157+HiiM0hP 4XAghmBEMoDikqIRuCPwf5cSsd/jOspZ/Lsnfv6UJapQsRhqhWOxfXGqg3R3us9P7YZl sYMCH57ZdyuoA5yesrFTt1RX3Ho8YpEEwX84xpvFsePKokfiVVrycQyFh/6ItGgrCCjG GAGfzd92H+ruRVTQPH0hYti6k6AZJ6vGJTGOcOmZ2YYaaZJjJywimeE3atJu1MT6LMzE bhJXlQKvgswCCNlb/NH3GpeJn+HhZA8EtMYiWll48cFhVhNcnpjh7cx4Tt8I42/UJTTt nknw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=jp81KnXk541V0C6/jcSQoDzvGhxvPSGBRW3kP7/6KRc=; b=XdAFInnk77ndjJ+QzB5x5M4u/jtloZJZu5GwAItjYTrz+XSciBsNmhvIuDbPyCwczY J4eW3H7YOznFjLTe618NoW5ij7iD67YF9o/HNgmPGtYtSmuyhAT6Dvub4HXZ5sPtr0Ov iEG3nopoWvasj5sCBr2o65YoVGXcu0uTXbyQuEHJVYYjgb9IFyT/4ScHQes2AE78dB6L WSqHJeokA/k+sI1W5S4w2qRh0f9djr03sT1kc5oZqc4Om42o42CONSHaknbKJIaYfPP3 Mnd+O6/VX6U9MhkWsQmce6ZZyEfkqMUVAVLxKc+qFSbO18W9Ey2RIoroHsMflSj6XONT bIRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j62si1111876pgc.583.2018.03.27.10.32.39; Tue, 27 Mar 2018 10:32:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754585AbeC0Qfv (ORCPT + 99 others); Tue, 27 Mar 2018 12:35:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45526 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754093AbeC0Qfs (ORCPT ); Tue, 27 Mar 2018 12:35:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 32672DCE; Tue, 27 Mar 2018 16:35:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Kirill A. Shutemov" , Laura Abbott , Jerome Marchand , Vlastimil Babka , Andrew Morton , Linus Torvalds Subject: [PATCH 4.14 049/101] mm/khugepaged.c: convert VM_BUG_ON() to collapse fail Date: Tue, 27 Mar 2018 18:27:21 +0200 Message-Id: <20180327162753.037315086@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162749.993880276@linuxfoundation.org> References: <20180327162749.993880276@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kirill A. Shutemov commit fece2029a9e65b9a990831afe2a2b83290cbbe26 upstream. khugepaged is not yet able to convert PTE-mapped huge pages back to PMD mapped. We do not collapse such pages. See check khugepaged_scan_pmd(). But if between khugepaged_scan_pmd() and __collapse_huge_page_isolate() somebody managed to instantiate THP in the range and then split the PMD back to PTEs we would have a problem -- VM_BUG_ON_PAGE(PageCompound(page)) will get triggered. It's possible since we drop mmap_sem during collapse to re-take for write. Replace the VM_BUG_ON() with graceful collapse fail. Link: http://lkml.kernel.org/r/20180315152353.27989-1-kirill.shutemov@linux.intel.com Fixes: b1caa957ae6d ("khugepaged: ignore pmd tables with THP mapped with ptes") Signed-off-by: Kirill A. Shutemov Cc: Laura Abbott Cc: Jerome Marchand Cc: Vlastimil Babka Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/khugepaged.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -530,7 +530,12 @@ static int __collapse_huge_page_isolate( goto out; } - VM_BUG_ON_PAGE(PageCompound(page), page); + /* TODO: teach khugepaged to collapse THP mapped with pte */ + if (PageCompound(page)) { + result = SCAN_PAGE_COMPOUND; + goto out; + } + VM_BUG_ON_PAGE(!PageAnon(page), page); /*