From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CB492EC560 for ; Fri, 30 Jan 2026 16:13:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769789610; cv=none; b=bZ5NomvNHgHUfEtiWNI1OrzC2yEwxMkvb6wyCNyJzhj8CFvFTAubW5E/OoeqZrSbdwY1OR0VN7txkAhnLunh/qphlD6eehSCqZmD+WX23HQv9hOD2mXSrG4IjwVeL9SrK3cggMNnlhMB+URe+Kb1FdXBtALTXCZIaRcpkYKs74E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769789610; c=relaxed/simple; bh=380kCpKnn396WuToLHd9vWVOOUUONx9mLqwKsS1nqJk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=d8S6d4GMUprsTWzCqpWOejNANn4Euzu1wOynJhH9t2TGjFqr1nZ0ojYaR8MNQgj5hIMdrFw1E2B4FjXmpl5AiOpYD/9VMfIxQmkOg0RkO66uk7m9SUQDcoI9L6e04iGfCvuh5SQ+Jo4QVCRv/hCtBTHnCeH7BSfrv1XoplWMhZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qdt33pL4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Qdt33pL4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F98EC4CEF7; Fri, 30 Jan 2026 16:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769789609; bh=380kCpKnn396WuToLHd9vWVOOUUONx9mLqwKsS1nqJk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Qdt33pL4JcR9Y8/fMQmQ0vPBErova8uHo+LS8IHzVYybFbfcsdRbm9d7g4C0kGvr4 mnPEPcZrI3XZLnvKOSf9O568JanuHx8x8a+USQevYnPZqi8ghog/G2nyl1bKAcQol3 0ciPADQG75lLDS9XB5d5zFL3Z2G0tYIIizh7Ycjxkrz3nNY7q089r+P+lcTk1RmP0+ at/tg3B2LO1RE25ip63hq/GTR3QAqyHEJE+FuS1VdXoUoGxglGqdXfvf011yzu6hHX i6ptg2pjaY4swV/yqlWz/ja1L4hbAhiBKQxmnFcuUYqDoQRyMxpC/hZFO5xSdUNXwi FHlL9hGeZK90w== From: Thomas Gleixner To: Mathieu Desnoyers , LKML Cc: Ihor Solodrai , Shrikanth Hegde , Peter Zijlstra , Michael Jeanson Subject: Re: [patch 4/4] sched/mmcid: Optimize transitional CIDs when scheduling out In-Reply-To: <50542cbe-8867-47fb-878e-0cff4b926eef@efficios.com> References: <20260129210219.452851594@kernel.org> <20260129211557.882759840@kernel.org> <50542cbe-8867-47fb-878e-0cff4b926eef@efficios.com> Date: Fri, 30 Jan 2026 17:13:26 +0100 Message-ID: <87343nkrix.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, Jan 30 2026 at 10:50, Mathieu Desnoyers wrote: > On 2026-01-29 16:20, Thomas Gleixner wrote: >> During the investigation of the various transition mode issues >> instrumentation revealed that the amount of bitmap operations can be >> significantly reduced when a task with a transitional CID schedules out >> after the fixup function completed and disabled the transition mode. >> >> At that point the mode is stable and therefore it is not required to drop >> the transitional CID back into the pool. As the fixup is complete the >> potential exhaustion of the CID pool is not longer possible, so the CID can >> be transferred to the scheduling out task or to the CPU depending on the >> current ownership mode. This is now possible because mm_cid::mode contains >> both the ownership state and the transition bit so the racy snapshot is >> valid under all circumstances because a subsequent modification of the >> mode is serialized by the corresponding runqueue lock. > > AFAIU the mc->mode updates are serialized by the mm->mm_cid.lock > and not the runqueue locks. What am I missing ? Actually the mode updates are serialized by the mutex. They happen under the lock as well, but the lock is not a serialization requirement for mode changes. What I meant to write with tired brain is: The racy snapshot is valid under runqueue lock even when there is a concurrent mode update going on because the subsequent fixup function is serialized with runqueue lock. That means in the following scenario: CPU0 CPU1 clear TRANSIT .... lock(rq) sched_out() CID has TRANSIT set ... // observes TRANSIT=0 localmode = READ_ONCE(...mode); // sets TRANSIT switch mode transfer CID according to localmode fixup() lock(rq) <- Blocked until the schedule on CPU1 is complete So both sched_out() and fixup() observe consistent state and everything just works. Thanks, tglx