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 8A10E2D3725 for ; Mon, 2 Feb 2026 09:39:54 +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=1770025194; cv=none; b=QjMkEQXzlcP7wxLNpD7R5Fk9vxW3ZpQ9h+zQisAeWvx0jsQm2bOGLJgwwX+KY20O38UnZiYtln8hBjKyjPIvzFOt6EUrRmc+MGriQA35VeUjEo0dAA5isMMGfpNtASk0Pzerls25DXX2wgwIFe+XRgExu7ZedEARi6w8AGpaWXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770025194; c=relaxed/simple; bh=1qMXS1lTHVhEjKe2gUTcfNgDs7eSzWmWTicVP6Mg384=; h=Date:Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=XbAtNIPSw1dHKWJ0Eomj5cefpSkZbM6nQ5Lw/DFc/aUegoSRdBwYClxmsrkd6cL5OMDZMS51HFgZGddWespjqvnPSZSgi5eBtmIbXm7FyPTHCJUKSADfgwB7aA5rK3nlGW90aiOtopTrM54Dq6dNBhXhrEQAiCWLBo3i9Lj7P5I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M06u87Eu; 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="M06u87Eu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 767C5C116C6; Mon, 2 Feb 2026 09:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770025194; bh=1qMXS1lTHVhEjKe2gUTcfNgDs7eSzWmWTicVP6Mg384=; h=Date:From:To:Cc:Subject:References:From; b=M06u87EuB0tGI8ymNFdO+/5YKfiAghMmIUyaxpTW/Lb4Wd8CCHmcNmkvtC8oPSdVq WwUNHaQtYSds1qO1KSKnuRiL8YGtaqrKjz3MFxG9fElYJB41mgC2SXgngi/8rzQAQ3 5NU9rllcjLwyynWdQLizCMWckWhklOWEaJatSn5c13Ak3uMnyWC6iEv+eOUtiNiM7D aOyRGsGewGyKM4g4niNnS+r4NiJAbefKtn09Tx9TWaLE03R8fmS+nb73MmDGFujAyW E77JigNBzMpiBZgm/kXTEtVSqFQRMa7ACwvB9egwA1eWZQaKiv8BKZPdUJJJB7RF64 TRDnvi8Q1Njfw== Date: Mon, 02 Feb 2026 10:39:50 +0100 Message-ID: <20260201192835.032221009@kernel.org> User-Agent: quilt/0.68 From: Thomas Gleixner To: LKML Cc: Ihor Solodrai , Shrikanth Hegde , Peter Zijlstra , Mathieu Desnoyers , Michael Jeanson Subject: [patch V2 3/4] sched/mmcid: Drop per CPU CID immediately when switching to per task mode References: <20260201192234.380608594@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 When a exiting task initiates the switch from per CPU back to per task mode, it has already dropped its CID and marked itself inactive. But a leftover from an earlier iteration of the rework then reassigns the per CPU CID to the exiting task with the transition bit set. That's wrong as the task is already marked CID inactive, which means it is inconsistent state. It's harmless because the CID is marked in transit and therefore dropped back into the pool when the exiting task schedules out either through preemption or the final schedule(). Simply drop the per CPU CID when the exiting task triggered the transition. Fixes: fbd0e71dc370 ("sched/mmcid: Provide CID ownership mode fixup functions") Signed-off-by: Thomas Gleixner Reviewed-by: Mathieu Desnoyers --- kernel/sched/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -10727,8 +10727,14 @@ void sched_mm_cid_exit(struct task_struc scoped_guard(raw_spinlock_irq, &mm->mm_cid.lock) { if (!__sched_mm_cid_exit(t)) return; - /* Mode change required. Transfer currents CID */ - mm_cid_transit_to_task(current, this_cpu_ptr(mm->mm_cid.pcpu)); + /* + * Mode change. The task has the CID unset + * already. The CPU CID is still valid and + * does not have MM_CID_TRANSIT set as the + * mode change has just taken effect under + * mm::mm_cid::lock. Drop it. + */ + mm_drop_cid_on_cpu(mm, this_cpu_ptr(mm->mm_cid.pcpu)); } mm_cid_fixup_cpus_to_tasks(mm); return;