mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: cui.tao@linux.dev,tj@kernel.org,josef@toxicopanda.com,axboe@kernel.dk,ast@kernel.org,alexei.starovoitov@gmail.com
Cc: cgroups@vger.kernel.org,linux-block@vger.kernel.org,linux-kernel@vger.kernel.org,bpf@vger.kernel.org,andrii@kernel.org,eddyz87@gmail.com,daniel@iogearbox.net,linux-kselftest@vger.kernel.org,cui.tao@linux.dev,cuitao@kylinos.cn,ameryhung@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [RFC PATCH v14 3/4] selftests/bpf: add iocost cost model test
Date: Wed, 18 Nov 2026 13:49:04 +0000 (UTC)	[thread overview]
Message-ID: <59496aca38bf7cf3d4d3e11d5ac32e144ae92bf9fa8b3d2420ae65464fea51df@mail.kernel.org> (raw)
In-Reply-To: <20261118131029.797007-4-cui.tao@linux.dev>

[-- Attachment #1: Type: text/plain, Size: 3374 bytes --]

> selftests/bpf: add iocost cost model test

TL;DR: In the iocost selftest, the setns() unwind on the skip path may reset
test_progs' cwd to "/" (and possibly leave a chroot), so later unrelated tests
could fail with -ENOENT when null_blk is unavailable.

> diff --git a/tools/testing/selftests/bpf/prog_tests/iocost_model.c b/tools/testing/selftests/bpf/prog_tests/iocost_model.c
> new file mode 100644
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/iocost_model.c

[ ... ]

> +static bool iocost_test_env(void)
> +{

[ ... ]

> +	/*
> +	 * Isolate the configfs and cgroup mounts from the host. A
> +	 * failed setup unwinds the namespace so that a later retry does
> +	 * not stack private namespaces.
> +	 */
> +	orig_ns = open("/proc/self/ns/mnt", O_RDONLY);
> +	if (unshare(CLONE_NEWNS) ||
> +	    mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) {
> +		printf("%s:SKIP:cannot make mounts private: %s\n",
> +		       __func__, strerror(errno));
> +		test__skip();
> +		goto out;
> +	}
> +	mkdir("/sys/kernel/config", 0755);
> +	(void)mount("none", "/sys/kernel/config", "configfs", 0, NULL);
> +	SYS_NOFAIL("modprobe null_blk nr_devices=0");
> +	if (access("/sys/kernel/config/nullb", W_OK)) {
> +		printf("%s:SKIP:needs null_blk with configfs support\n",
> +		       __func__);
> +		test__skip();
> +		goto out;
> +	}
> +
> +	ready = true;
> +	ok = true;
> +
> +out:
> +	if (orig_ns >= 0) {
> +		if (!ok)
> +			setns(orig_ns, CLONE_NEWNS);
> +		close(orig_ns);
> +	}
> +	return ok;
> +}

When a prerequisite check fails after unshare(CLONE_NEWNS), for example
when access("/sys/kernel/config/nullb", W_OK) fails because null_blk is
not built, not installed, or modprobe is missing, this goes back with
setns(orig_ns, CLONE_NEWNS).

Can this change the cwd of the test_progs process?  mntns_install() in
fs/namespace.c ends with:

	/* Update the pwd and root */
	set_fs_pwd(fs, &root);
	set_fs_root(fs, &root);

unshare() keeps the cwd, so only this skip path moves the process to "/".

The serial tests run in the test_progs main process, so the new cwd
persists for every test that runs afterwards.  Many of those open objects
by cwd-relative path, for example serial_test_kfree_skb() loading
"./test_pkt_access.bpf.o", select_reuseport.c opening
"test_select_reuseport_kern.bpf.o", and l4lb_all.c using "test_l4lb.bpf.o".
The flavored runners also lose the chdir() done by cd_flavor_subdir().

So on a kernel with the iocost BPF support but no usable null_blk, would
the iocost tests report SKIP and then unrelated tests fail with -ENOENT?
If test_progs runs inside a chroot, does the root reset also leave the
chroot?

The comment says the unwind exists "so that a later retry does not stack
private namespaces", but serial_test_iocost_model() and
serial_test_iocost_model_streams() call cgroup_setup_and_join(), and
setup_cgroup_environment() calls unshare(CLONE_NEWNS) every time, so
namespaces stack regardless.

Would it work to drop the setns() unwind and cache the failure in a
static, or to save the cwd with open(".", O_RDONLY | O_DIRECTORY) before
unshare() and fchdir() back to it after setns()?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/44312765238

  reply	other threads:[~2026-11-18 13:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 13:10 [RFC PATCH v14 0/4] blk-iocost: BPF struct_ops cost model Tao Cui
2026-11-18 13:10 ` [RFC PATCH v14 1/4] blk-iocost: add BPF struct_ops cost model support Tao Cui
2026-11-18 13:10 ` [RFC PATCH v14 2/4] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Tao Cui
2026-11-18 13:49   ` bot+bpf-ci
2026-11-18 13:10 ` [RFC PATCH v14 3/4] selftests/bpf: add iocost cost model test Tao Cui
2026-11-18 13:49   ` bot+bpf-ci [this message]
2026-11-18 13:10 ` [RFC PATCH v14 4/4] docs: cgroup-v2: document the iocost BPF cost model attachment Tao Cui
2026-11-18 13:17 ` [RFC PATCH v14 0/4] blk-iocost: BPF struct_ops cost model Tao Cui

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=59496aca38bf7cf3d4d3e11d5ac32e144ae92bf9fa8b3d2420ae65464fea51df@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=cui.tao@linux.dev \
    --cc=cuitao@kylinos.cn \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=josef@toxicopanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=mason@kernel.org \
    --cc=tj@kernel.org \
    --cc=yonghong.song@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®