From: Mateusz Majewski Date: Wed, 24 Aug 2022 09:21:07 +0000 (+0200) Subject: improvements X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1f9eb53652068589e8e36b6ad4cfefc1a51ba49;p=platform%2Fkernel%2Flinux-tizen-modules-source.git improvements Change-Id: Iec1d78153c06e06f4982d734c4e3cd8bf4a21c11 --- diff --git a/kernel/vlogger/vlogger.c b/kernel/vlogger/vlogger.c index 536bcae..2e6aed9 100644 --- a/kernel/vlogger/vlogger.c +++ b/kernel/vlogger/vlogger.c @@ -213,19 +213,14 @@ static inline char *get_shared_memory(int dev_index) static inline struct block_t *get_block(uint16_t block_index) { - // TODO: This represents the same 2048 value in three different ways: - // 1 << 11, 0x7FF + 1, as well as V_BLOCK_SIZE. uint16_t index = block_index - 1; - int offset = index & 0x7FF; - char *p = get_shared_memory(index >> 11); + int offset = index & (V_BLOCK_SIZE - 1); + char *p = get_shared_memory(index / V_BLOCK_SIZE); - if (!p) { - pr_err("[INVALID BLOCK] index:%d free:%d err:%d", block_index, g_free_q.count, g_err_count); - dump_stack(); - WARN_ON(1); - } + if (!p) + return NULL; - return (struct block_t *)(p + (offset << 11)); + return (struct block_t *)(p + (offset * V_BLOCK_SIZE)); } static inline void queue_init(struct queue_t *q, const char *name, uint16_t capacity) @@ -656,19 +651,18 @@ static const struct file_operations vlogger_fops = { static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *buf) { - // int thread_count = 0; - // int i; + int thread_count = 0; + int i; - // for (i = 0; i < MAX_THREAD; i++) { - // if (g_threads[i].block > 0) - // thread_count ++; - // } + for (i = 0; i < g_max_thread_id; i++) { + if (get_thread_table(i) > 0) + thread_count ++; + } - // return snprintf(buf, PAGE_SIZE, - // "free(%d%%):%d/%d task_on:%d gc_free:%u error:%u tid_max:%d\n", - // BLOCK_RATIO(g_free_q.count), g_free_q.count, (g_free_q.count + thread_count), - // g_task_on, g_free_count, g_err_count, g_max_thread_id); - return -ENOTSUPP; // TODO + return snprintf(buf, PAGE_SIZE, + "free(%d%%):%d/%d task_on:%d gc_free:%u error:%u tid_max:%d\n", + BLOCK_RATIO(g_free_q.count), g_free_q.count, (g_free_q.count + thread_count), + g_task_on, g_free_count, g_err_count, g_max_thread_id); } static DEVICE_ATTR_RO(status); @@ -739,8 +733,7 @@ static ssize_t thread_store(struct device *dev, static ssize_t thread_show(struct device *dev, struct device_attribute *attr, char *buf) { - // return snprintf(buf, PAGE_SIZE, "[%d] block:%u\n", g_thread, g_threads[g_thread].block); - return -ENOTSUPP; // TODO + return snprintf(buf, PAGE_SIZE, "[%d] block:%u\n", g_thread, get_thread_table(g_thread)); } static DEVICE_ATTR_RW(thread); @@ -829,11 +822,17 @@ out_free_g_thread_table_g_shm_ptr: static void __exit vlogger_exit(void) { int i; + struct thread_table_field *ptr = NULL; + struct hlist_node *tmp_iter = NULL; + int tmp_bkt; // TODO: What about the task that is running in the background? queue_deinit(&g_free_q); - kfree(g_thread_table); // TODO: Free innards + hash_for_each_safe(g_thread_table->data, tmp_bkt, tmp_iter, ptr, next) { + kfree(ptr); + } + kfree(g_thread_table); for (i = 0; i < DEVICE_COUNT; i++) kfree(g_shm_ptr[i]);