From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (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 2A0FD3EBF2C for ; Fri, 6 Mar 2026 21:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772831165; cv=none; b=rC7UIQjdY0Sx/G7WTNQCXfC7wpX4KitJ57e7laR+S3qnhImfey0jZtfYPWKVmtbHe/j6/aQXnxTATU7wVpngNZ6Fb+gT14HeirHAGgf6BVITbsGfe2UvJKGnXbhF8cqVS5YwXcoxd2VPOio6X4qD7YqL/cXM9JZFZybJv1UDHIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772831165; c=relaxed/simple; bh=aKeJ+jYVnSc6aUnP88KbsRy2JyOR0iRgjAr+Ltsv00Y=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=t0J+0iHv61T5csDCxWUGUzQPrQ1L2of73Pfa6ITPO7ZybgDZcUM075m/M3w+DYRhujr551ZOSivty5uWcoJBZpeqgv5o2UXUSdfF60DbGBGSynx9p5r5yo/z0HSWUmqS7lISRna1pVyq2uXgcsmCmf/ckZalHFKZI9xWpGW8O54= 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=qlhnv+sK; arc=none smtp.client-ip=209.85.160.177 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="qlhnv+sK" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-50335b926c2so87651671cf.2 for ; Fri, 06 Mar 2026 13:06:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20230601.gappssmtp.com; s=20230601; t=1772831163; x=1773435963; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=k8AhaB/v+2orrJY8LzngoycEWy1G/a6AEmgCr67UnpM=; b=qlhnv+sKjbaFwZlLl0NxuZ70lBo/pSZBXivPvDsK8aQPFysmkYQwTvYs8Tr0XY05HL 05NONozNUQnq3QxKHi4/0Ij26GlVZLgLlMhIwY+/QETxfHgHc9Kja2EtW2CYjgtOEaFO xRng/XA02WX0FbT7Z2ioTDli75g0ruqTzwSI+fRU1+8XcrkZk7fn6MqevpNBefAxlOE7 +/bo5sR+JT1HcqqSG/M5DD9EC7vWz83yIqTqSBJBSxll9X6YpPBVHssRyT4KBjj6eoln n2q/x9zpPtZyENaHxHtsgZzmA4V5Uh5wMhJBg2EUM3oxCAYwG8ijLtfkVfDudD2gwHra s29w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772831163; x=1773435963; h=in-reply-to:references:to:from:subject:cc: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=k8AhaB/v+2orrJY8LzngoycEWy1G/a6AEmgCr67UnpM=; b=a8DHAwld2ZGhyRAW/VwMci3GCUqVqO+AXE/40/icjbYVVifXVGgSBsemk/pAGHUNK7 q50nMB2jHGXQyrvr8n91hS0m6txxh0ftX76HgMZS2y0oqc7YUiEoBJbNdHnNSb/JC+bF DrVffnxqWbYCJaGZq5EfMBOJXGrHy3iOYxY+Gvgq2ljjPELFzXJNdav0fklfzZFm8ANj UKv7sVkP+u9FgHtXYNPqqwh+fabIrtZhm5P/SdflLv4jO9lNwD6rgMMXf3NKUrmx00vx hB4I1O/niku1jApxS0TsaKO38iW9iUvThVitbTezpBWTdMEI7Gt2i5+YTqSuvg4jgpvK nJAA== X-Forwarded-Encrypted: i=1; AJvYcCW8nvs5Ff3zI4rr143paStduBiSuEvYptlKJllDtbVvIbnUISPiUkZgn8mhKhyNotJMkzbuZNx6QcAyBzs=@vger.kernel.org X-Gm-Message-State: AOJu0Ywqm1WHkv1kSp+STcDTgHs89G0gZYKOJGZJjpVHhqqZkzjRodK/ v+mb+2XZ0MEqThFR49e/bNMlog8IDoNRQ6TJznYk0bJ06+NlnNE+EcIQEvTy/UFcex4= X-Gm-Gg: ATEYQzzuvYBX7iNSc8boE29rsVrZkLEtC4hT+B1VkllFRbPv72lZ8Gm8dgJFkLu5SET yD7krYuDw7i4zE4ERio6osMlYolDRdWxUlTh6FE/uWe4S0WapGCbC8CnHbqE1skrZdF/uBzuTDI k8p+YiJCv2MKJOjdDWY0E5wjRgZnSUtsLD/6jmETKrZevmuHYXrb+jimXsboyJo2sj31l+h/+No SStZE4KFwSQDqgTY0OOSsoNV8OLbVntOz+hoI/zCKeiaZENPh7mEcIiA7nDKHY0Wsd3y0xKGcxK TniFLZvg1zgYtCFpubmcWNrLDnROTFxtLIT54ml7l+0rbraNI+U377jW7vzcqyXRFBBMNvDKuMM 0NtoKC7VE1AIZFKPzwXW0/LSDsW6HAMWZpEi4Y04MnwQXbkc3RnC66t4v8UquGw0QUr5w4C+YJx 7BfRkCU/dTyoPOOlmWb6rB1PI= X-Received: by 2002:a05:622a:1aa1:b0:4e8:baad:9875 with SMTP id d75a77b69052e-508f46c84a0mr48281651cf.4.1772831162900; Fri, 06 Mar 2026 13:06:02 -0800 (PST) Received: from localhost ([140.174.219.137]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-508f6695738sm20402271cf.16.2026.03.06.13.06.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 06 Mar 2026 13:06:02 -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:06:01 -0500 Message-Id: Cc: , , Subject: Re: [PATCH 04/15] sched_ext: Change find_global_dsq() to take CPU number instead of task From: "Emil Tsalapatis" To: "Tejun Heo" , , X-Mailer: aerc 0.20.1 References: <20260306190623.1076074-1-tj@kernel.org> <20260306190623.1076074-5-tj@kernel.org> In-Reply-To: <20260306190623.1076074-5-tj@kernel.org> On Fri Mar 6, 2026 at 2:06 PM EST, Tejun Heo wrote: > Change find_global_dsq() to take a CPU number directly instead of a task > pointer. This prepares for callers where the CPU is available but the tas= k is > not. > > No functional changes. > > Signed-off-by: Tejun Heo Reviewed-by: Emil Tsalapatis > --- > kernel/sched/ext.c | 32 +++++++++++++++----------------- > 1 file changed, 15 insertions(+), 17 deletions(-) > > diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c > index c36d399bca3e..c44893878878 100644 > --- a/kernel/sched/ext.c > +++ b/kernel/sched/ext.c > @@ -341,10 +341,9 @@ static bool scx_is_descendant(struct scx_sched *sch,= struct scx_sched *ancestor) > for ((pos) =3D scx_next_descendant_pre(NULL, (root)); (pos); \ > (pos) =3D scx_next_descendant_pre((pos), (root))) > =20 > -static struct scx_dispatch_q *find_global_dsq(struct scx_sched *sch, > - struct task_struct *p) > +static struct scx_dispatch_q *find_global_dsq(struct scx_sched *sch, s32= tcpu) Nit: Maybe rename tcpu to cpu? It's only a task's CPU because we currently = use it that way, and the name is no longer obvious. > { > - return &sch->pnode[cpu_to_node(task_cpu(p))]->global_dsq; > + return &sch->pnode[cpu_to_node(tcpu)]->global_dsq; > } > =20 > static struct scx_dispatch_q *find_user_dsq(struct scx_sched *sch, u64 d= sq_id) > @@ -1266,7 +1265,7 @@ static void dispatch_enqueue(struct scx_sched *sch,= struct rq *rq, > scx_error(sch, "attempting to dispatch to a destroyed dsq"); > /* fall back to the global dsq */ > raw_spin_unlock(&dsq->lock); > - dsq =3D find_global_dsq(sch, p); > + dsq =3D find_global_dsq(sch, task_cpu(p)); > raw_spin_lock(&dsq->lock); > } > } > @@ -1474,7 +1473,7 @@ static void dispatch_dequeue_locked(struct task_str= uct *p, > =20 > static struct scx_dispatch_q *find_dsq_for_dispatch(struct scx_sched *sc= h, > struct rq *rq, u64 dsq_id, > - struct task_struct *p) > + s32 tcpu) > { > struct scx_dispatch_q *dsq; > =20 > @@ -1485,20 +1484,19 @@ static struct scx_dispatch_q *find_dsq_for_dispat= ch(struct scx_sched *sch, > s32 cpu =3D dsq_id & SCX_DSQ_LOCAL_CPU_MASK; > =20 > if (!ops_cpu_valid(sch, cpu, "in SCX_DSQ_LOCAL_ON dispatch verdict")) > - return find_global_dsq(sch, p); > + return find_global_dsq(sch, tcpu); > =20 > return &cpu_rq(cpu)->scx.local_dsq; > } > =20 > if (dsq_id =3D=3D SCX_DSQ_GLOBAL) > - dsq =3D find_global_dsq(sch, p); > + dsq =3D find_global_dsq(sch, tcpu); > else > dsq =3D find_user_dsq(sch, dsq_id); > =20 > if (unlikely(!dsq)) { > - scx_error(sch, "non-existent DSQ 0x%llx for %s[%d]", > - dsq_id, p->comm, p->pid); > - return find_global_dsq(sch, p); > + scx_error(sch, "non-existent DSQ 0x%llx", dsq_id); > + return find_global_dsq(sch, tcpu); > } > =20 > return dsq; > @@ -1540,7 +1538,7 @@ static void direct_dispatch(struct scx_sched *sch, = struct task_struct *p, > { > struct rq *rq =3D task_rq(p); > struct scx_dispatch_q *dsq =3D > - find_dsq_for_dispatch(sch, rq, p->scx.ddsp_dsq_id, p); > + find_dsq_for_dispatch(sch, rq, p->scx.ddsp_dsq_id, task_cpu(p)); > =20 > touch_core_sched_dispatch(rq, p); > =20 > @@ -1683,7 +1681,7 @@ static void do_enqueue_task(struct rq *rq, struct t= ask_struct *p, u64 enq_flags, > dsq =3D &rq->scx.local_dsq; > goto enqueue; > global: > - dsq =3D find_global_dsq(sch, p); > + dsq =3D find_global_dsq(sch, task_cpu(p)); > goto enqueue; > bypass: > dsq =3D bypass_enq_target_dsq(sch, task_cpu(p)); > @@ -2140,7 +2138,7 @@ static struct rq *move_task_between_dsqs(struct scx= _sched *sch, > dst_rq =3D container_of(dst_dsq, struct rq, scx.local_dsq); > if (src_rq !=3D dst_rq && > unlikely(!task_can_run_on_remote_rq(sch, p, dst_rq, true))) { > - dst_dsq =3D find_global_dsq(sch, p); > + dst_dsq =3D find_global_dsq(sch, task_cpu(p)); > dst_rq =3D src_rq; > } > } else { > @@ -2269,7 +2267,7 @@ static void dispatch_to_local_dsq(struct scx_sched = *sch, struct rq *rq, > =20 > if (src_rq !=3D dst_rq && > unlikely(!task_can_run_on_remote_rq(sch, p, dst_rq, true))) { > - dispatch_enqueue(sch, rq, find_global_dsq(sch, p), p, > + dispatch_enqueue(sch, rq, find_global_dsq(sch, task_cpu(p)), p, > enq_flags | SCX_ENQ_CLEAR_OPSS); > return; > } > @@ -2407,7 +2405,7 @@ static void finish_dispatch(struct scx_sched *sch, = struct rq *rq, > =20 > BUG_ON(!(p->scx.flags & SCX_TASK_QUEUED)); > =20 > - dsq =3D find_dsq_for_dispatch(sch, this_rq(), dsq_id, p); > + dsq =3D find_dsq_for_dispatch(sch, this_rq(), dsq_id, task_cpu(p)); > =20 > if (dsq->id =3D=3D SCX_DSQ_LOCAL) > dispatch_to_local_dsq(sch, rq, dsq, p, enq_flags); > @@ -2647,7 +2645,7 @@ static void process_ddsp_deferred_locals(struct rq = *rq) > =20 > list_del_init(&p->scx.dsq_list.node); > =20 > - dsq =3D find_dsq_for_dispatch(sch, rq, p->scx.ddsp_dsq_id, p); > + dsq =3D find_dsq_for_dispatch(sch, rq, p->scx.ddsp_dsq_id, task_cpu(p)= ); > if (!WARN_ON_ONCE(dsq->id !=3D SCX_DSQ_LOCAL)) > dispatch_to_local_dsq(sch, rq, dsq, p, > p->scx.ddsp_enq_flags); > @@ -7410,7 +7408,7 @@ static bool scx_dsq_move(struct bpf_iter_scx_dsq_ke= rn *kit, > } > =20 > /* @p is still on $src_dsq and stable, determine the destination */ > - dst_dsq =3D find_dsq_for_dispatch(sch, this_rq, dsq_id, p); > + dst_dsq =3D find_dsq_for_dispatch(sch, this_rq, dsq_id, task_cpu(p)); > =20 > /* > * Apply vtime and slice updates before moving so that the new time is