From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (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 82A23492184 for ; Fri, 6 Mar 2026 21:09:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772831362; cv=none; b=s1TSBhcDFHE+QUcaD6uBtjmnBTrQaTXRRJ1Gc+saSiCttvOypvzxD/Dq+qI8gAKn7cYcQKhOsUa1AuP9jSjpJ5PpBOueMkIfd76XE4kyaVGKspLvdDji5V4bUUn64xs1+ezk5U7LiokG7ULGcRXj9NFMf97vxFS0934WcGqtmDk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772831362; c=relaxed/simple; bh=JDdLDrRCDTZBKVmw3n5NK786r0Eg5MDC/uY74iYc2mo=; h=Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From: References:In-Reply-To; b=lOSEnrej/20fX+Np6xAOGErxRiVC5aXB4CXRROV+/w3jbbjIIousLtoe/fkmwgqRoY4V+gTwdnw0qQc3q1tjI8QhirQbPwglzYt2Cu41jtNPtZiPDRnFeQm09ofjgBjGJCWFMJzNDnQzJJlagFSW+lkQKBaXUGpihNTt++MpuMs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20230601.gappssmtp.com header.i=@etsalapatis-com.20230601.gappssmtp.com header.b=jH6E5Gvy; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20230601.gappssmtp.com header.i=@etsalapatis-com.20230601.gappssmtp.com header.b="jH6E5Gvy" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-508fe217a44so4649411cf.2 for ; Fri, 06 Mar 2026 13:09:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20230601.gappssmtp.com; s=20230601; t=1772831355; x=1773436155; darn=vger.kernel.org; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=D8PaeZhBJKFwWcc3eumfEq1eMgqmDoF5z6N5AUW84Qs=; b=jH6E5GvyL50s0+DjM1TrOStbg+z/FgzNPJysGrRerE/2qoq6/gJprODEhiIs76KMOG HHEA8gmy9u26V7omik9ne6KmSYtPCoAmGbRQ7euwRDrT/QWDV4y0YbYO3GjNipOCIhf/ PPU49AY7gP7bTU52hC/UYpZdvjLAmQAdQAKUIhA0Y/F9jOFcYD/Kew/t2GP11d+2JJAv vRAeiGfNr2uI/EvLflj8aZ9kFBuD+e+L97AKC2F2z4DCZDmnD+n/ne/fRUJu/lK/bGtW aleQ+EbpkrjxkCYoy71Ud8tIizADB1+tvOGlV9/Bc7LNTTNntYPK7jKeeB1YWddN/coV C/JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772831355; x=1773436155; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=D8PaeZhBJKFwWcc3eumfEq1eMgqmDoF5z6N5AUW84Qs=; b=Tm3viRU0L4gBjpHFZNocKkIlPocsRn9Fl5lf+x/wHWroLyD3j07vddkYFv/aM1190W cMB63tZQ8Y3I4TSRijawS8/x3UGG3r3GMAYhv4nZBfpR/cfU3o5MGZHy+1QaRY6jgzHW UchfM1wFrLfIiZVAhRjycWi4b3fFNXfHznnDkjH54unbGlBTx197FBO9l9UWQFb6sQk9 J9dixiLSWpmKASPW/v7jYB/bMlHo+FszeCJNJe5bhP0NIenXwIU5ekehNp4RYPbi3Sad LjzfqjCmuGHFkEAqOicWtF/4C2qKJhjgDbaOqTXvsX9YGO9E16KpfCiU1lpzP7y+XMzA tvPg== X-Forwarded-Encrypted: i=1; AJvYcCUx7FnaezxaN2oo+8XjW06Jtn4aaJgbQIsdjcE5cpGxNsGGfVhke7cVtvBXRhYvooh/8G8DNaKd8dJD4lA=@vger.kernel.org X-Gm-Message-State: AOJu0YzUlm0GP8QR/hgGHTeotFQzCr4ltO4ak6TgFc0s05CCY+Y2X0rp r0TXCx6+fH2K8316f6wFlOjuy00/W5RnXrRnR7IqqaXDrZvhWiuEJMQMQwhWRTw7rYo= X-Gm-Gg: ATEYQzxio/Sn0t+Tbut3U58YSTeTIT5uySRhZKyBFrtoC3MrwhCAl43fVXbDp3FpxxM Tgk8x41ggo2RReZbkCXytWP0rJsOGwkU2mwzIkpsiSzaxHHGXJvKnWvhdmWtEOLBB++AWcABxFD QdnDgtr7YnnV6r5YRaxIXjCDpbFvA7gD4byEQqyNEKN2a3k+d90G7PPIbzfzp8VhbEDi2/ZpcmW kZx6xajiii2cE9TinzNcGMWlofzL6r1NQXmTuN93wH8K6LHi0j6z1MlQslne3txckN3x3UdZR/t c8TGUYokWWPWWCcMhv/CK+qWlpyet4xVpJUkM6Q94RuGvq/PISAiLtRTHfRuHDJjAgettpqNgfK ILqIZpmlpvRuIsIvDtT3Z7/2UZUI7SZrLJDeJAtu/7jmtLSBaD6vfYkVfqHEwZWDLP391d0JOHO VOe8Ir4f9g8ql/UMESvC84ghg= X-Received: by 2002:a05:622a:1ba3:b0:504:3c8f:f9bf with SMTP id d75a77b69052e-508f49697c4mr45505741cf.74.1772831355211; Fri, 06 Mar 2026 13:09:15 -0800 (PST) Received: from localhost ([140.174.219.137]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89a316da913sm24965146d6.29.2026.03.06.13.09.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Mar 2026 13:09:14 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 06 Mar 2026 16:09:13 -0500 Message-Id: To: "Tejun Heo" , , Cc: , , Subject: Re: [PATCH 05/15] sched_ext: Relocate reenq_local() and run_deferred() From: "Emil Tsalapatis" X-Mailer: aerc 0.20.1 References: <20260306190623.1076074-1-tj@kernel.org> <20260306190623.1076074-6-tj@kernel.org> In-Reply-To: <20260306190623.1076074-6-tj@kernel.org> On Fri Mar 6, 2026 at 2:06 PM EST, Tejun Heo wrote: > Previously, both process_ddsp_deferred_locals() and reenq_local() require= d > forward declarations. Reorganize so that only run_deferred() needs to be > declared. This reduces forward declaration clutter and will ease adding m= ore > to the run_deferred() path. > > No functional changes. > > Signed-off-by: Tejun Heo Reviewed-by: Emil Tsalapatis > --- > kernel/sched/ext.c | 132 ++++++++++++++++++++++----------------------- > 1 file changed, 65 insertions(+), 67 deletions(-) > > diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c > index c44893878878..1b6cd1e4f8b9 100644 > --- a/kernel/sched/ext.c > +++ b/kernel/sched/ext.c > @@ -193,9 +193,8 @@ MODULE_PARM_DESC(bypass_lb_intv_us, "bypass load bala= nce interval in microsecond > #define CREATE_TRACE_POINTS > #include > =20 > -static void process_ddsp_deferred_locals(struct rq *rq); > +static void run_deferred(struct rq *rq); > static bool task_dead_and_done(struct task_struct *p); > -static u32 reenq_local(struct scx_sched *sch, struct rq *rq); > static void scx_kick_cpu(struct scx_sched *sch, s32 cpu, u64 flags); > static void scx_disable(struct scx_sched *sch, enum scx_exit_kind kind); > static bool scx_vexit(struct scx_sched *sch, enum scx_exit_kind kind, > @@ -1003,23 +1002,6 @@ static int ops_sanitize_err(struct scx_sched *sch,= const char *ops_name, s32 err > return -EPROTO; > } > =20 > -static void run_deferred(struct rq *rq) > -{ > - process_ddsp_deferred_locals(rq); > - > - if (!llist_empty(&rq->scx.deferred_reenq_locals)) { > - struct llist_node *llist =3D > - llist_del_all(&rq->scx.deferred_reenq_locals); > - struct scx_sched_pcpu *pos, *next; > - > - llist_for_each_entry_safe(pos, next, llist, > - deferred_reenq_locals_node) { > - init_llist_node(&pos->deferred_reenq_locals_node); > - reenq_local(pos->sch, rq); > - } > - } > -} > - > static void deferred_bal_cb_workfn(struct rq *rq) > { > run_deferred(rq); > @@ -3072,7 +3054,6 @@ static void rq_offline_scx(struct rq *rq) > rq->scx.flags &=3D ~SCX_RQ_ONLINE; > } > =20 > - > static bool check_rq_for_timeouts(struct rq *rq) > { > struct scx_sched *sch; > @@ -3612,6 +3593,70 @@ int scx_check_setscheduler(struct task_struct *p, = int policy) > return 0; > } > =20 > +static u32 reenq_local(struct scx_sched *sch, struct rq *rq) > +{ > + LIST_HEAD(tasks); > + u32 nr_enqueued =3D 0; > + struct task_struct *p, *n; > + > + lockdep_assert_rq_held(rq); > + > + /* > + * The BPF scheduler may choose to dispatch tasks back to > + * @rq->scx.local_dsq. Move all candidate tasks off to a private list > + * first to avoid processing the same tasks repeatedly. > + */ > + list_for_each_entry_safe(p, n, &rq->scx.local_dsq.list, > + scx.dsq_list.node) { > + struct scx_sched *task_sch =3D scx_task_sched(p); > + > + /* > + * If @p is being migrated, @p's current CPU may not agree with > + * its allowed CPUs and the migration_cpu_stop is about to > + * deactivate and re-activate @p anyway. Skip re-enqueueing. > + * > + * While racing sched property changes may also dequeue and > + * re-enqueue a migrating task while its current CPU and allowed > + * CPUs disagree, they use %ENQUEUE_RESTORE which is bypassed to > + * the current local DSQ for running tasks and thus are not > + * visible to the BPF scheduler. > + */ > + if (p->migration_pending) > + continue; > + > + if (!scx_is_descendant(task_sch, sch)) > + continue; > + > + dispatch_dequeue(rq, p); > + list_add_tail(&p->scx.dsq_list.node, &tasks); > + } > + > + list_for_each_entry_safe(p, n, &tasks, scx.dsq_list.node) { > + list_del_init(&p->scx.dsq_list.node); > + do_enqueue_task(rq, p, SCX_ENQ_REENQ, -1); > + nr_enqueued++; > + } > + > + return nr_enqueued; > +} > + > +static void run_deferred(struct rq *rq) > +{ > + process_ddsp_deferred_locals(rq); > + > + if (!llist_empty(&rq->scx.deferred_reenq_locals)) { > + struct llist_node *llist =3D > + llist_del_all(&rq->scx.deferred_reenq_locals); > + struct scx_sched_pcpu *pos, *next; > + > + llist_for_each_entry_safe(pos, next, llist, > + deferred_reenq_locals_node) { > + init_llist_node(&pos->deferred_reenq_locals_node); > + reenq_local(pos->sch, rq); > + } > + } > +} > + > #ifdef CONFIG_NO_HZ_FULL > bool scx_can_stop_tick(struct rq *rq) > { > @@ -7702,53 +7747,6 @@ static const struct btf_kfunc_id_set scx_kfunc_set= _dispatch =3D { > .set =3D &scx_kfunc_ids_dispatch, > }; > =20 > -static u32 reenq_local(struct scx_sched *sch, struct rq *rq) > -{ > - LIST_HEAD(tasks); > - u32 nr_enqueued =3D 0; > - struct task_struct *p, *n; > - > - lockdep_assert_rq_held(rq); > - > - /* > - * The BPF scheduler may choose to dispatch tasks back to > - * @rq->scx.local_dsq. Move all candidate tasks off to a private list > - * first to avoid processing the same tasks repeatedly. > - */ > - list_for_each_entry_safe(p, n, &rq->scx.local_dsq.list, > - scx.dsq_list.node) { > - struct scx_sched *task_sch =3D scx_task_sched(p); > - > - /* > - * If @p is being migrated, @p's current CPU may not agree with > - * its allowed CPUs and the migration_cpu_stop is about to > - * deactivate and re-activate @p anyway. Skip re-enqueueing. > - * > - * While racing sched property changes may also dequeue and > - * re-enqueue a migrating task while its current CPU and allowed > - * CPUs disagree, they use %ENQUEUE_RESTORE which is bypassed to > - * the current local DSQ for running tasks and thus are not > - * visible to the BPF scheduler. > - */ > - if (p->migration_pending) > - continue; > - > - if (!scx_is_descendant(task_sch, sch)) > - continue; > - > - dispatch_dequeue(rq, p); > - list_add_tail(&p->scx.dsq_list.node, &tasks); > - } > - > - list_for_each_entry_safe(p, n, &tasks, scx.dsq_list.node) { > - list_del_init(&p->scx.dsq_list.node); > - do_enqueue_task(rq, p, SCX_ENQ_REENQ, -1); > - nr_enqueued++; > - } > - > - return nr_enqueued; > -} > - > __bpf_kfunc_start_defs(); > =20 > /**