On 2020-05-20 11:13:31 [+0000], Song Bao Hua wrote: > For example, on cpu1, once you begin to compress, you hold the percpu > acomp-ctx and percpu destination buffer of CPU1, the below code makes sure > you get the acomp and dstmem from the same core by disabling preemption with > get_cpu_var and put_cpu_var: > dst = get_cpu_var(zswap_dstmem); > acomp_ctx = *this_cpu_ptr(entry->pool->acomp_ctx); > put_cpu_var(zswap_dstmem); > > then there are two cases: > > 1. after getting dst and acomp_ctx of cpu1, you might always work in cpu1, > the mutex in per-cpu acomp-ctx will guarantee two compressions won't do at > the same core in parallel, and it also makes certain compression and > decompression won't do at the same core in parallel. Everything is like > before.
For readability I suggest not to mix per-CPU and per-CTX variables like that. If zswap_dstmem is protected by the mutex, please make it part of acomp_ctx. Sebastian