diff options
| author | Waiman Long <longman@redhat.com> | 2026-07-02 17:47:51 -0400 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2026-07-06 14:51:01 -1000 |
| commit | e165f243fecce67898eaf986b3e768936ae4be8c (patch) | |
| tree | d4c9a4696dc26a6ea8606423ffca34d108b1a39e /kernel/cgroup | |
| parent | 892b8bb3fb7c0a96f294fc8b34e4477f51c90ab0 (diff) | |
| download | lwn-e165f243fecce67898eaf986b3e768936ae4be8c.tar.gz lwn-e165f243fecce67898eaf986b3e768936ae4be8c.zip | |
cgroup/cpuset: Add a cpuset_reserve_dl_bw() helper
Extract the DL bandwidth allocation code in cpuset_attach() to a new
cpuset_reserve_dl_bw() helper to simplify code.
No functional change is expected.
Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Ridong Chen <ridong.chen@linux.dev>
Reviewed-by: Gregory Price <gourry@gourry.net>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup')
| -rw-r--r-- | kernel/cgroup/cpuset.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 8dbbac8a66fd..33a6f932249e 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3031,6 +3031,25 @@ static int cpuset_can_attach_check(struct cpuset *cs) return 0; } +static int cpuset_reserve_dl_bw(struct cpuset *cs) +{ + int cpu, ret; + + if (!cs->sum_migrate_dl_bw) + return 0; + + cpu = cpumask_any_and(cpu_active_mask, cs->effective_cpus); + if (unlikely(cpu >= nr_cpu_ids)) + return -EINVAL; + + ret = dl_bw_alloc(cpu, cs->sum_migrate_dl_bw); + if (ret) + return ret; + + cs->dl_bw_cpu = cpu; + return 0; +} + static void reset_migrate_dl_data(struct cpuset *cs) { cs->nr_migrate_dl_tasks = 0; @@ -3045,7 +3064,7 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) struct cpuset *cs, *oldcs; struct task_struct *task; bool setsched_check; - int cpu, ret; + int ret; /* used later by cpuset_attach() */ attach_ctx.old_cs = task_cs(cgroup_taskset_first(tset, &css)); @@ -3101,27 +3120,14 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) } } - if (!cs->sum_migrate_dl_bw) - goto out_success; - - cpu = cpumask_any_and(cpu_active_mask, cs->effective_cpus); - if (unlikely(cpu >= nr_cpu_ids)) { - ret = -EINVAL; - goto out_unlock; - } - - ret = dl_bw_alloc(cpu, cs->sum_migrate_dl_bw); - if (ret) - goto out_unlock; - - cs->dl_bw_cpu = cpu; - -out_success: - attach_ctx.in_progress++; + ret = cpuset_reserve_dl_bw(cs); out_unlock: if (ret) reset_migrate_dl_data(cs); + else + attach_ctx.in_progress++; + mutex_unlock(&cpuset_mutex); return ret; } |
