Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

scx: cgroup: Fix mismatch between ops.cgroup_prep_move() and ops.cgroup_move() invocations #165

Merged
merged 2 commits into from
Mar 19, 2024

Conversation

htejun
Copy link
Collaborator

@htejun htejun commented Mar 19, 2024

We want each successful ops.cgroup_prep_move() invocation to be always paired with an invocation of either ops.cgroup_move() or ops.cgroup_cancel_move(). However, this doesn't always hold because sched_move_task() implicitly ignores identity migrations skipping ops.cgroup_move() invocations. This lead to #164. Let's fix it by making scx_cgroup_can_attach() skip ops.cgroup_prep_move() calls on identity migrations.

…dly NULL

Make the sanity check a bit more concise and ensure that ops.cgroup_move()
is never called with NULL source cgroup.
…ugh ops.cgroup_prep_move()

sched_move_task() takes an early exit if the source and destination are
identical. This triggers the warning in scx_cgroup_can_attach() as it leaves
p->scx.cgrp_moving_from uncleared.

Update the cgroup migration path so that ops.cgroup_prep_move() is skipped
for identity migrations so that its invocations always match
ops.cgroup_move() one-to-one.
@htejun htejun requested a review from Byte-Lab March 19, 2024 06:26
@htejun htejun merged commit fc86083 into sched_ext Mar 19, 2024
1 check passed
@htejun htejun deleted the htejun branch March 19, 2024 15:38
htejun pushed a commit that referenced this pull request Mar 29, 2024
Add a cgroup bpf program test where the bpf program is running
in a pid namespace. The test is successfully:
  #165/3   ns_current_pid_tgid/new_ns_cgrp:OK

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240315184910.2976522-1-yonghong.song@linux.dev
htejun pushed a commit that referenced this pull request Mar 29, 2024
Add a sk_msg bpf program test where the program is running in a pid
namespace. The test is successful:
  #165/4   ns_current_pid_tgid/new_ns_sk_msg:OK

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240315184915.2976718-1-yonghong.song@linux.dev
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant