From patchwork Tue Mar 5 14:53:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yeo Reum Yun X-Patchwork-Id: 13582535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1B66C54E41 for ; Tue, 5 Mar 2024 14:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ip9e/De49X9XUvCa9nHLt/frz85BvSaU8cpTtPWflBk=; b=NcG1u2g1F8H2ZM 2ip+suwp16rYr8CCsDvAOAITLd5mXXiM00JUgf3jDhBf1PML2U9IwoGPeyDm43RHzEPHO4Xf/1oNK Uu0L+GcjQ/AClT6pkgmw+9BmfePPpW/PqIddk1Hn4fvd0UZSiVAFX5VvDRfFdbxqsEd0jv6GyElnZ rQQ1x8LXeR8wkdni7Tnkx6cmNT9PwiOhL+Ps1gnj5pmd1y9ODV2ohgkspJm/lguptE1ixUB+9qZhT VIUVh9BM4UZa3zr15KYX+w8k376aEuPkrRuTGcAY8ai6UN6mN0+UM0FaqXwyeVb25aoJKxcp9MSJ3 6gxGKREPKx4VYIcRSR7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhWBE-0000000E9M7-1WyF; Tue, 05 Mar 2024 14:54:08 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhWBA-0000000E9KH-2VwB for linux-arm-kernel@lists.infradead.org; Tue, 05 Mar 2024 14:54:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F3541FB; Tue, 5 Mar 2024 06:54:37 -0800 (PST) Received: from e129823.cambridge.arm.com (e129823.arm.com [10.1.197.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C47693F762; Tue, 5 Mar 2024 06:53:58 -0800 (PST) From: "levi.yun" To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, peterz@infradead.org, mathieu.desnoyers@efficios.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, nd@arm.com, "levi.yun" , stable@vger.kernel.org, Aaron Lu Subject: [PATCH] arm64/mm: Add memory barrier for mm_cid Date: Tue, 5 Mar 2024 14:53:35 +0000 Message-Id: <20240305145335.2696125-1-yeoreum.yun@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240305_065404_787697_E0F1AC5C X-CRM114-Status: GOOD ( 10.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently arm64's switch_mm() doesn't always have an smp_mb() which the core scheduler code has depended upon since commit: commit 223baf9d17f25 ("sched: Fix performance regression introduced by mm_cid") If switch_mm() doesn't call smp_mb(), sched_mm_cid_remote_clear() can unset the activly used cid when it fails to observe active task after it sets lazy_put. By adding an smp_mb() in arm64's check_and_switch_context(), Guarantee to observe active task after sched_mm_cid_remote_clear() success to set lazy_put. Signed-off-by: levi.yun Fixes: 223baf9d17f2 ("sched: Fix performance regression introduced by mm_cid") Cc: # 6.4.x Cc: Mathieu Desnoyers Cc: Catalin Marinas Cc: Mark Rutland Cc: Will Deacon Cc: Peter Zijlstra Cc: Aaron Lu --- I'm really sorry if you got this multiple times. I had some problems with the SMTP server... arch/arm64/mm/context.c | 5 +++++ 1 file changed, 5 insertions(+) -- LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7} diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index 188197590fc9..7a9e8e6647a0 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -268,6 +268,11 @@ void check_and_switch_context(struct mm_struct *mm) */ if (!system_uses_ttbr0_pan()) cpu_switch_mm(mm->pgd, mm); + + /* + * See the comments on switch_mm_cid describing user -> user transition. + */ + smp_mb(); } unsigned long arm64_mm_context_get(struct mm_struct *mm)