Received: by 10.213.65.68 with SMTP id h4csp860935imn; Tue, 27 Mar 2018 10:06:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/61hjWBsg5DX+T4yRerpdhHLYx/8d29AMtNK8BLXE6Uirmzh2Bjlm78e52iQsHd0tlDCEb X-Received: by 10.98.247.9 with SMTP id h9mr120609pfi.212.1522170395696; Tue, 27 Mar 2018 10:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522170395; cv=none; d=google.com; s=arc-20160816; b=KBr//EqWseIAwvaWsTd05lhYWBOAp0AJHacBQwLjsuuHpu8ExSaapjDy0sjGIYzw4K HLTsd34plrQVCXVnR+guN6gEa+y0zTjDtRpPLY8g6D0atwY0B07X9yuUm0+ZsC8kAOmw OITw8E4ji5vCawqC3kW+v6szhtJgHVxovbJqReuUOFbCs8MuGhQ/OKelqTpO5oPsDEHx MaZ/8oIE6B4YbB5ksnjlo6rv4qVWFTi1n/l42wmS4VyJfUkHCMB0q+jNITfI+6ELi1CJ uCl/+4uLriRuKleWgZDVzRrLQkSBjGiyhtKdXJspTZTIuGmbZ1J+vbXkYExwUD81tvap wfdw== 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=1IyFjCDAjcmMndcyadcnsR26vCg6b/5exbS4EZaB2P4=; b=fQT+l0+8zt1IPgnmiYDFTjPqU+N5CTB2Jf6F0kDtPJQOni312BDRWjUUH8RevjHBaz uP9kR7ApU4C/Qfsqjic6l8N8woGOhoTuxAcP0BrWhlbRszPErjvp+qW4k1lszZsfW2MI 0ZUlvvG31UJNOJov8OEwAQP+tJs+DF+xWSrkTk1nvxt03pWeo6Fav1YZD3KkrLfPK1rb mexYI4iRpauJyX4pePD3bGN2lVIs2r2mIXKS13vs7ezKNosoheXg2CjN7dYe13d6m+dU TkcgBX/Yip5tmNBs2jGYSKTafpPq4YfEailKl0zf5AVrcjgMAHZYShkFtokzi5U5yXj+ X8IA== 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 f64-v6si1606232plf.624.2018.03.27.10.06.20; Tue, 27 Mar 2018 10:06:35 -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 S1753118AbeC0REX (ORCPT + 99 others); Tue, 27 Mar 2018 13:04:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47836 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755116AbeC0Qkj (ORCPT ); Tue, 27 Mar 2018 12:40:39 -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 ECE27127F; Tue, 27 Mar 2018 16:40:38 +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.15 051/105] mm/khugepaged.c: convert VM_BUG_ON() to collapse fail Date: Tue, 27 Mar 2018 18:27:31 +0200 Message-Id: <20180327162800.507511457@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180327162757.813009222@linuxfoundation.org> References: <20180327162757.813009222@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.15-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); /*