Rokudo Yan 2395928158 zsmalloc: account the number of compacted pages correctly
There exists multiple path may do zram compaction concurrently.
1. auto-compaction triggered during memory reclaim
2. userspace utils write zram<id>/compaction node

So, multiple threads may call zs_shrinker_scan/zs_compact concurrently.
But pages_compacted is a per zsmalloc pool variable and modification
of the variable is not serialized(through under class->lock).
There are two issues here:
1. the pages_compacted may not equal to total number of pages
freed(due to concurrently add).
2. zs_shrinker_scan may not return the correct number of pages
freed(issued by current shrinker).

The fix is simple:
1. account the number of pages freed in zs_compact locally.
2. use actomic variable pages_compacted to accumulate total number.

Link: https://lkml.kernel.org/r/20210202122235.26885-1-wu-yan@tcl.com
Fixes: 860c707dca155a56 ("zsmalloc: account the number of compacted pages")
Signed-off-by: Rokudo Yan <wu-yan@tcl.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-02-26 09:41:01 -08:00
..
2021-02-25 09:56:08 -08:00
2021-02-24 10:25:37 -08:00
2021-02-22 14:44:39 -08:00
2021-02-23 15:05:10 -08:00
2021-02-25 10:17:31 -08:00
2021-02-22 10:05:12 -08:00
2021-02-22 14:27:07 -08:00
2021-02-22 14:27:07 -08:00
2021-02-22 09:52:55 -08:00
2021-02-18 11:19:29 -04:00
2021-02-24 09:54:24 -08:00
2021-02-15 15:41:56 +01:00
2021-02-25 09:56:08 -08:00
2021-02-22 14:27:07 -08:00
2021-02-25 10:17:31 -08:00
2021-02-24 10:25:37 -08:00
2021-02-24 09:35:54 -08:00
2021-02-21 11:06:54 -08:00
2021-02-24 10:25:37 -08:00
2021-02-25 09:56:08 -08:00
2021-02-22 10:31:29 -08:00
2021-02-22 09:29:42 -08:00
2021-02-20 18:42:28 -08:00
2021-02-22 14:27:07 -08:00
2021-02-22 10:24:58 -08:00
2021-02-22 10:24:58 -08:00
2021-02-22 14:34:00 -08:00
2021-02-22 10:24:58 -08:00
2021-02-09 16:10:49 +01:00
2021-02-24 10:25:37 -08:00
2021-02-25 10:17:31 -08:00
2021-02-24 10:43:40 -08:00
2021-02-09 12:15:07 +01:00