meminfo: fix get_total_swap_cache_pages() for RHCK #93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Linux kernel calls total_swapcache_pages() to get the total number of in-used swap cache in pages. Within corelens.meminfo, this functionality is implemented by get_total_swap_cache_pages(). In the latest RHCK kernel on OL8 (v4.18.0-513.24.1.el8_9.x86_64), the kernel uses a per-node statistics item rather than iterating through the global array "swapper_spaces" to get the sum of pages, and it has optimization that makes array "nr_swapper_spaces" and "swapper_spaces" absent, causing crashes in corelens.
This fix checks whether "NR_SWAPCACHE" exists in the set of per-node statistics items. If found, the function directly reads and returns the counter. If not, it enters the iteration as the code did previously.