Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3752843pxv; Mon, 5 Jul 2021 05:02:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCsfctqGe5e0EkoS8nI5YFdoYIO/UcP+Fa4TiFo+0mXgEaMrxEuFs5/UbZeGbcPzHezivP X-Received: by 2002:a5d:8c9a:: with SMTP id g26mr3360424ion.121.1625486532644; Mon, 05 Jul 2021 05:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625486532; cv=none; d=google.com; s=arc-20160816; b=Mr/IClW/b1SQC9GGCbqboGf5YR+hIcbj/6REwxtqVN1ZvaQzsiNcUyfj461/hr/2te Db4NCd2bUqx4jgUrDn6M3B2SnVNYMaKb8NMDiOJqWQOpZuYZA7vTt8K4NyBXsRCxW3tC OVtCs712DpjXpZ4MY0/rjEVbiORv52Rk/chhwmGCII3Ikm8l+Ox9yOvu4aWqMY3UGE++ QWQq9tX/aCfo13MALKJ6UGxZ6PGL3GSMZoPGQhJT4EguriNNgalyARJCmncSCw6aQg7N cAwJuwAs4P+pIfnfx6wn4tA7aHiQfGZzRuu6WNqtUp8OfJ7IUPIRbDpWVOKZOZKoeCtm eNzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=uVJKuq3KfBulc7nd0GqwP5KQIiNYCyOOy2W0i9Pbl84=; b=lhn7z/ujA55OCtrnxxKuEIh7HC9tiaNIxyiHgeV5K0fTZ7hz+qK4p5mV9YD4WEOikm V7HtJZ9iQfQ9Pk+4OByLuJtxFIQB47T6dxPlESpVwq/Zep2yWUbxb0Acdptom+v4AsJm QuI6qRCCbZpB+gSgDEXVlbIA9gKeT/MmieeLBeI13xTem4VBxv+fxBmVSiLivVCxfNll wKcMicKvJUUilfRSYe0VtHtKDt8n9329NfzxTdiS9O2XJKkNu7YP+jr0+PivCpu1Sawp JbN+/pn4b7MJeGlrfqBa+M9lnKsWQD9ieSBO3RxDKfqDjPVoC1r/sLcUG29tmnuCo9Ws IAnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si16070086jav.18.2021.07.05.05.02.01; Mon, 05 Jul 2021 05:02:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231240AbhGEMD5 (ORCPT + 99 others); Mon, 5 Jul 2021 08:03:57 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:6498 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbhGEMD5 (ORCPT ); Mon, 5 Jul 2021 08:03:57 -0400 Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4GJPRM0sMxzB7Q1; Mon, 5 Jul 2021 14:01:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S1KocAW6MyJi; Mon, 5 Jul 2021 14:01:19 +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 4GJPQq3k1hzB5YS; Mon, 5 Jul 2021 14:00:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 7552C8B786; Mon, 5 Jul 2021 14:00:51 +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 gAnyppKZ_Q8D; Mon, 5 Jul 2021 14:00:51 +0200 (CEST) Received: from po9473vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.103]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 431C48B763; Mon, 5 Jul 2021 14:00:51 +0200 (CEST) Received: by po9473vm.idsi0.si.c-s.fr (Postfix, from userid 0) id C4FB6663AC; Mon, 5 Jul 2021 12:00:50 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH] powerpc/non-smp: Inconditionaly call smp_mb() on switch_mm To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 5 Jul 2021 12:00:50 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 3ccfebedd8cf ("powerpc, membarrier: Skip memory barrier in switch_mm()") added some logic to skip the smp_mb() in switch_mm_irqs_off() before the call to switch_mmu_context(). However, on non SMP smp_mb() is just a compiler barrier and doing it inconditionaly is simpler than the logic used to check whether the barrier is needed or not. After the patch: 00000000 : ... c: 7c 04 18 40 cmplw r4,r3 10: 81 24 00 24 lwz r9,36(r4) 14: 91 25 04 c8 stw r9,1224(r5) 18: 4d 82 00 20 beqlr 1c: 48 00 00 00 b 1c 1c: R_PPC_REL24 switch_mmu_context Before the patch: 00000000 : ... c: 7c 04 18 40 cmplw r4,r3 10: 81 24 00 24 lwz r9,36(r4) 14: 91 25 04 c8 stw r9,1224(r5) 18: 4d 82 00 20 beqlr 1c: 81 24 00 28 lwz r9,40(r4) 20: 71 29 00 0a andi. r9,r9,10 24: 40 82 00 34 bne 58 28: 48 00 00 00 b 28 28: R_PPC_REL24 switch_mmu_context ... 58: 2c 03 00 00 cmpwi r3,0 5c: 41 82 ff cc beq 28 60: 48 00 00 00 b 60 60: R_PPC_REL24 switch_mmu_context Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/membarrier.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/membarrier.h b/arch/powerpc/include/asm/membarrier.h index 6e20bb5c74ea..de7f79157918 100644 --- a/arch/powerpc/include/asm/membarrier.h +++ b/arch/powerpc/include/asm/membarrier.h @@ -12,7 +12,8 @@ static inline void membarrier_arch_switch_mm(struct mm_struct *prev, * when switching from userspace to kernel is not needed after * store to rq->curr. */ - if (likely(!(atomic_read(&next->membarrier_state) & + if (IS_ENABLED(CONFIG_SMP) && + likely(!(atomic_read(&next->membarrier_state) & (MEMBARRIER_STATE_PRIVATE_EXPEDITED | MEMBARRIER_STATE_GLOBAL_EXPEDITED)) || !prev)) return; -- 2.25.0