WSL2-Linux-Kernel/drivers
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: 860c707dca ("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
..
accessibility Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
acpi pci-v5.12-changes 2021-02-25 09:56:08 -08:00
amba
android
ata
atm
auxdisplay
base drivers/base/memory: don't store phys_device in memory blocks 2021-02-26 09:41:00 -08:00
bcma
block zsmalloc: account the number of compacted pages correctly 2021-02-26 09:41:01 -08:00
bluetooth
bus Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
cdrom
char Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
clk Driver core / debugfs update for 5.12-rc1 2021-02-24 10:13:55 -08:00
clocksource A small set of clockevent fixes which fell through the cracks 2021-02-22 14:11:36 -08:00
connector
counter
cpufreq Simple Firmware Interface (SFI) support removal for v5.12-rc1 2021-02-24 10:35:29 -08:00
cpuidle
crypto
cxl cxl/mem: Fix potential memory leak 2021-02-22 14:44:39 -08:00
dax Merge branch 'for-5.12/dax' into for-5.12/libnvdimm 2021-02-23 18:13:45 -08:00
dca
devfreq
dio
dma dmaengine updates for v5.12-rc1 2021-02-23 15:05:10 -08:00
dma-buf
edac
eisa
extcon
firewire
firmware Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
fpga
fsi
gnss
gpio Driver core / debugfs update for 5.12-rc1 2021-02-24 10:13:55 -08:00
gpu Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
greybus
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid 2021-02-23 14:52:22 -08:00
hsi
hv mm/memory_hotplug: MEMHP_MERGE_RESOURCE -> MHP_MERGE_RESOURCE 2021-02-26 09:41:00 -08:00
hwmon Devicetree updates for v5.12: 2021-02-22 10:05:12 -08:00
hwspinlock
hwtracing ARM updates for 5.12-rc1: 2021-02-22 14:27:07 -08:00
i2c ARM updates for 5.12-rc1: 2021-02-22 14:27:07 -08:00
i3c I3C for 5.12 2021-02-22 09:52:55 -08:00
ide
idle
iio
infiniband
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2021-02-23 14:56:23 -08:00
interconnect
iommu dma-mapping updates for 5.12: 2021-02-24 09:54:24 -08:00
ipack
irqchip
isdn
leds
lightnvm
macintosh
mailbox mailbox: arm_mhuv2: Skip calling kfree() with invalid pointer 2021-02-22 13:34:27 -06:00
mcb
md - Fix DM integrity's HMAC support to provide enhanced security of 2021-02-22 10:22:54 -08:00
media Fixes around VM_FPNMAP and follow_pfn 2021-02-22 17:45:02 -08:00
memory Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
memstick
message
mfd Simple Firmware Interface (SFI) support removal for v5.12-rc1 2021-02-24 10:35:29 -08:00
misc pci-v5.12-changes 2021-02-25 09:56:08 -08:00
mmc ARM updates for 5.12-rc1: 2021-02-22 14:27:07 -08:00
most
mtd
mux
net Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
nfc Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
ntb NTB: Add support for EPF PCI Non-Transparent Bridge 2021-02-23 14:12:53 -06:00
nubus
nvdimm libnvdimm + device-dax for 5.12 2021-02-24 09:35:54 -08:00
nvme
nvmem
of Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
opp
parisc
parport
pci pci-v5.12-changes 2021-02-25 09:56:08 -08:00
pcmcia
perf IOMMU Updates for Linux v5.12 2021-02-22 10:31:29 -08:00
phy
pinctrl This is the bulk of pin control changes for the v5.12 kernel. 2021-02-22 18:39:11 -08:00
platform Simple Firmware Interface (SFI) support removal for v5.12-rc1 2021-02-24 10:35:29 -08:00
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc ARM updates for 5.12-rc1: 2021-02-22 14:27:07 -08:00
s390 SCSI misc on 20210219 2021-02-22 10:24:58 -08:00
sbus
scsi SCSI misc on 20210219 2021-02-22 10:24:58 -08:00
sh
siox
slimbus
soc
soundwire
spi powerpc updates for 5.12 2021-02-22 14:34:00 -08:00
spmi
ssb
staging Simple Firmware Interface (SFI) support removal for v5.12-rc1 2021-02-24 10:35:29 -08:00
target SCSI misc on 20210219 2021-02-22 10:24:58 -08:00
tc
tee
thermal
thunderbolt
tty Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
uio
usb Kbuild updates for v5.12 2021-02-25 10:17:31 -08:00
vdpa
vfio VFIO updates for v5.12-rc1 2021-02-24 10:43:40 -08:00
vhost
video video: fbdev: acornfb: remove free_unused_pages() 2021-02-24 13:38:31 -08:00
virt
virtio virtio-mem: check against mhp_get_pluggable_range() which memory we can hotplug 2021-02-26 09:41:01 -08:00
visorbus
vlynq
vme
w1
watchdog Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
xen mm/memory_hotplug: MEMHP_MERGE_RESOURCE -> MHP_MERGE_RESOURCE 2021-02-26 09:41:00 -08:00
zorro
Kconfig
Makefile Simple Firmware Interface (SFI) support removal for v5.12-rc1 2021-02-24 10:35:29 -08:00