Received: by 10.192.165.148 with SMTP id m20csp538260imm; Wed, 25 Apr 2018 03:55:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5Wt0Pwww8GTm+Fidmo7ljRgFEQk/XBiLzM2EzP8VCZ1lkoQhKmL4vBxIOFejweA7quPUb X-Received: by 2002:a17:902:7e4a:: with SMTP id a10-v6mr24886899pln.276.1524653748944; Wed, 25 Apr 2018 03:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653748; cv=none; d=google.com; s=arc-20160816; b=OBspwN+kq8NoZgsSLvTc+WJz/armSG9IHovC9nn4YYYXYoXSQJqi3lA9jEdIfw6Frp VvCZJV2ihOvJmudcoPrxTrzL5ffFB+ND9fSeC6FkV+UFlZ2vC9KE8F/z8htW1qYjN0SP RmGH8B9BGjLjsqqt4bXCjbZfQsdqrTjGPF8A2exBWS0dTt9BkKJ1ov66WjpF6oft8T+r rXefrGHOmsp4cq1jMU/Lr3NVcbKlFz3DyAjslDrELM9+jYPpxoGxfAo8obh1Q6JbEdEn 8+slthFhOvUvYwWoEh78Rk63hjg+K2k2/UgQhR69CQbNrt5hlMRrMscV+Jd6NoEXDqos 18uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4Y1lUJ7ZQzxcF07V/BJ7p5MQQkMpcUPZatKRuwFg55g=; b=NeeFfwg+NvlrQxqDPaJb8vM8sf263w6nLbq5ZAnrEVuyBNvfAnHcXeww0m/Z3osInH Za6I3V5jhkT1s0wYP5Im1J6efywFdisFbeYR20xPkcm25WxcZrE7oACE2jgjH3+3sF1Y v9ac3uBZMXS0QsfrlRUHC4VSOh5wmaCenyLgmfDt1aglNZEZXvF638UQ2D1ZSFV5QlL4 cJ02lOlGfJUQw4Nc/xF2t3UNp1H0r7xHnvQzbfNbLMHv3b6hxMU/C9JkVHWUIUKMZoRH WKd2Bt3TxoMzeXrEJKcd9C//Q7JLu8RcBI3biy8naQQj1kCID+zhAoagQzM5ZZZ8J+9s F8+g== ARC-Authentication-Results: i=1; mx.google.com; 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 k185si13478140pgk.2.2018.04.25.03.55.34; Wed, 25 Apr 2018 03:55:48 -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; 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 S1753702AbeDYKyd (ORCPT + 99 others); Wed, 25 Apr 2018 06:54:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53030 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754032AbeDYKn1 (ORCPT ); Wed, 25 Apr 2018 06:43:27 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 91B2C36; Wed, 25 Apr 2018 10:43:26 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nitin Gupta , "Kirill A. Shutemov" , David Miller , Vlastimil Babka , Andrea Arcangeli , Michal Hocko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 114/183] sparc64: update pmdp_invalidate() to return old pmd value Date: Wed, 25 Apr 2018 12:35:34 +0200 Message-Id: <20180425103247.027009733@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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. ------------------ From: Nitin Gupta [ Upstream commit a8e654f01cb725d0bfd741ebca1bf4c9337969cc ] It's required to avoid losing dirty and accessed bits. [akpm@linux-foundation.org: add a `do' to the do-while loop] Link: http://lkml.kernel.org/r/20171213105756.69879-9-kirill.shutemov@linux.intel.com Signed-off-by: Nitin Gupta Signed-off-by: Kirill A. Shutemov Cc: David Miller Cc: Vlastimil Babka Cc: Andrea Arcangeli Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/sparc/include/asm/pgtable_64.h | 2 +- arch/sparc/mm/tlb.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -980,7 +980,7 @@ void update_mmu_cache_pmd(struct vm_area pmd_t *pmd); #define __HAVE_ARCH_PMDP_INVALIDATE -extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, +extern pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp); #define __HAVE_ARCH_PGTABLE_DEPOSIT --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -219,17 +219,28 @@ void set_pmd_at(struct mm_struct *mm, un } } +static inline pmd_t pmdp_establish(struct vm_area_struct *vma, + unsigned long address, pmd_t *pmdp, pmd_t pmd) +{ + pmd_t old; + + do { + old = *pmdp; + } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd); + + return old; +} + /* * This routine is only called when splitting a THP */ -void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, +pmd_t pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { - pmd_t entry = *pmdp; - - pmd_val(entry) &= ~_PAGE_VALID; + pmd_t old, entry; - set_pmd_at(vma->vm_mm, address, pmdp, entry); + entry = __pmd(pmd_val(*pmdp) & ~_PAGE_VALID); + old = pmdp_establish(vma, address, pmdp, entry); flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE); /* @@ -240,6 +251,8 @@ void pmdp_invalidate(struct vm_area_stru if ((pmd_val(entry) & _PAGE_PMD_HUGE) && !is_huge_zero_page(pmd_page(entry))) (vma->vm_mm)->context.thp_pte_count--; + + return old; } void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,