Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8131825imu; Tue, 4 Dec 2018 03:33:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wfi1XB9gkVnSKVZla+i1dVroOqcIkBZMlJQgRUuMBLTmESC8ugpoND6n+uNbSyCBHcW1If X-Received: by 2002:a17:902:9692:: with SMTP id n18mr20126704plp.333.1543923209442; Tue, 04 Dec 2018 03:33:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543923209; cv=none; d=google.com; s=arc-20160816; b=ybbXYwDbRoUVLOrcX8wr24Pjs2hlpjC1LC6YI+iEuJWZCFXxDaYEOemRFqx3+8+xUy /hJxRYfp6Dd/fcoRsilFItHRuf4tzGF36X6wY2KazWXZhdBiS+/ueIs18WI/kTtHUSC8 EFAhSo9PPyz8Gnccjdcyst4usM1PmFiTooSx/GBd3XyEOLcx8a+Q4w7ued7Sg2M6R2Sa iOCf5oWS4ikZF+r7RV6Mk2m0fsJuyBkNhveaBv0G//mGO2LP8L+w6PzlpN/UTRxJd5Mt PuPXwF7BFA9sWBxvENHfksNS4OXT8k0yVVBmVmYkY6hv9yHyQwWieHx2dIfsaIrCk8PE HH/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gH23KHwPe0ig/H25clAU6yVRgPWjiQ3qdBvKsJ2MoPo=; b=YhzFIDw1Q1KBpFELp31mDPjRX+BAcGSkPbRRI6kcNOinOc9scCIF3Kpm8zCNi+bgBz rlbL9DDqEZ4SQJQ5OnaUUCDQvsusthdglHZF8qoYamgzn5LeY0c/AuDEl442MTLWJbZO Y+iUX4UPbkWxrDQRACvUKEBtIxR7l/aK/kJ5bNNKe2QZ4jWYHyMva6Q4BwGqvT+SRkcH HfkXPWdXmCoxG71YribeKoSQykuzyvCNvbOTyS4w/tyGe6ObwWioS0WBjb6BbtG5vjpp Yh2WDaJa5wt7zFUQLDnhTsPoAVMKbfeBKZftAq0y9IuvVC+wgtpWzStQw1SFyMhRXcIy dagQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EZgeg8GB; 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 a9si16080041plp.323.2018.12.04.03.33.13; Tue, 04 Dec 2018 03:33:29 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=EZgeg8GB; 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 S1726521AbeLDK4i (ORCPT + 99 others); Tue, 4 Dec 2018 05:56:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:39942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbeLDK4d (ORCPT ); Tue, 4 Dec 2018 05:56:33 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8916521508; Tue, 4 Dec 2018 10:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543920993; bh=GQYbBTYiA6s/AOZMS87ly6cILcsApi0hOsMREvY4TYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZgeg8GBbueEcRdcWG2TYs3UeUxLskbkcxcy/Pz1uVa6+qsOU+Xh0sN8JbDHg6iiI 9zQIaJ46id1yb1OKFvglz09Tvgk/yw6fGDtR/gEAmVXC4I3JQfAGHPNpWoHASoeLnZ KwSvq+U6L/JPNKiSnScWYwyB3LLscbIJ2jW+3tuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hugh Dickins , "Kirill A. Shutemov" , Jerome Glisse , Konstantin Khlebnikov , Matthew Wilcox , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 006/139] mm/khugepaged: collapse_shmem() remember to clear holes Date: Tue, 4 Dec 2018 11:48:07 +0100 Message-Id: <20181204103650.219807209@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103649.950154335@linuxfoundation.org> References: <20181204103649.950154335@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ commit 2af8ff291848cc4b1cce24b6c943394eb2c761e8 upstream. Huge tmpfs testing reminds us that there is no __GFP_ZERO in the gfp flags khugepaged uses to allocate a huge page - in all common cases it would just be a waste of effort - so collapse_shmem() must remember to clear out any holes that it instantiates. The obvious place to do so, where they are put into the page cache tree, is not a good choice: because interrupts are disabled there. Leave it until further down, once success is assured, where the other pages are copied (before setting PageUptodate). Link: http://lkml.kernel.org/r/alpine.LSU.2.11.1811261525080.2275@eggly.anvils Fixes: f3f0e1d2150b2 ("khugepaged: add support of collapse for tmpfs/shmem pages") Signed-off-by: Hugh Dickins Acked-by: Kirill A. Shutemov Cc: Jerome Glisse Cc: Konstantin Khlebnikov Cc: Matthew Wilcox Cc: [4.8+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/khugepaged.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 87dbb0fcfa1a..068868763b78 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1498,7 +1498,12 @@ static void collapse_shmem(struct mm_struct *mm, * Replacing old pages with new one has succeed, now we need to * copy the content and free old pages. */ + index = start; list_for_each_entry_safe(page, tmp, &pagelist, lru) { + while (index < page->index) { + clear_highpage(new_page + (index % HPAGE_PMD_NR)); + index++; + } copy_highpage(new_page + (page->index % HPAGE_PMD_NR), page); list_del(&page->lru); @@ -1508,6 +1513,11 @@ static void collapse_shmem(struct mm_struct *mm, ClearPageActive(page); ClearPageUnevictable(page); put_page(page); + index++; + } + while (index < end) { + clear_highpage(new_page + (index % HPAGE_PMD_NR)); + index++; } local_irq_save(flags); -- 2.17.1