Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1963803ima; Thu, 25 Oct 2018 07:39:15 -0700 (PDT) X-Google-Smtp-Source: AJdET5d+zC37aW92U84hKSY5b9M3yR3IL6OTaPyURTzy47nRxU/i/pWTrXcdGRIHMCGPS0p3SxA4 X-Received: by 2002:a62:e20a:: with SMTP id a10-v6mr1780713pfi.75.1540478355633; Thu, 25 Oct 2018 07:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478355; cv=none; d=google.com; s=arc-20160816; b=KG6foxbpizA8NQGjydWEi61UxmD74DuKANPy03PpCVWatnlQ4QKLUZ70jT94Kmfr0p llOc7kJZMAPQVrg4NHFUIo7kh24f77PeVH8g39EOwXBbWjrFgEK+2TN+xU7f4BTIhre6 lYnCKaZpMxiO5su6qD84ZyETMgp+fiivL0UGEWNJWTP0whzBHcPJYWsPGqEKv3rfvCI4 dHvvswKimlS7QM53wfwDX3t0FDaoHWlWmsdjHJvAdy8FvT2WVwfyJ31FVjsc/mLBzSe/ 4cRfWh4Nzm8OWiy9SI9sWKwN+B7Zvzg1fPVgx+cOQVOtbh66HcT62x8nysFHtw54IID/ pgvg== 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=1Y0HqGhMowL3fog5CZLRBOPIW7kgT0dAVjzqVP8ymp4=; b=MNv9N+uPlnmaX0TJS7hngBmK15xy7+jhYkBSjLRwXTcEb9trWwqnjKbNTZeQ//QC9Z 5+GwlqAFgle1UFXNaMyG5NFcUn+JNZeq1ms/spFz5nAzc3SKIUizGbhXUp15uHlIn2Mb 92w2sDucE4YOAOHpxLx++hKm6OhHj6gLtLhNSz7+BtgoPHOXUjaBycAnRgwrj6i5+wsP /9kDPLIJ5IV4ph917MMXUA/dvBiQilescjG+4YJHJQfrb34lj3lcFTohGfI1LwZcUjhZ 61KM5oNc1YWgtTn/GhdQI2C9WzQIHwZMsbieOlYVYBHbKLYGAnRyvAttcr0MrxgHFdX+ nO0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yVjiaYX9; 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 z72-v6si9074426pgz.323.2018.10.25.07.38.40; Thu, 25 Oct 2018 07:39:15 -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=yVjiaYX9; 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 S1729409AbeJYWta (ORCPT + 99 others); Thu, 25 Oct 2018 18:49:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:58644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728357AbeJYWt2 (ORCPT ); Thu, 25 Oct 2018 18:49:28 -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 A980920870; Thu, 25 Oct 2018 14:16:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476991; bh=HfFfcj4lE3uwi1NFL5nR1V2Ky6kJuDF3IXpyZBTe5qM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yVjiaYX9fsUXrdV8jD9ep6xOIaAK1begzjlMwo9vezDbrI/ykVWNe5SwtBW7BaXye jRoHd16+fx044LbuS0H7PnCXlFaI5tknvAHRXSFs76SfeETOtMQPtqwrGjiTaFUMWK afxFiBa+2O8uDJvjAjzlKATY3j3WZl76MGO/Jcwc= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.9 87/98] sparc64: Fix regression in pmdp_invalidate(). Date: Thu, 25 Oct 2018 10:14:12 -0400 Message-Id: <20181025141423.213774-87-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-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 b2722ed31053..349cb83f7b5f 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