Received: by 10.192.165.148 with SMTP id m20csp733229imm; Fri, 4 May 2018 05:40:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrdRWliEBddBDRfANAwpt+eTzOE09lXM0RXWZ4T3s6L7M4L6WZWR1DUoKbV5ZmHqtkmMug7 X-Received: by 2002:a65:4ed0:: with SMTP id w16-v6mr5407918pgq.41.1525437647925; Fri, 04 May 2018 05:40:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525437647; cv=none; d=google.com; s=arc-20160816; b=eN2emnq4MBs3LbT6g0KRzJcAyP9Szu62EH/k0hF1tmzN/2QohsW3tlJurAFBP0A+rw ZhTPj0XztKL/CFQvbdZJ6mhK4LU2uf4OJD5Z7Gan1PYsCejgX2UKoocPfIFwUpzt9ksA eAznUcCj9u+8gRC81Ddgmw+B/OgDeo+DF4CeDlbRGEE1qY1LtbR++G+1kzvGA/mBJMV3 Ps7Za6SPlot5nbMPRrVKd3LYWkEGtooBf17ohWWC5DsrCpmeO5/3LnNB6k8Ok+5Qv9IY JPjDuRBF4Z8GNEvnufIlKsHVinpprNqQuAOH9wxprkdIkLHzRU16ZiohTzP4cT6jA5J5 eWfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:arc-authentication-results; bh=mrZcgDyqv0ZuxgP4VhX7G2z96voQeil0nABPh/E0j/A=; b=HIxrQqGbSMZ9MLrNe/mpzPkImSFbFWWCkw3kpP/Vh1bLF5xZqJRzVi7F7qLY4+KUr/ C8ZZLl2eM6e58euX0OqB9WC1TnTrH2FwZT37qWFDl1fi0pnhAK84AYeeynrFvr4XhLl6 DFKRNVqlgJMWaqw2xfYaoke2dcEHu9LUezBpPN1jlq+Wq7PDpXY/9yobpjnixxEjR+bu BWGsTDbvNg5EFl3n+BnPeqeE9ij/s0z9ASFwvyuspFE140JoQm0+4Hz7S1G7wBpXA923 nQmLO/pcAmcLCTiJB3D1ZH+93eUYDlTR0ZZuLhKJzEzDB+REn0F6FwHySp+hiCxNFxMI plMw== 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 e33-v6si9526915pld.231.2018.05.04.05.40.31; Fri, 04 May 2018 05:40:47 -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 S1751519AbeEDMeC (ORCPT + 99 others); Fri, 4 May 2018 08:34:02 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:21356 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751470AbeEDMd5 (ORCPT ); Fri, 4 May 2018 08:33:57 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 40crzP0QDzz9tvTD; Fri, 4 May 2018 14:33:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id ljWk2FaoL5st; Fri, 4 May 2018 14:33:52 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 40crzN7101z9ttC1; Fri, 4 May 2018 14:33:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BCEA28B975; Fri, 4 May 2018 14:33:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id qhNaGczPSukJ; Fri, 4 May 2018 14:33:56 +0200 (CEST) Received: from po14934vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A08C68B972; Fri, 4 May 2018 14:33:56 +0200 (CEST) Received: by po14934vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 9287E6CF2D; Fri, 4 May 2018 14:33:56 +0200 (CEST) Message-Id: <6bfe791e70143f22b3868c9c8c60237de120931e.1525435203.git.christophe.leroy@c-s.fr> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH 03/17] powerpc/nohash: use IS_ENABLED() to simplify __set_pte_at() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , aneesh.kumar@linux.vnet.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 4 May 2018 14:33:56 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By using IS_ENABLED() we can simplify __set_pte_at() by removing redundant *ptep = pte Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/nohash/pgtable.h | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h index f2fe3cbe90af..077472640b35 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -148,40 +148,33 @@ extern void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte, int percpu) { -#if defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT) /* Second case is 32-bit with 64-bit PTE. In this case, we * can just store as long as we do the two halves in the right order * with a barrier in between. * In the percpu case, we also fallback to the simple update */ - if (percpu) { - *ptep = pte; + if (IS_ENABLED(CONFIG_PPC32) && IS_ENABLED(CONFIG_PTE_64BIT) && !percpu) { + __asm__ __volatile__("\ + stw%U0%X0 %2,%0\n\ + eieio\n\ + stw%U0%X0 %L2,%1" + : "=m" (*ptep), "=m" (*((unsigned char *)ptep+4)) + : "r" (pte) : "memory"); return; } - __asm__ __volatile__("\ - stw%U0%X0 %2,%0\n\ - eieio\n\ - stw%U0%X0 %L2,%1" - : "=m" (*ptep), "=m" (*((unsigned char *)ptep+4)) - : "r" (pte) : "memory"); - -#else /* Anything else just stores the PTE normally. That covers all 64-bit * cases, and 32-bit non-hash with 32-bit PTEs. */ *ptep = pte; -#ifdef CONFIG_PPC_BOOK3E_64 /* * With hardware tablewalk, a sync is needed to ensure that * subsequent accesses see the PTE we just wrote. Unlike userspace * mappings, we can't tolerate spurious faults, so make sure * the new PTE will be seen the first time. */ - if (is_kernel_addr(addr)) + if (IS_ENABLED(CONFIG_PPC_BOOK3E_64) && is_kernel_addr(addr)) mb(); -#endif -#endif } -- 2.13.3