The patch titled Subject: mm: vmstat: add some comments on internal storage of byte items has been added to the -mm tree. Its filename is mm-vmstat-add-some-comments-on-internal-storage-of-byte-items.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-vmstat-add-some-comments-on-internal-storage-of-byte-items.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-vmstat-add-some-comments-on-internal-storage-of-byte-items.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Johannes Weiner <hannes@xxxxxxxxxxx> Subject: mm: vmstat: add some comments on internal storage of byte items Byte-accounted items are used for slab object accounting at the cgroup level, because the objects in a slab page can belong to different cgroups. At the global level these items always change in multiples of whole slab pages. The vmstat code exploits this and stores these items as pages internally, which allows for more compact per-cpu data. This optimization isn't self-evident from the asserts and the division in the stat update functions. Provide the reader with some context. Link: https://lkml.kernel.org/r/20210202184411.118614-1-hannes@xxxxxxxxxxx Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/vmstat.h | 6 ++++++ mm/vmstat.c | 12 ++++++++++++ 2 files changed, 18 insertions(+) --- a/include/linux/vmstat.h~mm-vmstat-add-some-comments-on-internal-storage-of-byte-items +++ a/include/linux/vmstat.h @@ -313,6 +313,12 @@ static inline void __mod_node_page_state enum node_stat_item item, int delta) { if (vmstat_item_in_bytes(item)) { + /* + * Only cgroups use subpage accounting right now; at + * the global level, these items still change in + * multiples of whole pages. Store them as pages + * internally to keep the per-cpu counters compact. + */ VM_WARN_ON_ONCE(delta & (PAGE_SIZE - 1)); delta >>= PAGE_SHIFT; } --- a/mm/vmstat.c~mm-vmstat-add-some-comments-on-internal-storage-of-byte-items +++ a/mm/vmstat.c @@ -342,6 +342,12 @@ void __mod_node_page_state(struct pglist long t; if (vmstat_item_in_bytes(item)) { + /* + * Only cgroups use subpage accounting right now; at + * the global level, these items still change in + * multiples of whole pages. Store them as pages + * internally to keep the per-cpu counters compact. + */ VM_WARN_ON_ONCE(delta & (PAGE_SIZE - 1)); delta >>= PAGE_SHIFT; } @@ -551,6 +557,12 @@ static inline void mod_node_state(struct long o, n, t, z; if (vmstat_item_in_bytes(item)) { + /* + * Only cgroups use subpage accounting right now; at + * the global level, these items still change in + * multiples of whole pages. Store them as pages + * internally to keep the per-cpu counters compact. + */ VM_WARN_ON_ONCE(delta & (PAGE_SIZE - 1)); delta >>= PAGE_SHIFT; } _ Patches currently in -mm which might be from hannes@xxxxxxxxxxx are revert-mm-memcontrol-avoid-workload-stalls-when-lowering-memoryhigh.patch mm-vmstat-fix-nohz-wakeups-for-node-stat-changes.patch mm-vmstat-add-some-comments-on-internal-storage-of-byte-items.patch