Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2462523imd; Fri, 2 Nov 2018 11:50:10 -0700 (PDT) X-Google-Smtp-Source: AJdET5e/zeGt95rVETnLFb1n9KigW8VAKr2nCbGgz366xAdXSsiv/6aD1s4x3MgSafnQfhuuOro8 X-Received: by 2002:a62:14d4:: with SMTP id 203-v6mr12695278pfu.221.1541184610673; Fri, 02 Nov 2018 11:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184610; cv=none; d=google.com; s=arc-20160816; b=sLCSzO+t1W/TRhzeeJYyUqAk8vEayZ0jPA+uW4oOjiLVCttKX6Wj8CZXZrxbnjB0EL 0XVj2Gdv2EOSkyfoUKKc59Iu7xzayDpTc5fLcQWLzwc9w+Ullrh/uKexMmkkShziMafu sSfnrHzC3+yKFY/KUTxsGCM3EqAsDj3nUQZj3QF+uscbd4mAyE5ACBgUoaH1SwJPHnHZ +MPYg5hSUs51wi9SB2eVBwia6NUCJfHC9NE7zSv/X+NQMW0k5FrMHNQxa3dIYi7oZ49/ LyPQCSfRt0ggPstW95C4YaKlVGdPvpFMHE+aqwu0m8duDSpCGavFwhb04v3LEn5gRZsL UDRw== 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=aXrA2bAf8m6Rufb1KE6kQyCuPtlqp180a6ZX9XmBQXA=; b=Am+5J6j/1MCddlgZs+2XG/kmEILlRae3avgzHl8C9yxTBfk5KqDBMkt/XANSrN6Knb ksoTVToxi0AoA0BIcbyEafvA9ypzeDC5N1aU+SwbPODaaC2yhLMjCld1kFAMlkxE0JJY pPgmmXsGU2x4cnELX7CNAH3/Qjj7OAbNKHfLc4QluUYQezN01UJQSO6+MeOFUvAwZyAE JvqPaKRg17c5QFBY53gVNnUAf6ynZzAzuBJ0qENwoSb2iOxI6cKxn2BCQ0fuflsVej0V PlflrpzCvm/zEHhw2pWVA8g1+47M39GFMiEqYXLAdIT7pFmdBZN3giqHi9uHPeOSVAxQ 893w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q7LesYKT; 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 z126-v6si12980062pfb.280.2018.11.02.11.49.56; Fri, 02 Nov 2018 11:50:10 -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=Q7LesYKT; 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 S1730700AbeKCD5r (ORCPT + 99 others); Fri, 2 Nov 2018 23:57:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:53520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbeKCD5r (ORCPT ); Fri, 2 Nov 2018 23:57:47 -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 0CDD220837; Fri, 2 Nov 2018 18:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184572; bh=wLN85fRG4904OqZ3inN731Ro1yyR9MbM3y17KaDlIUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q7LesYKTgx+V3+gDocN/maIEC418y+TN3T9t/K1wFWjSuwxl1QMXEHy8Ye961LCMY C2j33CJ0Rv5cJX03beYuG6DfOgMNKBqUqv9/CMKrz/J3DISwJT+7giCeE+K2xn2bKq mc8sa2es8/T6cBHzQqP6UcBXjd/ffjc6i4Ellm+E= 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.14 015/143] arm64: hugetlb: Fix handling of young ptes Date: Fri, 2 Nov 2018 19:33:20 +0100 Message-Id: <20181102182858.309982426@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182857.064326086@linuxfoundation.org> References: <20181102182857.064326086@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.14-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 6cb0fa92a651..9f6ae9686dac 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -118,11 +118,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) @@ -347,10 +350,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