<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/cgroup/rstat.c, branch v6.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.0</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.0'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2022-07-04T07:23:07Z</updated>
<entry>
<title>sched/core: add forced idle accounting for cgroups</title>
<updated>2022-07-04T07:23:07Z</updated>
<author>
<name>Josh Don</name>
<email>joshdon@google.com</email>
</author>
<published>2022-06-29T21:14:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1fcf54deb767d474181ad7cf33c92bb2a33607fb'/>
<id>urn:sha1:1fcf54deb767d474181ad7cf33c92bb2a33607fb</id>
<content type='text'>
4feee7d1260 previously added per-task forced idle accounting. This patch
extends this to also include cgroups.

rstat is used for cgroup accounting, except for the root, which uses
kcpustat in order to bypass the need for doing an rstat flush when
reading root stats.

Only cgroup v2 is supported. Similar to the task accounting, the cgroup
accounting requires that schedstats is enabled.

Signed-off-by: Josh Don &lt;joshdon@google.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Link: https://lkml.kernel.org/r/20220629211426.3329954-1-joshdon@google.com
</content>
</entry>
<entry>
<title>Merge branch 'akpm' (patches from Andrew)</title>
<updated>2022-03-24T21:14:07Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2022-03-24T21:14:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=52deda9551a01879b3562e7b41748e85c591f14c'/>
<id>urn:sha1:52deda9551a01879b3562e7b41748e85c591f14c</id>
<content type='text'>
Merge more updates from Andrew Morton:
 "Various misc subsystems, before getting into the post-linux-next
  material.

  41 patches.

  Subsystems affected by this patch series: procfs, misc, core-kernel,
  lib, checkpatch, init, pipe, minix, fat, cgroups, kexec, kdump,
  taskstats, panic, kcov, resource, and ubsan"

* emailed patches from Andrew Morton &lt;akpm@linux-foundation.org&gt;: (41 commits)
  Revert "ubsan, kcsan: Don't combine sanitizer with kcov on clang"
  kernel/resource: fix kfree() of bootmem memory again
  kcov: properly handle subsequent mmap calls
  kcov: split ioctl handling into locked and unlocked parts
  panic: move panic_print before kmsg dumpers
  panic: add option to dump all CPUs backtraces in panic_print
  docs: sysctl/kernel: add missing bit to panic_print
  taskstats: remove unneeded dead assignment
  kasan: no need to unset panic_on_warn in end_report()
  ubsan: no need to unset panic_on_warn in ubsan_epilogue()
  panic: unset panic_on_warn inside panic()
  docs: kdump: add scp example to write out the dump file
  docs: kdump: update description about sysfs file system support
  arm64: mm: use IS_ENABLED(CONFIG_KEXEC_CORE) instead of #ifdef
  x86/setup: use IS_ENABLED(CONFIG_KEXEC_CORE) instead of #ifdef
  riscv: mm: init: use IS_ENABLED(CONFIG_KEXEC_CORE) instead of #ifdef
  kexec: make crashk_res, crashk_low_res and crash_notes symbols always visible
  cgroup: use irqsave in cgroup_rstat_flush_locked().
  fat: use pointer to simple type in put_user()
  minix: fix bug when opening a file with O_DIRECT
  ...
</content>
</entry>
<entry>
<title>cgroup: use irqsave in cgroup_rstat_flush_locked().</title>
<updated>2022-03-24T02:00:34Z</updated>
<author>
<name>Sebastian Andrzej Siewior</name>
<email>bigeasy@linutronix.de</email>
</author>
<published>2022-03-23T23:06:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b1e2c8df0f007f34c373925471c7b493c9e16620'/>
<id>urn:sha1:b1e2c8df0f007f34c373925471c7b493c9e16620</id>
<content type='text'>
All callers of cgroup_rstat_flush_locked() acquire cgroup_rstat_lock
either with spin_lock_irq() or spin_lock_irqsave().
cgroup_rstat_flush_locked() itself acquires cgroup_rstat_cpu_lock which
is a raw_spin_lock.  This lock is also acquired in
cgroup_rstat_updated() in IRQ context and therefore requires _irqsave()
locking suffix in cgroup_rstat_flush_locked().

Since there is no difference between spin_lock_t and raw_spin_lock_t on
!RT lockdep does not complain here.  On RT lockdep complains because the
interrupts were not disabled here and a deadlock is possible.

Acquire the raw_spin_lock_t with disabled interrupts.

Link: https://lkml.kernel.org/r/20220301122143.1521823-2-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Zefan Li &lt;lizefan.x@bytedance.com&gt;
From: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Subject: cgroup: add a comment to cgroup_rstat_flush_locked().

Add a comment why spin_lock_irq() -&gt; raw_spin_lock_irqsave() is needed.

Link: https://lkml.kernel.org/r/Yh+DOK73hfVV5ThX@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Zefan Li &lt;lizefan.x@bytedance.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>cgroup: rstat: retrieve current bstat to delta directly</title>
<updated>2022-01-12T19:55:12Z</updated>
<author>
<name>Wei Yang</name>
<email>richard.weiyang@gmail.com</email>
</author>
<published>2022-01-08T00:38:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=95b99f353cf3d9d753796975f2093b13f75e0fbd'/>
<id>urn:sha1:95b99f353cf3d9d753796975f2093b13f75e0fbd</id>
<content type='text'>
Instead of retrieve current bstat to cur and copy it to delta, let's use
delta directly.

This saves one copy operation and has the same code convention as
propagating delta to parent.

Signed-off-by: Wei Yang &lt;richard.weiyang@gmail.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>cgroup: rstat: use same convention to assign cgroup_base_stat</title>
<updated>2022-01-12T19:55:02Z</updated>
<author>
<name>Wei Yang</name>
<email>richard.weiyang@gmail.com</email>
</author>
<published>2022-01-08T00:38:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4148be7de0a3316edd1af45609d354cac0e6a021'/>
<id>urn:sha1:4148be7de0a3316edd1af45609d354cac0e6a021</id>
<content type='text'>
In function cgroup_base_stat_flush(), we update cgroup_base_stat by
getting rstatc-&gt;bstat and adjust delta to related fields.

There are two convention to assign cgroup_base_stat in this function:

  * rstat2 = rstat1
  * rstat2.cputime = rstat1.cputime

The second convention may make audience think just field "cputime" is
updated, while cputime is the only field in cgroup_base_stat.

Let's use the same convention to eliminate this confusion.

