From 6778948f9de86c3cfaf36725a7c87dcff9ba247f Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 11 Dec 2023 08:20:59 +0000 Subject: [PATCH] kernel_5.10 no rt --- kernel/mm/zswap.c | 43 +++++++++++++++---------------------------- 1 files changed, 15 insertions(+), 28 deletions(-) diff --git a/kernel/mm/zswap.c b/kernel/mm/zswap.c index b24f761..fbb7829 100644 --- a/kernel/mm/zswap.c +++ b/kernel/mm/zswap.c @@ -18,7 +18,6 @@ #include <linux/highmem.h> #include <linux/slab.h> #include <linux/spinlock.h> -#include <linux/local_lock.h> #include <linux/types.h> #include <linux/atomic.h> #include <linux/frontswap.h> @@ -388,37 +387,27 @@ /********************************* * per-cpu code **********************************/ -struct zswap_comp { - /* Used for per-CPU dstmem and tfm */ - local_lock_t lock; - u8 *dstmem; -}; - -static DEFINE_PER_CPU(struct zswap_comp, zswap_comp) = { - .lock = INIT_LOCAL_LOCK(lock), -}; +static DEFINE_PER_CPU(u8 *, zswap_dstmem); static int zswap_dstmem_prepare(unsigned int cpu) { - struct zswap_comp *zcomp; u8 *dst; dst = kmalloc_node(PAGE_SIZE * 2, GFP_KERNEL, cpu_to_node(cpu)); if (!dst) return -ENOMEM; - zcomp = per_cpu_ptr(&zswap_comp, cpu); - zcomp->dstmem = dst; + per_cpu(zswap_dstmem, cpu) = dst; return 0; } static int zswap_dstmem_dead(unsigned int cpu) { - struct zswap_comp *zcomp; + u8 *dst; - zcomp = per_cpu_ptr(&zswap_comp, cpu); - kfree(zcomp->dstmem); - zcomp->dstmem = NULL; + dst = per_cpu(zswap_dstmem, cpu); + kfree(dst); + per_cpu(zswap_dstmem, cpu) = NULL; return 0; } @@ -930,11 +919,10 @@ dlen = PAGE_SIZE; src = (u8 *)zhdr + sizeof(struct zswap_header); dst = kmap_atomic(page); - local_lock(&zswap_comp.lock); - tfm = *this_cpu_ptr(entry->pool->tfm); + tfm = *get_cpu_ptr(entry->pool->tfm); ret = crypto_comp_decompress(tfm, src, entry->length, dst, &dlen); - local_unlock(&zswap_comp.lock); + put_cpu_ptr(entry->pool->tfm); kunmap_atomic(dst); BUG_ON(ret); BUG_ON(dlen != PAGE_SIZE); @@ -1086,12 +1074,12 @@ } /* compress */ - local_lock(&zswap_comp.lock); - dst = *this_cpu_ptr(&zswap_comp.dstmem); - tfm = *this_cpu_ptr(entry->pool->tfm); + dst = get_cpu_var(zswap_dstmem); + tfm = *get_cpu_ptr(entry->pool->tfm); src = kmap_atomic(page); ret = crypto_comp_compress(tfm, src, PAGE_SIZE, dst, &dlen); kunmap_atomic(src); + put_cpu_ptr(entry->pool->tfm); if (ret) { ret = -EINVAL; goto put_dstmem; @@ -1115,7 +1103,7 @@ memcpy(buf, &zhdr, hlen); memcpy(buf + hlen, dst, dlen); zpool_unmap_handle(entry->pool->zpool, handle); - local_unlock(&zswap_comp.lock); + put_cpu_var(zswap_dstmem); /* populate entry */ entry->offset = offset; @@ -1143,7 +1131,7 @@ return 0; put_dstmem: - local_unlock(&zswap_comp.lock); + put_cpu_var(zswap_dstmem); zswap_pool_put(entry->pool); freepage: zswap_entry_cache_free(entry); @@ -1188,10 +1176,9 @@ if (zpool_evictable(entry->pool->zpool)) src += sizeof(struct zswap_header); dst = kmap_atomic(page); - local_lock(&zswap_comp.lock); - tfm = *this_cpu_ptr(entry->pool->tfm); + tfm = *get_cpu_ptr(entry->pool->tfm); ret = crypto_comp_decompress(tfm, src, entry->length, dst, &dlen); - local_unlock(&zswap_comp.lock); + put_cpu_ptr(entry->pool->tfm); kunmap_atomic(dst); zpool_unmap_handle(entry->pool->zpool, entry->handle); BUG_ON(ret); -- Gitblit v1.6.2