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/zsmalloc.c | 85 +++--------------------------------------- 1 files changed, 6 insertions(+), 79 deletions(-) diff --git a/kernel/mm/zsmalloc.c b/kernel/mm/zsmalloc.c index fab4cdf..1b309c6 100644 --- a/kernel/mm/zsmalloc.c +++ b/kernel/mm/zsmalloc.c @@ -57,7 +57,6 @@ #include <linux/wait.h> #include <linux/pagemap.h> #include <linux/fs.h> -#include <linux/local_lock.h> #define ZSPAGE_MAGIC 0x58 @@ -77,20 +76,6 @@ #define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER) #define ZS_HANDLE_SIZE (sizeof(unsigned long)) - -#ifdef CONFIG_PREEMPT_RT - -struct zsmalloc_handle { - unsigned long addr; - spinlock_t lock; -}; - -#define ZS_HANDLE_ALLOC_SIZE (sizeof(struct zsmalloc_handle)) - -#else - -#define ZS_HANDLE_ALLOC_SIZE (sizeof(unsigned long)) -#endif /* * Object location (<PFN>, <obj_idx>) is encoded as @@ -308,7 +293,6 @@ }; struct mapping_area { - local_lock_t lock; char *vm_buf; /* copy buffer for objects that span pages */ char *vm_addr; /* address of kmap_atomic()'ed pages */ enum zs_mapmode vm_mm; /* mapping mode */ @@ -338,7 +322,7 @@ static int create_cache(struct zs_pool *pool) { - pool->handle_cachep = kmem_cache_create("zs_handle", ZS_HANDLE_ALLOC_SIZE, + pool->handle_cachep = kmem_cache_create("zs_handle", ZS_HANDLE_SIZE, 0, 0, NULL); if (!pool->handle_cachep) return 1; @@ -362,26 +346,9 @@ static unsigned long cache_alloc_handle(struct zs_pool *pool, gfp_t gfp) { - void *p; - - p = kmem_cache_alloc(pool->handle_cachep, - gfp & ~(__GFP_HIGHMEM|__GFP_MOVABLE)); -#ifdef CONFIG_PREEMPT_RT - if (p) { - struct zsmalloc_handle *zh = p; - - spin_lock_init(&zh->lock); - } -#endif - return (unsigned long)p; + return (unsigned long)kmem_cache_alloc(pool->handle_cachep, + gfp & ~(__GFP_HIGHMEM|__GFP_MOVABLE|__GFP_CMA)); } - -#ifdef CONFIG_PREEMPT_RT -static struct zsmalloc_handle *zs_get_pure_handle(unsigned long handle) -{ - return (void *)(handle &~((1 << OBJ_TAG_BITS) - 1)); -} -#endif static void cache_free_handle(struct zs_pool *pool, unsigned long handle) { @@ -401,18 +368,12 @@ static void record_obj(unsigned long handle, unsigned long obj) { -#ifdef CONFIG_PREEMPT_RT - struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - - WRITE_ONCE(zh->addr, obj); -#else /* * lsb of @obj represents handle lock while other bits * represent object value the handle is pointing so * updating shouldn't do store tearing. */ WRITE_ONCE(*(unsigned long *)handle, obj); -#endif } /* zpool driver */ @@ -494,10 +455,7 @@ #endif /* CONFIG_ZPOOL */ /* per-cpu VM mapping areas for zspage accesses that cross page boundaries */ -static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { - /* XXX remove this and use a spin_lock_t in pin_tag() */ - .lock = INIT_LOCAL_LOCK(lock), -}; +static DEFINE_PER_CPU(struct mapping_area, zs_map_area); static bool is_zspage_isolated(struct zspage *zspage) { @@ -907,13 +865,7 @@ static unsigned long handle_to_obj(unsigned long handle) { -#ifdef CONFIG_PREEMPT_RT - struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - - return zh->addr; -#else return *(unsigned long *)handle; -#endif } static unsigned long obj_to_head(struct page *page, void *obj) @@ -927,46 +879,22 @@ static inline int testpin_tag(unsigned long handle) { -#ifdef CONFIG_PREEMPT_RT - struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - - return spin_is_locked(&zh->lock); -#else return bit_spin_is_locked(HANDLE_PIN_BIT, (unsigned long *)handle); -#endif } static inline int trypin_tag(unsigned long handle) { -#ifdef CONFIG_PREEMPT_RT - struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - - return spin_trylock(&zh->lock); -#else return bit_spin_trylock(HANDLE_PIN_BIT, (unsigned long *)handle); -#endif } static void pin_tag(unsigned long handle) __acquires(bitlock) { -#ifdef CONFIG_PREEMPT_RT - struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - - return spin_lock(&zh->lock); -#else bit_spin_lock(HANDLE_PIN_BIT, (unsigned long *)handle); -#endif } static void unpin_tag(unsigned long handle) __releases(bitlock) { -#ifdef CONFIG_PREEMPT_RT - struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - - return spin_unlock(&zh->lock); -#else bit_spin_unlock(HANDLE_PIN_BIT, (unsigned long *)handle); -#endif } static void reset_page(struct page *page) @@ -1350,8 +1278,7 @@ class = pool->size_class[class_idx]; off = (class->size * obj_idx) & ~PAGE_MASK; - local_lock(&zs_map_area.lock); - area = this_cpu_ptr(&zs_map_area); + area = &get_cpu_var(zs_map_area); area->vm_mm = mm; if (off + class->size <= PAGE_SIZE) { /* this object is contained entirely within a page */ @@ -1405,7 +1332,7 @@ __zs_unmap_object(area, pages, off, class->size); } - local_unlock(&zs_map_area.lock); + put_cpu_var(zs_map_area); migrate_read_unlock(zspage); unpin_tag(handle); -- Gitblit v1.6.2