Re: [PATCH] accel/rocket: Parallelize independent jobs across cores
From: Gyeyoung Baek
Date: Sun Dec 06 2026 - 03:34:38 EST
Hi Philipp, Tvrtko,
Before answering inline, here is how I see the problem. Please correct
me where I'm wrong.
In short: the entity-to-scheduler step has drm_sched_pick_best(),
and I think the job-to-entity step needs the same kind of selection.
1. Why this need is new
- GPUs so far: the hardware spreads the workload of one job over its
cores, or firmware assigns the jobs. So the software abstraction
could be as simple as one FIFO per client (the entity) feeding one
scheduler.
- NPUs like rocket: there are N cores and nothing in front of them
that distributes jobs. One job runs on one core. So software has to
spread the jobs of one client over the N cores, and one FIFO can't
do that.
2. What follows from an entity being a FIFO
The jobs of one entity run one after the other. For example, 3
independent jobs in one entity still run one at a time, even with 3
idle cores.
-> One entity per core is needed, because jobs that should run in
parallel must be in different entities.
-> Each job then needs an entity picked for it. pick_best() can't do
this: it attaches an entity to a scheduler, and putting a job into
an entity happens before that.
-> The entity-to-scheduler mapping can then be fixed 1:1. Once the jobs
are spread over the entities, what runs in parallel is decided, and
nothing is left to pick.
Tvrtko, you suggested giving all schedulers to all entities and letting
drm_sched_pick_best() spread them.
The above is why I kept them fixed instead.
On Thu, Dec 3, 2026 at 6:09 PM Philipp Stanner <phasta@xxxxxxxxxxx> wrote:
> On Thu, 2026-12-03 at 13:12 +0900, Gyeyoung Baek wrote:
> > > > In general, the problem with why a single entity does not work really is
> > > > that drm_sched_entity_select_rq() has this artificial coupling
> > > > preventing run queue / scheduler changes while there are queued or
> > > > active jobs in the entity. In the ideal world it should work.
> > >
> > > Scratch this, I got confused due context switching. One entity shouldn't
> > > execute in parallel to itself is fundamental.
> >
> > Yes. So an entity alone can't run jobs that don't depend on each other
> > concurrently on the cores of hardware like rocket.
> >
> > I think drm_sched needs a new queue object, separate from the entity,
> > that orders jobs only by their dependencies:
> >
> > - An entity orders its jobs in two ways:
> > 1. the dependency fences of each job
> > 2. the order in which the jobs were queued
>
> I don't think that's a formally correct description. jobs within an
> entity are always ordered as FIFO, hence point 2 from your list.
>
> Dependency fences merely determine which entity is runnable.
Right, I was wrong. The dependency fences only decide whether the head
job can go, and the order is FIFO only. The summary above starts from
this.
> >
> > - The problem is 2. Because of it, a job waits for the job queued before
> > it even without a dependency, so rocket had to work around it with one
> > entity per core.
>
> Can you elaborate a bit more how your hardware works. So what other
> drivers call their ring, for you consists of multiple cores, and each
> core can process 1 job in parallel?
To be exact, there is one ring (drm_gpu_scheduler) per core.
A core runs one job at a time, and the cores run in parallel.
No hardware or firmware in front of the cores distributes jobs.
> If my description above is correct, then it would seem that having one
> entity per core is the right thing to do. Or do they then not match the
> user(space) queues?
Agreed, one entity per core is right.
They don't match the userspace queues 1:1. rocket has no queue object;
one fd is one submission path. That leaves two ways to spread the jobs
over the entities:
1. Expose one queue per core to userspace, and userspace picks a queue
for each job.
2. Userspace submits to one path, and the kernel spreads the jobs.
The problem with 1 is that userspace can't know which core is idle. The
cores are shared by several processes, and only the kernel sees all of
the load.
So I think 2 is the right abstraction: userspace only submits jobs, and
the kernel decides which core runs them. The patch I sent does this.
> > - 1 can express 2: if each job depends on the previous one, we get 2.
> > So an interface that orders jobs by 1 alone is the more general one.
> >
> > I also think drm_sched should provide this, as other multi-core
> > accelerators need the same (e.g. the thames driver). I only did it in
> > rocket to start small.
> >
> > Please let me know if I got anything wrong so far. Otherwise I'll send
> > an RFC.
>
> drm_sched is unfortunately not a very stable code base, so if we can
> avoid a big rework completely re-conceptualizing the concept of an
> entity, that would be kind of nice :(
Agreed, I don't want to touch entities or run-queues.
What I have in mind now is a small layer on top of entities,
which holds one entity per core and picks one for each job.
To sum up:
the patch I sent implements the job-to-entity selection inside rocket.
Other N-core hardware with nothing distributing jobs
needs the same logic, so I think it is better placed in drm_sched.
If nothing above is wrong, I'll send an RFC in this direction.
--
Thanks,
Gyeyoung