summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorHui Zhu <zhuhui@kylinos.cn>2026-04-29 11:42:16 +0300
committerAndrew Morton <akpm@linux-foundation.org>2026-05-29 07:05:00 +0300
commit838376c60df0f28b5b3659a3ef649f07d0eeadf6 (patch)
tree77f303c2a8aa8d2905dffe105817cc4bec7a0367 /include/linux
parentd94d0f9c153f8d9a234171d1ff1c48e513254e7a (diff)
downloadlinux-838376c60df0f28b5b3659a3ef649f07d0eeadf6.tar.xz
mm/memcontrol: hoist pstatc_pcpu assignment out of CPU loop
In mem_cgroup_alloc(), the assignment of pstatc_pcpu is invariant with respect to the for_each_possible_cpu() loop: both the 'parent' pointer and 'parent->vmstats_percpu' remain constant throughout all iterations. The original code redundantly re-evaluated the 'if (parent)' condition and reassigned pstatc_pcpu on every CPU iteration, then repeated the same ternary check 'parent ? pstatc_pcpu : NULL' when storing into statc->parent_pcpu. Move the single conditional assignment of pstatc_pcpu to before the loop, resolving both the loop-invariant placement issue and the duplicated null check. On systems with a large number of possible CPUs, this eliminates repeated branch evaluation with no functional change. No functional change intended. Link: https://lore.kernel.org/20260429084216.186238-1-hui.zhu@linux.dev Signed-off-by: Hui Zhu <zhuhui@kylinos.cn> Reviewed-by: SeongJae Park <sj@kernel.org> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Roman Gushchin <roman.gushchin@linux.dev> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions