mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
syscall log: log number of free physical pages before and after every system call
This commit is contained in:
@@ -121,6 +121,7 @@ static char *args[] = {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern size_t freepagecount;
|
||||||
__attribute__((no_caller_saved_registers)) void arch_syscall_log(int syscall, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6) {
|
__attribute__((no_caller_saved_registers)) void arch_syscall_log(int syscall, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6) {
|
||||||
#ifdef SYSCALL_LOGGING
|
#ifdef SYSCALL_LOGGING
|
||||||
char argbuff[768];
|
char argbuff[768];
|
||||||
@@ -130,7 +131,7 @@ __attribute__((no_caller_saved_registers)) void arch_syscall_log(int syscall, ui
|
|||||||
proc_t *proc = thread->proc;
|
proc_t *proc = thread->proc;
|
||||||
|
|
||||||
snprintf(argbuff, 768, syscall < SYSCALL_COUNT ? args[syscall] : "N/A", a1, a2, a3, a4, a5, a6);
|
snprintf(argbuff, 768, syscall < SYSCALL_COUNT ? args[syscall] : "N/A", a1, a2, a3, a4, a5, a6);
|
||||||
snprintf(printbuff, 1024, "\e[92msyscall: pid %d tid %d: %s: %s\n\e[0m", proc->pid, thread->tid, syscall < SYSCALL_COUNT ? name[syscall] : "invalid syscall", argbuff);
|
snprintf(printbuff, 1024, "\e[92msyscall: pid %d tid %d: %s: %s (%lu free pages)\n\e[0m", proc->pid, thread->tid, syscall < SYSCALL_COUNT ? name[syscall] : "invalid syscall", argbuff, freepagecount);
|
||||||
|
|
||||||
LOGSTR(printbuff);
|
LOGSTR(printbuff);
|
||||||
#endif
|
#endif
|
||||||
@@ -143,7 +144,7 @@ __attribute__((no_caller_saved_registers)) void arch_syscall_log_return(uint64_t
|
|||||||
thread_t *thread = _cpu()->thread;
|
thread_t *thread = _cpu()->thread;
|
||||||
proc_t *proc = thread->proc;
|
proc_t *proc = thread->proc;
|
||||||
|
|
||||||
snprintf(printbuff, 1024, "\e[94msyscall return: pid %d tid %d: %lu %lu\n\e[0m", proc->pid, thread->tid, ret, errno);
|
snprintf(printbuff, 1024, "\e[94msyscall return: pid %d tid %d: %lu %lu (%lu free pages)\n\e[0m", proc->pid, thread->tid, ret, errno, freepagecount);
|
||||||
LOGSTR(printbuff);
|
LOGSTR(printbuff);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
uintptr_t hhdmbase;
|
uintptr_t hhdmbase;
|
||||||
static size_t memorysize;
|
static size_t memorysize;
|
||||||
static size_t pagecount;
|
static size_t pagecount;
|
||||||
|
size_t freepagecount;
|
||||||
|
|
||||||
static spinlock_t freelistlock;
|
static spinlock_t freelistlock;
|
||||||
static page_t *freelists[PMM_SECTION_COUNT];
|
static page_t *freelists[PMM_SECTION_COUNT];
|
||||||
@@ -69,6 +70,8 @@ static void insertinfreelist(page_t *page) {
|
|||||||
*list = page;
|
*list = page;
|
||||||
if (page->freenext)
|
if (page->freenext)
|
||||||
page->freenext->freeprev = page;
|
page->freenext->freeprev = page;
|
||||||
|
|
||||||
|
++freepagecount;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void removefromfreelist(page_t *page) {
|
static void removefromfreelist(page_t *page) {
|
||||||
@@ -94,6 +97,8 @@ static void removefromfreelist(page_t *page) {
|
|||||||
|
|
||||||
if (page->freenext)
|
if (page->freenext)
|
||||||
page->freenext->freeprev = page->freeprev;
|
page->freenext->freeprev = page->freeprev;
|
||||||
|
|
||||||
|
--freepagecount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pmm_hold(void *addr) {
|
void pmm_hold(void *addr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user