This is Part II of the series [1] that makes zram read() and write() preemptible. This part focuses only zsmalloc because zsmalloc imposes atomicity restrictions on its users. One notable example is object mapping API, which returns with: a) local CPU lock held b) zspage rwlock held First, zsmalloc is converted to use sleepable RW-"lock" (it's atomic_t in fact) for zspage migration protection. Second, a new handle mapping is introduced which doesn't use per-CPU buffers (and hence no local CPU lock), does fewer memcpy() calls, but requires users to provide a pointer to temp buffer for object copy-in (when needed). Third, zram is converted to the new zsmalloc mapping API and thus zram read() becomes preemptible. [1] https://lore.kernel.org/linux-mm/20250127072932.1289973-1-senozhatsky@xxxxxxxxxxxx v1 -> v2: - Tweak cmpxchg loop (Uros) - Addressed feedback provided by Yosry Sergey Senozhatsky (7): zsmalloc: factor out pool locking helpers zsmalloc: re-shuffle zs_pool members zsmalloc: factor out size-class locking helpers zsmalloc: make zspage lock preemptible zsmalloc: introduce new object mapping API zram: switch to new zsmalloc object mapping API zram: add might_sleep to zcomp API drivers/block/zram/zcomp.c | 6 +- drivers/block/zram/zcomp.h | 2 + drivers/block/zram/zram_drv.c | 28 +-- include/linux/zsmalloc.h | 8 + mm/zsmalloc.c | 379 ++++++++++++++++++++++++++-------- 5 files changed, 313 insertions(+), 110 deletions(-) -- 2.48.1.262.g85cc9f2d1e-goog