]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/vmstat: defer the refresh_zone_stat_thresholds after all CPUs bringup
authorSaurabh Sengar <ssengar@linux.microsoft.com>
Fri, 5 Jul 2024 08:48:21 +0000 (01:48 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 17 Aug 2024 00:53:07 +0000 (17:53 -0700)
commit7ee52f4284ab1e4a195e15d326a733ef7d4eabcd
tree5966009f48c092806eb38cf1ee0c790ebf6299b0
parent56d247a8c362a95d51b6f6c10814279820e69418
mm/vmstat: defer the refresh_zone_stat_thresholds after all CPUs bringup

refresh_zone_stat_thresholds function has two loops which is expensive for
higher number of CPUs and NUMA nodes.

Below is the rough estimation of total iterations done by these loops
based on number of NUMA and CPUs.

Total number of iterations: nCPU * 2 * Numa * mCPU
Where:
 nCPU = total number of CPUs
 Numa = total number of NUMA nodes
 mCPU = mean value of total CPUs (e.g., 512 for 1024 total CPUs)

For the system under test with 16 NUMA nodes and 1024 CPUs, this results
in a substantial increase in the number of loop iterations during boot-up
when NUMA is enabled:

No NUMA = 1024*2*1*512  =   1,048,576 : Here refresh_zone_stat_thresholds
takes around 224 ms total for all the CPUs in the system under test.
16 NUMA = 1024*2*16*512 =  16,777,216 : Here refresh_zone_stat_thresholds
takes around 4.5 seconds total for all the CPUs in the system under test.

Calling this for each CPU is expensive when there are large number of CPUs
along with multiple NUMAs.  Fix this by deferring
refresh_zone_stat_thresholds to be called later at once when all the
secondary CPUs are up.  Also, register the DYN hooks to keep the existing
hotplug functionality intact.

Without this patch, refresh_zone_stat_threshold was being called 1024
times.  After applying the patch, it is called only once, which is same
as the last iteration of the earlier 1024 calls.  Further testing with
this patch, I observed a 4.5-second improvement in the overall boot
timing due to this fix, which is same as the total time taken by
refresh_zone_stat_thresholds without thie patch, leading me to
reasonably conclude that refresh_zone_stat_threshold now takes a
negligible amount of time (likely just a few milliseconds).

Link: https://lkml.kernel.org/r/1720169301-21002-1-git-send-email-ssengar@linux.microsoft.com
Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmstat.c