Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1937915ima; Thu, 25 Oct 2018 07:17:20 -0700 (PDT) X-Google-Smtp-Source: AJdET5fKh2fpJKggobFkcjXp1qGsl7Rdi2aoPacD0W2UuTSiuDvrRjDz6Uawb8XF5S8KwRaaQBR/ X-Received: by 2002:a63:d513:: with SMTP id c19mr1641196pgg.287.1540477040876; Thu, 25 Oct 2018 07:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540477040; cv=none; d=google.com; s=arc-20160816; b=k7CxlW4PMLaBxwVqnbyHfvime7gBQknI2SWxA0J/cgcIDU8auAD7wV4hYHrJG9h/nI TQ4BSbGPDlsr6Lqzr6vBOttZ1fYrOuxVdKmdD0NGdm6H/Fq+xTk98QHl9U6iwhh1lLoT r/zA4UulW7D8TOtiqkvSPumbD7/WklHqxJ1M1/tX973N3bNBkv/HY74VB/QBJ8fhRBqO 8D2Iwe/oAncqQ6njhbn0ZYTqo4j+dHDEdwOE0LyMkCASjnQ4MdNuzncQt5bgR06Td8Cd +Rln9mUpveZQgwPuJhv/HzwYZm3uzkJiujx7X4QH3YsjrvKwbPpr92Km68Ue6Sa7dYYq S+vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=4jY/1v/vvU1Y3Dd3Gw3Za/Fyvcaci1E6O/TI47oq8EI=; b=CoJLMv2VDe7usIaibbic/XtXPgCeBcPBrHei0hsrC7u/yE6BX9n0JtmdWtMqaFLWzo jwSkXEIKc0nSSW7aGkFg4VXRxuQbtReqlzGAXBZN7wFh9PIpD+moEyKzHva1Wv3vSxcB MpXC4svX7/mpKfC2ppAXk+7ingxToE3pXEhYf2dFEHBc9UsZtXdh5D2NWlKC9+2X1YRO hWD2Xnwdl4CLMucXXXWGNouCB/XuOAID7a1k0Dx1TK9KiDkpiffsmCw/Qmiw0nb/ZwZG qHuqa7z2PWYWJbGlryL9HxJ68fyP/g+3y3sjre9I4pLhfdixZNj0FvMDwU5klN4kg5Ec Xj6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=neYNSLCe; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19-v6si7676290pgi.324.2018.10.25.07.16.28; Thu, 25 Oct 2018 07:17:20 -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=neYNSLCe; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbeJYWo0 (ORCPT + 99 others); Thu, 25 Oct 2018 18:44:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:53226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728157AbeJYWoZ (ORCPT ); Thu, 25 Oct 2018 18:44:25 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA49D2054F; Thu, 25 Oct 2018 14:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476690; bh=h1w5tdTsbdXfAsIibCjoy1TvzkcnIJqMT7N1lLwz2iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=neYNSLCe7/Xb0mbQGzuh4yP0llLvLDDcXb7xhDWKoIKIFLsiWnJF9Uk/Z+OphjE53 Z1nWMNBBxMfTEPxiIhsu0x6x6YgdYhfPUEQr+ecmdW7TsT9M4Sh6R9Optgcki5Osep tORa2IXqQrod5bGIeRp5GRGc/XacmjapDcKIZNvA= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.14 25/46] sparc64: Fix regression in pmdp_invalidate(). Date: Thu, 25 Oct 2018 10:10:32 -0400 Message-Id: <20181025141053.213330-25-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141053.213330-1-sashal@kernel.org> References: <20181025141053.213330-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "David S. Miller" [ Upstream commit cfb61b5e3e09f8b49bc4d685429df75f45127adc ] pmdp_invalidate() was changed to update the pmd atomically (to not lose dirty/access bits) and return the original pmd value. However, in doing so, we lost a lot of the essential work that set_pmd_at() does, namely to update hugepage mapping counts and queuing up the batched TLB flush entry. Thus we were not flushing entries out of the TLB when making such PMD changes. Fix this by abstracting the accounting work of set_pmd_at() out into a separate function, and call it from pmdp_establish(). Fixes: a8e654f01cb7 ("sparc64: update pmdp_invalidate() to return old pmd value") Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- arch/sparc/mm/tlb.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index 847ddffbf38a..b5cfab711651 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -163,13 +163,10 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr, pte_unmap(pte); } -void set_pmd_at(struct mm_struct *mm, unsigned long addr, - pmd_t *pmdp, pmd_t pmd) -{ - pmd_t orig = *pmdp; - - *pmdp = pmd; +static void __set_pmd_acct(struct mm_struct *mm, unsigned long addr, + pmd_t orig, pmd_t pmd) +{ if (mm == &init_mm) return; @@ -219,6 +216,15 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr, } } +void set_pmd_at(struct mm_struct *mm, unsigned long addr, + pmd_t *pmdp, pmd_t pmd) +{ + pmd_t orig = *pmdp; + + *pmdp = pmd; + __set_pmd_acct(mm, addr, orig, pmd); +} + static inline pmd_t pmdp_establish(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, pmd_t pmd) { @@ -227,6 +233,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma, do { old = *pmdp; } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd); + __set_pmd_acct(vma->vm_mm, address, old, pmd); return old; } -- 2.17.1