Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2483988imd; Fri, 2 Nov 2018 12:12:01 -0700 (PDT) X-Google-Smtp-Source: AJdET5dSMIKOrfetadFeUFJQWalBa7TvIuqGP9YolqFMPetblx3hro29K/nbRFuDCY/3dUTBZzXS X-Received: by 2002:a63:bc12:: with SMTP id q18-v6mr11536075pge.353.1541185921741; Fri, 02 Nov 2018 12:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541185921; cv=none; d=google.com; s=arc-20160816; b=KDt0Ii+XVYvAuMq25kZNePD/12g/cdu6zuIg6OlHpRKrsEzNCqmitntt+Cbgr0IJQC zYRl643C2gX3RokPbSYiw37fR36SBpDutnTI4uEZd/5CmTBe+QZoWZhxBeiFCWBV8o5l 22eq+qnhpuqIZIv5OFmMKodw+SWe0saUwHnGUBrzPNLsVYQ6nFoAsibXC0Q1hgdb1Yuw 3kSBSH8Yk1/x9AmBN1mPi648sJi5pBtIB33mi3Tzyj8ICb4ypPhGbWfrfh3Ha7XNWmCd 7b1aKOs+ZSCd52sD6bwt05JvGgt/DXT9hKU0kj2khY1YV1BadsNDFel8aTvZIhbB7+LJ EKmw== 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=u1qYwx2SJ/vEOcGgD6i1dSBA0sy4u87Cn+NBlP0ABLc=; b=TBUD6AcJKDzG2/4/8E6Jm0MmI0EkvqQg4u+eNCIaNTuQ7GTUxdnTsfODvCHxWqlWLY dV6g8ic2CoRNBc0bG5blUzgrxW2CNEK6/DnB4AovM30H4RDG9/NGz1eufovnZCLOS5wC ryOd+FArNy+8PW/eJhL+OOFcbzl6oh2f8eJzxFY/f822I9bmtoMRqz7z7gRoHY3JWO6f 72zw3EKXGLz1vJZ3G6oQ3kO0Sijn+4UBhXM9FPy8PmhwFjLWcom1ELi5TwsQyv5w3jQN lazwWwNL3m5WT5aBY2ayl8B25oQy0CsuPCLXnPIfuSzYS9XtX9UEVbYyws/UaepJ+wd1 Xjew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BjfzZMmz; 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 d18-v6si9798994pls.8.2018.11.02.12.11.47; Fri, 02 Nov 2018 12:12:01 -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; dkim=pass header.i=@kernel.org header.s=default header.b=BjfzZMmz; 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 S1728884AbeKCDqn (ORCPT + 99 others); Fri, 2 Nov 2018 23:46:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:40534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728140AbeKCDqm (ORCPT ); Fri, 2 Nov 2018 23:46:42 -0400 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 882DF2082D; Fri, 2 Nov 2018 18:38:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541183911; bh=fkBp0lERrmqoXhzPGz/ztUrlCOLS9tFVs+pFegg96co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BjfzZMmzd5ZoaCcB0hb8D7vj2MudIqcUnz8cLU1SQO8i0L6O7s856uQDSpxEuy3vm ACA0PVpbazl6MBW/4yrdV12YtacAYkRPlj7sZMFOMJdoCzmBXQICpnAVklutRuZ/Q7 k2xmX1Zgma2vkEPYUU2Ed6B1BNyiESGcqRsNvWvs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve Capper , Will Deacon , Sasha Levin Subject: [PATCH 4.18 018/150] arm64: hugetlb: Fix handling of young ptes Date: Fri, 2 Nov 2018 19:33:00 +0100 Message-Id: <20181102182904.160098767@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 469ed9d823b7d240d6b9574f061ded7c3834c167 ] In the contiguous bit hugetlb break-before-make code we assume that all hugetlb pages are young. In fact, remove_migration_pte is able to place an old hugetlb pte so this assumption is not valid. This patch fixes the contiguous hugetlb scanning code to preserve young ptes. Fixes: d8bdcff28764 ("arm64: hugetlb: Add break-before-make logic for contiguous entries") Signed-off-by: Steve Capper Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/mm/hugetlbpage.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 192b3ba07075..f85be2f8b140 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -117,11 +117,14 @@ static pte_t get_clear_flush(struct mm_struct *mm, /* * If HW_AFDBM is enabled, then the HW could turn on - * the dirty bit for any page in the set, so check - * them all. All hugetlb entries are already young. + * the dirty or accessed bit for any page in the set, + * so check them all. */ if (pte_dirty(pte)) orig_pte = pte_mkdirty(orig_pte); + + if (pte_young(pte)) + orig_pte = pte_mkyoung(orig_pte); } if (valid) { @@ -340,10 +343,13 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, if (!pte_same(orig_pte, pte)) changed = 1; - /* Make sure we don't lose the dirty state */ + /* Make sure we don't lose the dirty or young state */ if (pte_dirty(orig_pte)) pte = pte_mkdirty(pte); + if (pte_young(orig_pte)) + pte = pte_mkyoung(pte); + hugeprot = pte_pgprot(pte); for (i = 0; i < ncontig; i++, ptep++, addr += pgsize, pfn += dpfn) set_pte_at(vma->vm_mm, addr, ptep, pfn_pte(pfn, hugeprot)); -- 2.17.1