From: Marek Szulc Date: Wed, 28 Feb 2024 16:07:50 +0000 (+0100) Subject: wip X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F77%2F306877%2F1;p=platform%2Fkernel%2Flinux-tizen-modules-source.git wip Change-Id: Ie085f16cc04174c9ab3bc7866e04bcf41bbe3cdd --- diff --git a/include/uapi/linux/zlogger.h b/include/uapi/linux/zlogger.h index 2c2e2b4..7e8b73d 100644 --- a/include/uapi/linux/zlogger.h +++ b/include/uapi/linux/zlogger.h @@ -32,6 +32,7 @@ #define ZLOGGER_BLOCK_COUNT (ZLOGGER_BUFFER_SIZE / ZLOGGER_BLOCK_SIZE) #define ZLOGGER_BITMAP_SIZE (ZLOGGER_BLOCK_COUNT / 8) #define ZLOGGER_DATA_MAX (ZLOGGER_BLOCK_SIZE - sizeof(struct zlogger_header)) +#define ZLOGGER_BLOCK_NUMBER 8192 #define ZLOGGER_TAG_MAX (32) #define ZLOGGER_MSG_MAX (140) diff --git a/kernel/zlogger/mockup.c b/kernel/zlogger/mockup.c new file mode 100644 index 0000000..82c1678 --- /dev/null +++ b/kernel/zlogger/mockup.c @@ -0,0 +1,52 @@ +#include +#include + +#define MAX_BLOCKS 10000 +#define POOL_SIZE 2 +#define INIT_PROCESSES 5000 + +struct process_history { + pid_t pid; + int history[POOL_SIZE]; // last used blocks + //int current_index; // which index should be overwritten +}; + +size_t history_size = INIT_PROCESSES; +struct proccess_history *history; + +void init() { + history = calloc(INIT_PROCESSES, sizeof(struct process_history)); +} + +int get_proccess_index(pid_t pid) { + for (int i = 0; i < history_size; i++) + if (history[i].pid == pid) + return i; +} + +void save_new_process(pid_t pid) { + for (int i = 0; i < history_size; i++) { + if (history[i].pid == 0) { + history[i].pid = pid; + return; + } + } + + struct process_history *temp = realloc(history, sizeof(struct process_history)*history_size*2); + if (temp != NULL) { + history = temp; + history_size*=2; + } +} + +void delete_process(pid_t pid) { + memset(&history[get_proccess_index(pid)], 0, sizeof(struct process_history)); +} + +void choose_block(pid_t pid) { + int idx = get_proccess_index(pid); + // sprawdz czy ktorys z tablicy history[idx] jest wolny, jak nie to przydziel dowolny wolny i nadpisz jeden z blokow w historii +} + + + diff --git a/kernel/zlogger/zlogger.c b/kernel/zlogger/zlogger.c index 804e6f6..9916b4e 100644 --- a/kernel/zlogger/zlogger.c +++ b/kernel/zlogger/zlogger.c @@ -119,7 +119,7 @@ static struct miscdevice zlogger_device; static struct miscdevice zlogger_dump_device; static int g_init; -static char *g_shm_ptr[ZLOGGER_DEVICE_COUNT]; +static char *g_shm_ptr[ZLOGGER_BLOCK_NUMBER]; static struct thread_table *g_thread_table; static struct mutex g_block_mutex; @@ -1105,6 +1105,14 @@ static int zlogger_init(void) int g_shm_ptr_i = 0; int r = 0; + unsigned int target_size = 32 * 1024 * 1024; // 32mb + unsigned int page_size = 4 * 1024; // 4kb + + unsigned int iterations = target_size / page_size; + if (target_size % page_size != 0) { + iterations++; + } + if (!g_zlog_enable) { pr_info("zlog is disable\n"); return 0; @@ -1115,8 +1123,8 @@ static int zlogger_init(void) return -ENOMEM; hash_init(g_thread_table->data); - for (g_shm_ptr_i = 0; g_shm_ptr_i < ZLOGGER_DEVICE_COUNT; g_shm_ptr_i++) { - g_shm_ptr[g_shm_ptr_i] = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, MAP_ORDER); + for (g_shm_ptr_i = 0; g_shm_ptr_i < iterations; g_shm_ptr_i++) { + g_shm_ptr[g_shm_ptr_i] = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(page_size)); if (g_shm_ptr[g_shm_ptr_i] == NULL) { r = -ENOMEM; goto out_free_g_thread_table_g_shm_ptr;