!735 支持产品定制化hilog内核缓存大小

Merge pull request !735 from shenchenkai/master
This commit is contained in:
openharmony_ci 2021-12-18 06:52:23 +00:00 committed by Gitee
commit 954e7eb0cf
3 changed files with 25 additions and 2 deletions

View File

@ -102,3 +102,6 @@ source "kernel/extended/perf/Kconfig"
######################### config options of lms ######################### ######################### config options of lms #########################
source "kernel/extended/lms/Kconfig" source "kernel/extended/lms/Kconfig"
######################### config options of hilog #########################
source "kernel/extended/hilog/Kconfig"

View File

@ -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

View File

@ -41,7 +41,7 @@
#include "los_vm_lock.h" #include "los_vm_lock.h"
#include "user_copy.h" #include "user_copy.h"
#define HILOG_BUFFER 4096 #define HILOG_BUFFER LOSCFG_HILOG_BUFFER_SIZE
#define DRIVER_MODE 0666 #define DRIVER_MODE 0666
#define HILOG_DRIVER "/dev/hilog" #define HILOG_DRIVER "/dev/hilog"
@ -255,6 +255,7 @@ static void HiLogCoverOldLog(size_t bufLen)
int retval; int retval;
struct HiLogEntry header; struct HiLogEntry header;
size_t totalSize = bufLen + sizeof(struct HiLogEntry); size_t totalSize = bufLen + sizeof(struct HiLogEntry);
int dropLogLines = 0;
while (totalSize + g_hiLogDev.size > HILOG_BUFFER) { while (totalSize + g_hiLogDev.size > HILOG_BUFFER) {
retval = HiLogReadRingBuffer((unsigned char *)&header, sizeof(header)); retval = HiLogReadRingBuffer((unsigned char *)&header, sizeof(header));
@ -262,9 +263,13 @@ static void HiLogCoverOldLog(size_t bufLen)
break; break;
} }
dropLogLines++;
HiLogBufferDec(sizeof(header)); HiLogBufferDec(sizeof(header));
HiLogBufferDec(header.len); HiLogBufferDec(header.len);
} }
if (dropLogLines > 0) {
dprintf("hilog ringbuffer full, drop %d line(s) log", dropLogLines);
}
} }
int HiLogWriteInternal(const char *buffer, size_t bufLen) int HiLogWriteInternal(const char *buffer, size_t bufLen)