Signed-off-by: Wei Yang &lt;richard.weiyang@gmail.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>cgroup/rstat: check updated_next only for root</title>
<updated>2022-01-06T21:50:34Z</updated>
<author>
<name>Wei Yang</name>
<email>richard.weiyang@gmail.com</email>
</author>
<published>2021-12-25T00:09:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f5f60d235e7058da13a643c33fc7599c05ec0b73'/>
<id>urn:sha1:f5f60d235e7058da13a643c33fc7599c05ec0b73</id>
<content type='text'>
After commit dc26532aed0a ("cgroup: rstat: punt root-level optimization to
individual controllers"), each rstat on updated_children list has its
-&gt;updated_next not NULL.

This means we can remove the check on -&gt;updated_next, if we make sure
the subtree from @root is on list, which could be done by checking
updated_next for root.

tj: Coding style fixes.

Signed-off-by: Wei Yang &lt;richard.weiyang@gmail.com&gt;
Reviewed-by: Michal Koutný &lt;mkoutny@suse.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>cgroup: rstat: explicitly put loop variant in while</title>
<updated>2022-01-06T21:10:06Z</updated>
<author>
<name>Wei Yang</name>
<email>richard.weiyang@gmail.com</email>
</author>
<published>2021-12-25T00:09:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0da41f7348fff193d01d031ce255088fa98324b7'/>
<id>urn:sha1:0da41f7348fff193d01d031ce255088fa98324b7</id>
<content type='text'>
Instead of do while unconditionally, let's put the loop variant in
while.

Signed-off-by: Wei Yang &lt;richard.weiyang@gmail.com&gt;
Reviewed-by: Michal Koutný &lt;mkoutny@suse.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>cgroup: rstat: Mark benign data race to silence KCSAN</title>
<updated>2021-11-15T21:34:17Z</updated>
<author>
<name>Michal Koutný</name>
<email>mkoutny@suse.com</email>
</author>
<published>2021-11-03T16:58:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=eda09706b240ca9129ac4e1fbb4eb1e2bc67aadc'/>
<id>urn:sha1:eda09706b240ca9129ac4e1fbb4eb1e2bc67aadc</id>
<content type='text'>
There is a race between updaters and flushers (flush can possibly miss
the latest update(s)). This is expected as explained in
cgroup_rstat_updated() comment, add also machine readable annotation so
that KCSAN results aren't noisy.

Reported-by: Hao Sun &lt;sunhao.th@gmail.com&gt;
Link: https://lore.kernel.org/r/CACkBjsbPVdkub=e-E-p1WBOLxS515ith-53SFdmFHWV_QMo40w@mail.gmail.com
Suggested-by: Hao Sun &lt;sunhao.th@gmail.com&gt;

Signed-off-by: Michal Koutný &lt;mkoutny@suse.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>cgroup: Fix rootcg cpu.stat guest double counting</title>
<updated>2021-11-01T16:47:08Z</updated>
<author>
<name>Dan Schatzberg</name>
<email>schatzberg.dan@gmail.com</email>
</author>
<published>2021-10-28T22:15:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=81c49d39aea8a10e6d05d3aa1cb65ceb721e19b0'/>
<id>urn:sha1:81c49d39aea8a10e6d05d3aa1cb65ceb721e19b0</id>
<content type='text'>
In account_guest_time in kernel/sched/cputime.c guest time is
attributed to both CPUTIME_NICE and CPUTIME_USER in addition to
CPUTIME_GUEST_NICE and CPUTIME_GUEST respectively. Therefore, adding
both to calculate usage results in double counting any guest time at
the rootcg.

Fixes: 936f2a70f207 ("cgroup: add cpu.stat file to root cgroup")
Signed-off-by: Dan Schatzberg &lt;schatzberg.dan@gmail.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>cgroup: rstat: fix A-A deadlock on 32bit around u64_stats_sync</title>
<updated>2021-07-27T23:12:20Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2021-07-27T23:12:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c3df5fb57fe8756d67fd56ed29da65cdfde839f9'/>
<id>urn:sha1:c3df5fb57fe8756d67fd56ed29da65cdfde839f9</id>
<content type='text'>
0fa294fb1985 ("cgroup: Replace cgroup_rstat_mutex with a spinlock") added
cgroup_rstat_flush_irqsafe() allowing flushing to happen from the irq
context. However, rstat paths use u64_stats_sync to synchronize access to
64bit stat counters on 32bit machines. u64_stats_sync is implemented using
seq_lock and trying to read from an irq context can lead to A-A deadlock if
the irq happens to interrupt the stat update.

Fix it by using the irqsafe variants - u64_stats_update_begin_irqsave() and
u64_stats_update_end_irqrestore() - in the update paths. Note that none of
this matters on 64bit machines. All these are just for 32bit SMP setups.

Note that the interface was introduced way back, its first and currently
only use was recently added by 2d146aa3aa84 ("mm: memcontrol: switch to
rstat"). Stable tagging targets this commit.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: Rik van Riel &lt;riel@surriel.com&gt;
Fixes: 2d146aa3aa84 ("mm: memcontrol: switch to rstat")
Cc: stable@vger.kernel.org # v5.13+
</content>
</entry>
</feed>
