The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tao Cui <cui.tao@linux.dev>
To: Shaojie Sun <sunshaojie@kylinos.cn>, mkoutny@suse.com
Cc: cui.tao@linux.dev, cgroups@vger.kernel.org, hannes@cmpxchg.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	shuah@kernel.org, tj@kernel.org
Subject: Re: [PATCH v2] selftests/cgroup: add user_usec sanity check in test_cpucg_nice
Date: Thu, 30 Jul 2026 22:55:41 +0800	[thread overview]
Message-ID: <23996589-fe21-4f39-bcbb-91eb1df56bd7@linux.dev> (raw)
In-Reply-To: <20260730130717.1236233-1-sunshaojie@kylinos.cn>



在 2026/7/30 21:07, Shaojie Sun 写道:
> In test_cpucg_nice, after the child process exits, user_usec is
> read from cpu.stat but the value is not checked. Add a sanity check
> to ensure user_usec > 0, analogous to test_cpucg_stats(), so that
> the test fails early if CPU usage wasn't properly accounted.
> 
> Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
> ---
> v2: Instead of simply removing the unused user_usec read, add a sanity
>     check (if user_usec <= 0, goto cleanup) analogous to test_cpucg_stats(),
>     as suggested by Michal.
> 
>  tools/testing/selftests/cgroup/test_cpu.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/cgroup/test_cpu.c b/tools/testing/selftests/cgroup/test_cpu.c
> index 7a40d76b9548..5a44705ed3fd 100644
> --- a/tools/testing/selftests/cgroup/test_cpu.c
> +++ b/tools/testing/selftests/cgroup/test_cpu.c
> @@ -291,6 +291,8 @@ static int test_cpucg_nice(const char *root)
>  
>  		user_usec = cg_read_key_long(cpucg, "cpu.stat", "user_usec");
>  		nice_usec = cg_read_key_long(cpucg, "cpu.stat", "nice_usec");
> +		if (user_usec <= 0)
> +			goto cleanup;
>  		if (!values_close_report(nice_usec, expected_nice_usec, 1))
>  			goto cleanup;
>  
Acked-by: Tao Cui <cuitao@kylinos.cn>


  reply	other threads:[~2026-07-30 14:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 10:04 [PATCH 0/2] selftests/cgroup: misc cleanups for test_cpu.c Shaojie Sun
2026-07-29 10:04 ` [PATCH 1/2] selftests/cgroup: remove unused user_usec read in test_cpucg_nice Shaojie Sun
2026-07-29 11:58   ` Michal Koutný
2026-07-30 13:07     ` [PATCH v2] selftests/cgroup: add user_usec sanity check " Shaojie Sun
2026-07-30 14:55       ` Tao Cui [this message]
2026-07-29 10:04 ` [PATCH 2/2] selftests/cgroup: write explicit period to cpu.max in max tests Shaojie Sun
2026-07-29 11:53   ` Michal Koutný

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=23996589-fe21-4f39-bcbb-91eb1df56bd7@linux.dev \
    --to=cui.tao@linux.dev \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=shuah@kernel.org \
    --cc=sunshaojie@kylinos.cn \
    --cc=tj@kernel.org \
    /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