From: Johannes Weiner <hannes@cmpxchg.org>
To: Hao Jia <jiahao.os@bytedance.com>
Cc: mingo@redhat.com, peterz@infradead.org, mingo@kernel.org,
juri.lelli@redhat.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, bristot@redhat.com,
vschneid@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] sched/psi: Zero the memory of struct psi_group
Date: Wed, 10 Aug 2022 11:04:48 -0400 [thread overview]
Message-ID: <YvPJEDHfOmX90UOz@cmpxchg.org> (raw)
In-Reply-To: <20220806120510.96131-2-jiahao.os@bytedance.com>
On Sat, Aug 06, 2022 at 08:05:08PM +0800, Hao Jia wrote:
> After commit 5f69a6577bc3 ("psi: dont alloc memory for psi by default"),
> the memory used by struct psi_group is no longer allocated and zeroed
> in cgroup_create().
>
> Since the memory of struct psi_group is not zeroed, the data in this
> memory is random, which will lead to inaccurate psi statistics when
> creating a new cgroup.
>
> So we use kzlloc() to allocate and zero the struct psi_group and
> remove the redundant zeroing in group_init().
>
> Steps to reproduce:
> 1. Use cgroup v2 and enable CONFIG_PSI
> 2. Create a new cgroup, and query psi statistics
> mkdir /sys/fs/cgroup/test
> cat /sys/fs/cgroup/test/cpu.pressure
> some avg10=0.00 avg60=0.00 avg300=47927752200.00 total=12884901
> full avg10=561815124.00 avg60=125835394188.00 avg300=1077090462000.00 total=10273561772
>
> cat /sys/fs/cgroup/test/io.pressure
> some avg10=1040093132823.95 avg60=1203770351379.21 avg300=3862252669559.46 total=4294967296
> full avg10=921884564601.39 avg60=0.00 avg300=1984507298.35 total=442381631
>
> cat /sys/fs/cgroup/test/memory.pressure
> some avg10=232476085778.11 avg60=0.00 avg300=0.00 total=0
> full avg10=0.00 avg60=0.00 avg300=2585658472280.57 total=12884901
>
> Fixes: commit 5f69a6577bc3 ("psi: dont alloc memory for psi by default")
>
> Signed-off-by: Hao Jia <jiahao.os@bytedance.com>
Yikes! Yes, we relied on the embedding cgroup being kzalloc'd, or, in
the case of psi_system, on the psi_group being in NULLed static mem.
The partial zeroing in group_init() obscured that. Thanks for the fix.
Cc: stable@vger.kernel.org # 5.19
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
next prev parent reply other threads:[~2022-08-10 15:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-06 12:05 [PATCH 0/3] sched/psi: psi bug fixes and cleanups Hao Jia
2022-08-06 12:05 ` [PATCH 1/3] sched/psi: Zero the memory of struct psi_group Hao Jia
2022-08-10 15:04 ` Johannes Weiner [this message]
2022-08-06 12:05 ` [PATCH 2/3] sched/psi: Remove unused parameter nbytes of psi_trigger_create() Hao Jia
2022-08-10 15:12 ` Johannes Weiner
2022-08-06 12:05 ` [PATCH 3/3] sched/psi: Remove redundant cgroup_psi() when !CONFIG_CGROUPS Hao Jia
2022-08-10 15:13 ` Johannes Weiner
2022-08-06 19:38 ` [PATCH 0/3] sched/psi: psi bug fixes and cleanups Ingo Molnar
2022-08-09 17:37 ` Tejun Heo
2022-08-10 15:13 ` Johannes Weiner
2022-08-15 20:55 ` Tejun Heo
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=YvPJEDHfOmX90UOz@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=jiahao.os@bytedance.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/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