From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010052.outbound.protection.outlook.com [52.101.85.52]) (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 EFB7B2F2914 for ; Sun, 15 Mar 2026 16:27:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.52 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773592036; cv=fail; b=HWibbIeO5YDgJY9h8d0FsKKLyWAvgL4Ax0FFhyBb3RGSMCNALzaj8HYqVCYgNOfPOtNCozPsffWXtWX6PyTfusdxmXDNultutMi95havZv/h29WJQHPxoLttiidw51YmxlCgeoq5Rl97B/OGOLENhSiE9ETt1ic6LRT7v1NTc8Y= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773592036; c=relaxed/simple; bh=JvRvgz+vQI/zLfuKiltlM8xkWSd2xlymxp94u5JgoMs=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=QbT5Ynjjh+2ZI82LuPXjpAR6EHZkI5ZRIzGjH/JIkxBApI2L4Kb0wBwg2qIqnnXKJbp3dyLMwShnwsEKTmeWAzTqQztyZsC5QS1FdccxoLLtuq/hPaX/DdKRGnL7DT1RelhyYlInTQPQF5XjoZWqCCQ2tx7YlkV9PNtBVVIEiCk= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=EgzPVa4/; arc=fail smtp.client-ip=52.101.85.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="EgzPVa4/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g/awPjAoSzi/CZmhYXlEa+vgjvXKLXc4dQ/mptVSs8BE1f3mTdOuM23tMxhaAnckH7l3PiZ+IQBX6095GdjDs8hX3kGzz1yLe4JXUCt2yvWYn/zQvzaLHjpnwe81buINPZmse5HSSDlBU6XhERKFRUOxnUMPVnv2FJiR93LC3la3l9dG3mTpLXWigI6CJvXmWBGXyBbwM8ZmyxAJDZcYYAp0DBVHYitXtI2HoctZqfepxh4+IarZ+Ry1Ca1tA6GcZrKQL+Jd0LFVFc7Nfs4raDH49N7r81WZohNhIWzYlS2LRBInNfBQCC5Ves0qeErMqSRMv//ZdVvhj0l81iag8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n0hQmJuFmuDCmzwdK4w/MUG0EBMLS1Fy6z+rQ2bcIDA=; b=HWp+ah1i81h63B0nzaK6BIu4nGnXkOAAztMKzR7fdL4Mk0/l1nUj55O9oAjc8rTDJHXV8sc05lpuULVJ/aXhs0Y8m75YdhyD+zNLuh+4KYXxHwxHnLug97BgC1SxcxIdPTLU3hXfc7sOAczc9zUqsRWk/SyC/RQq8Ct3sM4nqVlCB7j3goS5kQiyswIsgauNu8ySmf9L7vJAhngURbs6/f1UpaG4RbEnq+bzLwccG+VuwAqb2q1scEMrPJc9Ti/uybZeN+1cOjKlk+a8yKWVyKVN2zpQLA7fJT24q2WoOrOI0bBNORuOfZ1D8okyGy83gc8qEiVM6w6vpafrYiNzpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n0hQmJuFmuDCmzwdK4w/MUG0EBMLS1Fy6z+rQ2bcIDA=; b=EgzPVa4/rdOLKsp2UXBMM5t8eve9SvOTGqEQKkoSVZimjSOvUqEpjb5IXaVfrejbA8r36+X6UMCniAWQT/XkXy+jxC+4BeL9q4wh2zPymSd3hJftN01ECbzTTZ1dFR/E//AlRdCQnPaQrlXzufpCQ2n6cBTIo1fm3T4D4QcX1fU= Received: from BY5PR03CA0014.namprd03.prod.outlook.com (2603:10b6:a03:1e0::24) by BL3PR12MB6427.namprd12.prod.outlook.com (2603:10b6:208:3b6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9723.13; Sun, 15 Mar 2026 16:27:10 +0000 Received: from SJ5PEPF000001D3.namprd05.prod.outlook.com (2603:10b6:a03:1e0:cafe::6b) by BY5PR03CA0014.outlook.office365.com (2603:10b6:a03:1e0::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9700.17 via Frontend Transport; Sun, 15 Mar 2026 16:27:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by SJ5PEPF000001D3.mail.protection.outlook.com (10.167.242.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.17 via Frontend Transport; Sun, 15 Mar 2026 16:27:10 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Sun, 15 Mar 2026 11:27:09 -0500 Received: from [172.31.184.125] (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.17 via Frontend Transport; Sun, 15 Mar 2026 11:27:02 -0500 Message-ID: <20ea3670-c30a-433b-a07f-c4ff98ae2379@amd.com> Date: Sun, 15 Mar 2026 21:56:56 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v25 1/9] sched: Make class_schedulers avoid pushing current, and get rid of proxy_tag_curr() To: John Stultz , LKML CC: Peter Zijlstra , Joel Fernandes , Qais Yousef , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Mel Gorman , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Metin Kaya , Xuewen Yan , Thomas Gleixner , Daniel Lezcano , Suleiman Souhlal , kuyo chang , hupu , References: <20260313023022.2902479-1-jstultz@google.com> <20260313023022.2902479-2-jstultz@google.com> Content-Language: en-US From: K Prateek Nayak In-Reply-To: <20260313023022.2902479-2-jstultz@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D3:EE_|BL3PR12MB6427:EE_ X-MS-Office365-Filtering-Correlation-Id: c4c799e2-e136-4ec8-49b5-08de82afb524 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|376014|7416014|82310400026|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: Qk2oMiiJB8O7KFwtBe7/aPqtLS9I7ETqUUA4n402EYle3f0MBhxTYCTzLcuUHMoy/8QvZlmUfwEA+hXrlpRx58m/2lVA6exczGIqQNimOPqaA8+Y20GVTlJFFD9vSdL4GqqDXob1e/IiGWlhEXtBKYHEDnk8xuZu18xlnuemZRCbNaDGvT3LFJ20AgZ2coIM1MMfPQBYo+6iR5zzMACoJ7pb14V1n3EbNVkS8nkwOo6LYnt4frlZ4h8MMcmfBUUP9uIkEUhVn9BHxlMDOYqYkgie4Lenv5ZRlTmo+xr2BXb/iPA0H+zR3vVi2jk7PirkGRIY/kTMl9VQGCEf2qPF2IlThHHf0H/SrEf72IXWh1OSN8yLqKKXO7PR85GWYEP+MHgwCYDt05Ra9xw854VSlWGM28oCPLHd1FcULcZvpVnbAshjmodlGFERQCu4rw09YxDxvZlFUkbz64n4L/xMxHJLn1aotqBYwq7RW0XB6ejS9G3j68FauI18JPsc+Wtr0Gl1H4hcUNBjGkpWlvIAB/mcljgRJOjqErt+yNQsLBZ8W2FwxUKZoWCxndOEfhVkOSBxujUGZ9cw/kzJwl6FFNLYzZRIk8jIjRwomrKbfX1TL4mFGA9MWv0MU45CBSxSFrus74DW2CIv3mePYAvVew3AQNawaAap5O7o3vlu0i1yHLgwPnS6roWET1hMJHeReX3gTpiJ5lc090zUncSk4JQwEtdtnmLAwSKSx0mr19+5qfmC/5L4QEpYNLCYyKJruuEyFGJOOyPeKDjPVrmVmA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700016)(376014)(7416014)(82310400026)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E5JFhDc4fUz8PWoipU5LLrGiF67tJLzQ6xRedtiUyNfXbFRw4S4yVqoeuWnh+ek09F89b6DkcGo4gBEuu6HM7XtLsckfTnMUVipy2fhAoLAT3Oc4+E2tDBaOVJ1J2OGdB4tGe45r73forAkd6nkgZBF2UC3fSPdW2NmtDmbXiOboHn7uueWaRceCFqX7JYP/ucvQqZmZ5xeWZvHJMkebrKoLXq3FFeHltVWUxBYBpjx/EtfVCZJw3iS8K9UWloAj31f9beIZ7FWDoy58ZyTfgmKZTx3PUGj50SmiwPUTFDH7YevDJstOJe2VDWgIfO3IvAXqbVRwal8fE1ntXnrdVOl5zXS2058HvrVlDXwenHUsi31LP8uB3o0B/awZkn4K0g0qD3+qx4w9X5Tva8gHJeTIas0SkwuFcXHDPM1YgPvXTndTqxB70thJGpAhC4+A X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2026 16:27:10.2386 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4c799e2-e136-4ec8-49b5-08de82afb524 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001D3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6427 Hello John, On 3/13/2026 8:00 AM, John Stultz wrote: > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index b7f77c165a6e0..d86d648a75a4b 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -6702,23 +6702,6 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf) > } > #endif /* SCHED_PROXY_EXEC */ > > -static inline void proxy_tag_curr(struct rq *rq, struct task_struct *owner) > -{ > - if (!sched_proxy_exec()) > - return; > - /* > - * pick_next_task() calls set_next_task() on the chosen task > - * at some point, which ensures it is not push/pullable. > - * However, the chosen/donor task *and* the mutex owner form an > - * atomic pair wrt push/pull. > - * > - * Make sure owner we run is not pushable. Unfortunately we can > - * only deal with that by means of a dequeue/enqueue cycle. :-/ > - */ > - dequeue_task(rq, owner, DEQUEUE_NOCLOCK | DEQUEUE_SAVE); > - enqueue_task(rq, owner, ENQUEUE_NOCLOCK | ENQUEUE_RESTORE); > -} > - > /* > * __schedule() is the main scheduler function. > * > @@ -6871,9 +6854,6 @@ static void __sched notrace __schedule(int sched_mode) > */ > RCU_INIT_POINTER(rq->curr, next); > > - if (!task_current_donor(rq, next)) > - proxy_tag_curr(rq, next); > - Back to my concern with the queuing of the balance_callback, and the deadline and RT folks can keep me honest here, consider the following: CPU0 ==== ======> Task A (prio: 80) ... mutex_lock(Mutex0) ... /* Executing critical section. */ =====> Interrupt: Wakes up Task B (prio: 50); B->blocked_on = Mutex0; resched_curr() <===== Interrupt return preempt_schedule_irq() schedule() put_prev_set_next_Task(A, B) rq->donor = B if (task_is_blocked(B) next = find_proxy_task() /* Return Task A */ rq->curr = A queue_balance_callback() do_balance_callbacks() /* Finds A as task_on_cpu(); Does nothing. */ ... /* returns from schedule */ ... /* continues with critical section */ mutex_unlock(Mutex0) mutex_handoff(B /* Task B */) preempt_disable() try_to_wake_up() resched_curr() preempt_enable() preempt_schedule() proxy_force_return() /* Returns to same CPU */ /* * put_prev_set_next_task() is skipped since * rq->donor context is same. no balance * callbacks are queued. Task A still on the * push list. */ rq->donor = B rq->curr = B =======> sched_out: Task A !!! No balance callback; Task A still on push list. !!! <======= sched_in: Task B So what I'm getting to is, if we find that rq->donor has not changed with sched_proxy_exec() but rq->curr has changed during schedule(), we should forcefully do a: prev->sched_class->put_prev_task(rq, rq->donor, rq->donor /* or rq->idle / NULL ? */); next->sched_class->set_next_task(rq, rq->donor, true /* to queue balance callback. */); That way, when we do set_nex_task(), we see if we potentially have tasks in the push list and queue a balance callback since the task_on_cpu() condition may no longer apply to the tasks left behind on the list. Thoughts? > /* > * The membarrier system call requires each architecture > * to have a full memory barrier after updating > @@ -6907,10 +6887,6 @@ static void __sched notrace __schedule(int sched_mode) > /* Also unlocks the rq: */ > rq = context_switch(rq, prev, next, &rf); > } else { > - /* In case next was already curr but just got blocked_donor */ > - if (!task_current_donor(rq, next)) > - proxy_tag_curr(rq, next); > - > rq_unpin_lock(rq, &rf); > __balance_callbacks(rq, NULL); > raw_spin_rq_unlock_irq(rq); -- Thanks and Regards, Prateek