From 0e48a0dd129e3cb1592eda9b2b8cdcde48d29bcf Mon Sep 17 00:00:00 2001 From: shenchenkai Date: Fri, 17 Dec 2021 15:45:15 +0800 Subject: [PATCH] Description:[feature] support customized hilog ring buffer size Change-Id: I5d23deaada5939bbb6fb57505f72c2348bd6afe9 Signed-off-by: shenchenkai --- kernel/extended/Kconfig | 5 ++++- kernel/extended/hilog/Kconfig | 15 +++++++++++++++ kernel/extended/hilog/los_hilog.c | 7 ++++++- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 kernel/extended/hilog/Kconfig diff --git a/kernel/extended/Kconfig b/kernel/extended/Kconfig index 0ae789b6..abb7bec3 100644 --- a/kernel/extended/Kconfig +++ b/kernel/extended/Kconfig @@ -101,4 +101,7 @@ source "kernel/extended/hidumper/Kconfig" source "kernel/extended/perf/Kconfig" ######################### config options of lms ######################### -source "kernel/extended/lms/Kconfig" \ No newline at end of file +source "kernel/extended/lms/Kconfig" + +######################### config options of hilog ######################### +source "kernel/extended/hilog/Kconfig" \ No newline at end of file diff --git a/kernel/extended/hilog/Kconfig b/kernel/extended/hilog/Kconfig new file mode 100644 index 00000000..28e99493 --- /dev/null +++ b/kernel/extended/hilog/Kconfig @@ -0,0 +1,15 @@ +config HILOG + tristate "Hilog support" + default y + help + hilog buffer manager. + + Hilog is a simple log manager for OpenHarmonyOS. + log string write to /dev/hilog, and the hilog driver copy it + to the ring buffer. Ring buffer can be read from userspace. + +config HILOG_BUFFER_SIZE + int "hilog buffer size" + default 4096 + help + Define the default ring buffer size of hilog \ No newline at end of file diff --git a/kernel/extended/hilog/los_hilog.c b/kernel/extended/hilog/los_hilog.c index 2c8853be..9fe43ec6 100644 --- a/kernel/extended/hilog/los_hilog.c +++ b/kernel/extended/hilog/los_hilog.c @@ -41,7 +41,7 @@ #include "los_vm_lock.h" #include "user_copy.h" -#define HILOG_BUFFER 4096 +#define HILOG_BUFFER LOSCFG_HILOG_BUFFER_SIZE #define DRIVER_MODE 0666 #define HILOG_DRIVER "/dev/hilog" @@ -255,6 +255,7 @@ static void HiLogCoverOldLog(size_t bufLen) int retval; struct HiLogEntry header; size_t totalSize = bufLen + sizeof(struct HiLogEntry); + int dropLogLines = 0; while (totalSize + g_hiLogDev.size > HILOG_BUFFER) { retval = HiLogReadRingBuffer((unsigned char *)&header, sizeof(header)); @@ -262,9 +263,13 @@ static void HiLogCoverOldLog(size_t bufLen) break; } + dropLogLines++; HiLogBufferDec(sizeof(header)); HiLogBufferDec(header.len); } + if (dropLogLines > 0) { + dprintf("hilog ringbuffer full, drop %d line(s) log", dropLogLines); + } } int HiLogWriteInternal(const char *buffer, size_t bufLen)