From: sashiko-bot@kernel.org
To: "Shakeel Butt" <shakeel.butt@linux.dev>
Cc: hannes@cmpxchg.org, tj@kernel.org, bpf@vger.kernel.org, mkoutny@suse.com
Subject: Re: [RFC PATCH 7/7] selftests: cgroup: check that high_work reclaim is charged to the memcg
Date: Thu, 24 Sep 2026 19:01:23 +0000 [thread overview]
Message-ID: <20260924190124.528C81F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260924184714.912181-8-shakeel.butt@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests: integer overflow in CPU time calculations on 32-bit systems
--
commit 07220f623c10651bfa63c3489314840c8641decc
Author: Shakeel Butt <shakeel.butt@linux.dev>
selftests: cgroup: check that high_work reclaim is charged to the memcg
Fills a memcg's TCP receive buffers from softirq while its only task
sleeps, so the memcg goes over memory.high and high_work reclaims.
Checks that the memcg's cpu.stat and memory.pressure grow, which
only happens if that reclaim is charged to the memcg.
> diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c
> index 0ed82347044ed..00802804c0d98 100644
> --- a/tools/testing/selftests/cgroup/test_memcontrol.c
> +++ b/tools/testing/selftests/cgroup/test_memcontrol.c
[ ... ]
> +static long now_usec(void)
> +{
> + struct timespec ts;
> +
> + clock_gettime(CLOCK_MONOTONIC, &ts);
> + return ts.tv_sec * 1000000L + ts.tv_nsec / 1000;
[Severity: Medium]
Does this calculation overflow a 32-bit signed long? On 32-bit architectures,
multiplying tv_sec by 1000000L truncates to a 32-bit signed long, which
overflows after approximately 35 minutes of system uptime. Could this corrupt
time differences due to signed overflow?
> +}
[ ... ]
> +static int test_memcg_high_work_cpu_max(const char *root)
> +{
> + int ret = KSFT_FAIL, pid = -1, hog = -1, i, sk[HIGH_WORK_NCONN];
> + long current, h0, h1, h2, t0, t1, t2, u1, u2, reclaim, lost;
[ ... ]
> + /* The receiver sleeps, so the rest of the memcg's time is high_work. */
> + reclaim = (u2 - u1) - (h2 - h1);
> + lost = (h1 - h0) * (t2 - t1) / (t1 - t0) - (h2 - h1);
[Severity: Medium]
Can this multiplication overflow a 32-bit long? The time differences
(t2 - t1) and (h1 - h0) appear to be microsecond deltas of several seconds.
On 32-bit systems, their product can unconditionally overflow the 32-bit
signed long maximum, resulting in a bogus negative value that might cause
spurious test failures.
> + if (reclaim < 30000) {
> + ksft_print_msg("high_work used only %ld us, too little to test\n",
> + reclaim);
> + ret = KSFT_SKIP;
> + goto cleanup;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260924184714.912181-1-shakeel.butt@linux.dev?part=7
next prev parent reply other threads:[~2026-09-24 19:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 18:47 [RFC PATCH 0/7] cgroup: charge kernel work to the cgroup it is done for Shakeel Butt
2026-09-24 18:47 ` [RFC PATCH 1/7] cgroup: add cgroup_account_system_time() Shakeel Butt
2026-09-24 18:47 ` [RFC PATCH 2/7] cgroup: add set_active_cgroup() to charge CPU time to a cgroup Shakeel Butt
2026-09-24 18:47 ` [RFC PATCH 3/7] psi: charge pressure to the task's active cgroup Shakeel Butt
2026-09-24 18:47 ` [RFC PATCH 4/7] sched/fair: add cfs_bandwidth_charge() for kernel work done for a cgroup Shakeel Butt
2026-09-24 18:47 ` [RFC PATCH 5/7] cgroup: take set_active_cgroup() time out of the cgroup's cpu.max Shakeel Butt
2026-09-24 18:47 ` [RFC PATCH 6/7] memcg: charge high_work reclaim to the memcg Shakeel Butt
2026-09-24 18:47 ` [RFC PATCH 7/7] selftests: cgroup: check that high_work reclaim is charged " Shakeel Butt
2026-09-24 19:01 ` sashiko-bot [this message]
2026-09-24 20:28 ` [RFC PATCH 0/7] cgroup: charge kernel work to the cgroup it is done for Tejun Heo
2026-09-24 21:11 ` Shakeel Butt
2026-09-28 22:39 ` Tejun Heo
2026-10-01 10:59 ` Peter Zijlstra
2026-10-01 12:18 ` Peter Zijlstra
2026-10-01 16:00 ` Shakeel Butt
2026-10-01 12:40 ` Sebastian Andrzej Siewior
2026-10-01 18:59 ` Tejun Heo
2026-10-01 10:54 ` Peter Zijlstra
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=20260924190124.528C81F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shakeel.butt@linux.dev \
--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 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.