From nobody Tue Dec 16 07:41:28 2025 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2989157480 for ; Sat, 6 Dec 2025 00:14:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764980103; cv=none; b=EsR1xJfXxYDxVFtONpdBmrqDTI1y9C5Ce7ZlHT8LBOMaN46CCnglPluH0hSunTtA/mHFAAmyK9JZLYuAIeinhEdkUl2iha1sDGnJDlQSTJHx8BAQnFH4E/FHECtzn4RFj2HDEb8BA3q3yzIIaoYG+/DZcqA7WpGLjqAEAPNJv7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764980103; c=relaxed/simple; bh=5WtD6k98BxZm1ugxEKncG6MTBPADYFrbytB4YGdeiB0=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=J/G8dhgbWGRWnWG0N57oitV5p+U1QnrFWLlbbeBlQEjLu+JRNj3QbMhLK6XWHJzoA/CqA42WLPqzgQH9VnE/ZoQ0nNDNpWfhOy6moS+G7ez06t9T1KQZmeiqcX4VPHwVmTdw7pPdab560TddQEwBs9W1VDYv4gv2/4cwurATDdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TwrvGb5C; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jstultz.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TwrvGb5C" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7b80de683efso4332167b3a.3 for ; Fri, 05 Dec 2025 16:14:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764980099; x=1765584899; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=o3cEtc6f0/lfF9FXuA+00G32aR06pcVYGdnh6khS/0c=; b=TwrvGb5CmBmKjlkdPvfxjMZIe3YqPuxy5sRYp9SqWOcvMJg3DeAjfWKScyS2V5zJg7 F7G2B4gSoUrve51638q0iMCobdLsFsCsCWXoxslZ2TMdaf5zMnXXwxlgkkN3qkfeG7DU TP7e8wN9L1eDyBEbA4ZLJrCF0Chhez0ZMWVMajL2wQIvxV3HP0oLOwpeS3nWjckotq/H zmBeF/AbofrK46yRd2I5+idESRzjp78y60AxlJhXZpnX2T7N/ehNCOR6y+QRZCWPumWB NceClobcE6imKd5bkc6XwsRJFbVHKCSokqD4j9eZGdUJ83VeMFxuddLTQV/TQX9tW2nq iR6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764980099; x=1765584899; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=o3cEtc6f0/lfF9FXuA+00G32aR06pcVYGdnh6khS/0c=; b=PFNtDtqhJJqsoy88NzKzuCb1IGgpN23Je7M+iPy1WPI1Ws02l/IUP00AOgWf33KD0U jhNlIiusck01OiLvx7/LYte3WhAq5Ux6grd43oZ6OkYwNhSQCrTLpHO3sCHKerVyATVS KV3MB1pT+p7p3HjQmOflYGrznIznnWQZBXyiem+210DeKCQ0neACJUZXFOtxR0SflYNp t3GxKSHyneDOuR1q4XCNw1dcAYLyDKWucjPNZD/QGRGm0L/9/2McPzTLgivBpXIdJcIZ RKUPI9b6tTggi9b0MibHma4MeCTeEfRWwyazuej3yTvphfIFH2ZMptMn8XWJkr3hLZAm QDRQ== X-Gm-Message-State: AOJu0YweKlAO6Y+k2+O1Xv5U1erlozRJqxULr/RUPF0elXUJ54qKPrrF 1Ad05mlVtAKLeoJyEL58ECiOmkmWx+esqDxcRVF+o+UAMLh8rzmXjiS2KtVMHbovEWSehpY3fk4 2GL/rbZ+C46z1b6JQ8i5XUsKCX4KQFIc1G4mPduy+awNoPm08lNMsf3qzeXN/RsRsw3C9mx+ark xo5+fM6fj1mT6f1Cxls3mG98DeMYI0yXHP9YIBT3TUEa8p9XrT X-Google-Smtp-Source: AGHT+IGrs2qWvcvxyvWaNiLVsxZBIvEtG/ed8axGpcta2J0frmLvOYGpO6eMaTfYs/IhnIUT/11156Kdav4t X-Received: from pfblu2.prod.google.com ([2002:a05:6a00:7482:b0:7ae:a150:ac8]) (user=jstultz job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:94c1:b0:7e8:450c:61cc with SMTP id d2e1a72fcca58-7e8c60de799mr778041b3a.60.1764980098770; Fri, 05 Dec 2025 16:14:58 -0800 (PST) Date: Sat, 6 Dec 2025 00:14:45 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.223.gf5cc29aaa4-goog Message-ID: <20251206001451.1418225-1-jstultz@google.com> Subject: [RFC][PATCH] sched/ext: Split curr|donor references properly From: John Stultz To: LKML Cc: John Stultz , Joel Fernandes , Qais Yousef , Ingo Molnar , Peter Zijlstra , 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 , K Prateek Nayak , Thomas Gleixner , Daniel Lezcano , Tejun Heo , David Vernet , Andrea Righi , Changwoo Min , sched-ext@lists.linux.dev, kernel-team@android.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With proxy-exec, we want to do the accounting against the donor most of the time. Without proxy-exec, there should be no difference as the rq->donor and rq->curr are the same. So rework the logic to reference the rq->donor where appropriate. Also add donor info to scx_dump_state() Since CONFIG_SCHED_PROXY_EXEC currently depends on !CONFIG_SCHED_CLASS_EXT, this should have no effect (other then the extra donor output in scx_dump_state), but this is one step needed to eventually remove that constraint for proxy-exec. Just wanted to send this out for early review prior to LPC. Feedback or thoughts would be greatly appreciated! Signed-off-by: John Stultz --- Cc: Joel Fernandes Cc: Qais Yousef Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Valentin Schneider Cc: Steven Rostedt Cc: Ben Segall Cc: Zimuzo Ezeozue Cc: Mel Gorman Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: "Paul E. McKenney" Cc: Metin Kaya Cc: Xuewen Yan Cc: K Prateek Nayak Cc: Thomas Gleixner Cc: Daniel Lezcano Cc: Tejun Heo Cc: David Vernet Cc: Andrea Righi Cc: Changwoo Min Cc: sched-ext@lists.linux.dev Cc: kernel-team@android.com --- kernel/sched/ext.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 05f5a49e9649a..446091cba4429 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -938,17 +938,17 @@ static void touch_core_sched_dispatch(struct rq *rq, = struct task_struct *p) =20 static void update_curr_scx(struct rq *rq) { - struct task_struct *curr =3D rq->curr; + struct task_struct *donor =3D rq->donor; s64 delta_exec; =20 delta_exec =3D update_curr_common(rq); if (unlikely(delta_exec <=3D 0)) return; =20 - if (curr->scx.slice !=3D SCX_SLICE_INF) { - curr->scx.slice -=3D min_t(u64, curr->scx.slice, delta_exec); - if (!curr->scx.slice) - touch_core_sched(rq, curr); + if (donor->scx.slice !=3D SCX_SLICE_INF) { + donor->scx.slice -=3D min_t(u64, donor->scx.slice, delta_exec); + if (!donor->scx.slice) + touch_core_sched(rq, donor); } } =20 @@ -1090,14 +1090,14 @@ static void dispatch_enqueue(struct scx_sched *sch,= struct scx_dispatch_q *dsq, struct rq *rq =3D container_of(dsq, struct rq, scx.local_dsq); bool preempt =3D false; =20 - if ((enq_flags & SCX_ENQ_PREEMPT) && p !=3D rq->curr && - rq->curr->sched_class =3D=3D &ext_sched_class) { - rq->curr->scx.slice =3D 0; + if ((enq_flags & SCX_ENQ_PREEMPT) && p !=3D rq->donor && + rq->donor->sched_class =3D=3D &ext_sched_class) { + rq->donor->scx.slice =3D 0; preempt =3D true; } =20 if (preempt || sched_class_above(&ext_sched_class, - rq->curr->sched_class)) + rq->donor->sched_class)) resched_curr(rq); } else { raw_spin_unlock(&dsq->lock); @@ -2001,7 +2001,7 @@ static void dispatch_to_local_dsq(struct scx_sched *s= ch, struct rq *rq, } =20 /* if the destination CPU is idle, wake it up */ - if (sched_class_above(p->sched_class, dst_rq->curr->sched_class)) + if (sched_class_above(p->sched_class, dst_rq->donor->sched_class)) resched_curr(dst_rq); } =20 @@ -2424,7 +2424,7 @@ static struct task_struct *first_local_task(struct rq= *rq) static struct task_struct * do_pick_task_scx(struct rq *rq, struct rq_flags *rf, bool force_scx) { - struct task_struct *prev =3D rq->curr; + struct task_struct *prev =3D rq->donor; bool keep_prev, kick_idle =3D false; struct task_struct *p; =20 @@ -3093,7 +3093,7 @@ int scx_check_setscheduler(struct task_struct *p, int= policy) #ifdef CONFIG_NO_HZ_FULL bool scx_can_stop_tick(struct rq *rq) { - struct task_struct *p =3D rq->curr; + struct task_struct *p =3D rq->donor; =20 if (scx_rq_bypassing(rq)) return false; @@ -4587,6 +4587,9 @@ static void scx_dump_state(struct scx_exit_info *ei, = size_t dump_len) dump_line(&ns, " curr=3D%s[%d] class=3D%ps", rq->curr->comm, rq->curr->pid, rq->curr->sched_class); + dump_line(&ns, " donor=3D%s[%d] class=3D%ps", + rq->donor->comm, rq->donor->pid, + rq->donor->sched_class); if (!cpumask_empty(rq->scx.cpus_to_kick)) dump_line(&ns, " cpus_to_kick : %*pb", cpumask_pr_args(rq->scx.cpus_to_kick)); @@ -5426,7 +5429,7 @@ static bool kick_one_cpu(s32 cpu, struct rq *this_rq,= unsigned long *ksyncs) unsigned long flags; =20 raw_spin_rq_lock_irqsave(rq, flags); - cur_class =3D rq->curr->sched_class; + cur_class =3D rq->donor->sched_class; =20 /* * During CPU hotplug, a CPU may depend on kicking itself to make @@ -5438,7 +5441,7 @@ static bool kick_one_cpu(s32 cpu, struct rq *this_rq,= unsigned long *ksyncs) !sched_class_above(cur_class, &ext_sched_class)) { if (cpumask_test_cpu(cpu, this_scx->cpus_to_preempt)) { if (cur_class =3D=3D &ext_sched_class) - rq->curr->scx.slice =3D 0; + rq->donor->scx.slice =3D 0; cpumask_clear_cpu(cpu, this_scx->cpus_to_preempt); } =20 --=20 2.52.0.223.gf5cc29aaa4-goog