All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kuba Piecuch" <jpiecuch@google.com>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 1/3] selftests/sched_ext: Add a test for ops.dequeue() on remote local DSQ moves
Date: Tue, 29 Sep 2026 16:28:03 +0000	[thread overview]
Message-ID: <20260929162803.B33D01F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929161730.185271-2-jpiecuch@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/sched_ext: leaked bpf_link FD on error path blocks subsequent tests
--

commit 1ccbec9969985b2fbfb40e59807388cd3896b3e6
Author: Kuba Piecuch <jpiecuch@google.com>
Subject: selftests/sched_ext: Add a test for ops.dequeue() on remote local DSQ moves

When a BPF scheduler moves a task that is in its custody to the local DSQ
of a CPU other than the one whose rq the task is on, sched_ext migrates the
task with move_remote_task_to_local_dsq(). The task leaves the BPF
scheduler's custody when it is inserted into the destination local DSQ and
ops.dequeue() should be called at that point, just like for same-rq
dispatches.

> diff --git a/tools/testing/selftests/sched_ext/dequeue_remote.c b/tools/testing/selftests/sched_ext/dequeue_remote.c
> new file mode 100644
> index 0000000000000..ab42ac694ac6b
> --- /dev/null
> +++ b/tools/testing/selftests/sched_ext/dequeue_remote.c
[ ... ]
> +static enum scx_test_status run_scenario(struct dequeue_remote *skel,
> +					 bool use_move_to_local,
> +					 const char *name)
> +{
> +	struct bpf_link *link;
> +	pid_t pids[MAX_WORKERS];
> +	int nr_workers, i, status;
> +	u64 enq, deq, dsp_deq, chg_deq, remote_dsp, remote_run;
[ ... ]
> +	link = bpf_map__attach_struct_ops(skel->maps.dequeue_remote_ops);
> +	SCX_FAIL_IF(!link, "Failed to attach struct_ops for %s", name);
> +
> +	fflush(stdout);
> +	fflush(stderr);
> +
> +	for (i = 0; i < nr_workers; i++) {
> +		pids[i] = fork();
> +		SCX_FAIL_IF(pids[i] < 0, "Failed to fork worker %d", i);

[Severity: Medium]
If fork() fails here, SCX_FAIL_IF() will return immediately. Does this leak
the bpf_link in the runner process?

Since link is stored in a local variable, it won't be freed by the test
framework's cleanup() callback. If leaked, this would leave the scheduler
attached, causing subsequent tests to fail with -EBUSY because only one
sched_ext scheduler can be active at a time.

> +		if (pids[i] == 0)
> +			worker_fn(i);
> +	}
> +
> +	for (i = 0; i < nr_workers; i++) {
> +		SCX_FAIL_IF(waitpid(pids[i], &status, 0) != pids[i],
> +			    "Failed to wait for worker %d", i);
> +		SCX_FAIL_IF(status != 0, "Worker %d exited with status %d", i, status);

[Severity: Medium]
Similarly, if waitpid() fails or a worker exits with a non-zero status, the
early return will skip bpf_link__destroy(link).

Could the test be updated to use a goto cleanup path, or perhaps assign the
link to the skeleton so it is destroyed automatically, ensuring it doesn't
block subsequent tests on error?

> +	}
> +
> +	bpf_link__destroy(link);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260929161730.185271-1-jpiecuch@google.com?part=1

  reply	other threads:[~2026-09-29 16:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 16:17 [PATCHSET sched_ext/for-7.3-fixes] sched_ext: Fix missing ops.dequeue() on remote local DSQ moves Kuba Piecuch
2026-09-29 16:17 ` [PATCH 1/3] selftests/sched_ext: Add a test for " Kuba Piecuch
2026-09-29 16:28   ` sashiko-bot [this message]
2026-09-30 11:50     ` Kuba Piecuch
2026-09-29 18:42   ` Andrea Righi
2026-09-30 11:50     ` Kuba Piecuch
2026-09-29 16:17 ` [PATCH 2/3] sched_ext: Call ops.dequeue() when a task arrives on a remote local DSQ Kuba Piecuch
2026-09-29 18:33   ` Andrea Righi
2026-09-30 11:50     ` Kuba Piecuch
2026-09-29 16:17 ` [PATCH 3/3] selftests/sched_ext: Enable the dequeue_remote test Kuba Piecuch
2026-09-29 17:13 ` [PATCHSET sched_ext/for-7.3-fixes] sched_ext: Fix missing ops.dequeue() on remote local DSQ moves Tejun Heo
2026-09-29 18:30   ` Andrea Righi
2026-09-30 11:50   ` Kuba Piecuch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929162803.B33D01F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jpiecuch@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sched-ext@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.