Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp450886lqs; Tue, 5 Mar 2024 06:54:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW0PJ/Z+DrV614iXQApFWplUvHdYshG2hKFazZU/wHizmGUa2PCqPaC8z71PvtVyDlVOxjPSVHhJUdGsIk+9WWjjHttkONwlNLOvAL1AQ== X-Google-Smtp-Source: AGHT+IGdEojC3a0GSGVMD/t2fWNQLdWxUTR5dALcSrpueng4hed5+n5N0XSpRCWtbQKM8gogSDPx X-Received: by 2002:a05:6358:8a2:b0:17b:5712:70f2 with SMTP id m34-20020a05635808a200b0017b571270f2mr1791838rwj.11.1709650465312; Tue, 05 Mar 2024 06:54:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709650465; cv=pass; d=google.com; s=arc-20160816; b=DZmCh7iqFOkih2z/vEmMoOCnIdkfNNPY9fp+XMc8XzBFpdYrHkH/9PECCcNfXtQDP7 HkvovMfbuh70H0y1jvyqQubsY+0JyZY1BvHig5Vq/AWMDvCwKXXeIAGgCsb6GU+79dIm no23XRc/N5tZG2OXF/A4ZbiDZNDLr9b0X4+F0Pegu1azUma2rWwVHspMENDwvqYPKtLy zgBiiYbmjmByfYD/thagJeEwfE0Zxeprc9KKYQQyCep2TLHzcSsxo9Btc0+BRPEA+aNN OWLDFWxLnRs32uvTMFMRZIjj00c1Cu7yJCGAKp0yQ7/77FdOOCVAIjCiPGGD2EDGW7YJ PWlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=o23JO6tbts9tKWDSK9w1mtUnxhLE5OH7y3Ju6Ri3PP8=; fh=ZebJ5ACT5VRTvZwjYNlHU0kA13XboFKuoDseTcHQo24=; b=gvNbn8B4z5bGeuA/4LwQ+gzVJ4QQVilfaFwNVafLv+Kddcn9OJhKbMFJW/DQdnJ4/g YCIi/VMdVZlQq/K3AnhNFPbqTFGXDdr0y9FKNbeCFz1RIrzjnCFRLgckk+ou9l+rDRkn bHK5TqwwsjNUsy5uEyS8rVnkvcLldBOY257CsScQC7xoIpfIYCRgmD51+nfaaTKZcvNL i7I/WRm9/9llQFY1c1b0llY7MoR6wunwUNFovAdoJihvzB6w2BMPVXUmyPxNuCAmbRHR TSzZL/mVyBvvfxyO31/w4EbZmLNXtgsX+eRrmV5XZHmnCyKdLn8FyrtBR8uFr+o7q42b 8V3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-92549-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92549-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 12-20020a05621420ec00b00690191023c1si12583903qvk.561.2024.03.05.06.54.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 06:54:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92549-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-92549-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92549-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0BBF51C20B09 for ; Tue, 5 Mar 2024 14:54:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D2231272A4; Tue, 5 Mar 2024 14:54:03 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECC4D6127; Tue, 5 Mar 2024 14:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709650442; cv=none; b=e2BuvSi8DpyEdrUgsPyNzYRRmQAStvYFLCJuAmOiGDx2pJJSkgzCnWBuX9Nk14Qher3X242wMOf20a1UC6psVC1foQ6sCZNHTNiJnvAxPzOnOPSPOf/6m8IrRUYRJujlA293B5lnB82hViXdIoOHIKFUXrUDkuFrC91O3OoBvkg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709650442; c=relaxed/simple; bh=RIA85WUsvoaR0l2yajYG2tSdVf08/i/yUJ9xFRgITs8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=rFSh7Ut1DzGGyauojKimplDnkvHTwSHRNuuzpVQJk508AzNwyfKt5gFsjcS0XBR5in8N9rlnehHaCj2bEG5oBEOXXDtyFh4gNbmMSIvpsO2XlEElN9if/V4vBsRjyN4nr22APU2e/1pUsht6JzoI00gKe2GTrkLjP4rwk55IM6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(+) 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) -- LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}