[LTP] [PATCH v3] memory: rewrite memcg_stress_test into C API

Michal Koutný mkoutny@suse.com
Wed Nov 12 15:40:55 CET 2025


On Tue, Nov 11, 2025 at 02:46:23PM +0100, Andrea Cervesato <andrea.cervesato@suse.de> wrote:
> +	for (int i = 0; i < iter_per_cgroup; i++) {
> +		while (!*cgroups_avail)
> +			sched_yield();

BTW this pattern looks like a custom semaphore (initialized to
parallelism level, IIUC you picked cgroups_num).

> +static void run(void)
> +{
> +	struct tst_cg_group *cg_child[cgroups_num];
> +	pid_t child_pid;
> +
> +	for (int i = 0; i < cgroups_num; i++) {
> +		cg_child[i] = tst_cg_group_mk(tst_cg, "ltp_memcg_stress_%d", i);
> +
> +		child_pid = SAFE_FORK();
> +		if (!child_pid) {
> +			run_child(cg_child[i]);
> +			exit(0);
> +		}
> +	}
> +
> +	tst_reap_children();
> +
> +	for (int i = 0; i < cgroups_num; i++)
> +		cg_child[i] = tst_cg_group_rm(cg_child[i]);
> +

Would it make sense to drop_caches and calculate mem_avail like in the
beginning and expect the value shouldn't be smaller?

This would assume this LTP test runs alone and it would check that
nothing leaked. Thus the test would have at least some assert :-)

Michal


More information about the ltp mailing list