diff --git a/arch/x86_64/kernel/memory.c b/arch/x86_64/kernel/memory.c index d0e38470..a25c3b1f 100644 --- a/arch/x86_64/kernel/memory.c +++ b/arch/x86_64/kernel/memory.c @@ -255,6 +255,11 @@ static unsigned long attr_to_l1attr(enum ihk_mc_pt_attribute attr) } } +#define PTLX_SHIFT(index) PTL ## index ## _SHIFT + +#define GET_VIRT_INDEX(virt, index, dest) \ + dest = ((virt) >> PTLX_SHIFT(index)) & (PT_ENTRIES - 1) + #define GET_VIRT_INDICES(virt, l4i, l3i, l2i, l1i) \ l4i = ((virt) >> PTL4_SHIFT) & (PT_ENTRIES - 1); \ l3i = ((virt) >> PTL3_SHIFT) & (PT_ENTRIES - 1); \ @@ -1515,12 +1520,12 @@ static int clear_range_l1(void *args0, pte_t *ptep, uint64_t base, if (page) { dkprintf("%s: page=%p,is_in_memobj=%d,(old & PFL1_DIRTY)=%lx,memobj=%p,args->memobj->flags=%x\n", __FUNCTION__, page, page_is_in_memobj(page), (old & PFL1_DIRTY), args->memobj, args->memobj ? args->memobj->flags : -1); } - if (page && page_is_in_memobj(page) && (old & PFL1_DIRTY) && (args->memobj) && - !(args->memobj->flags & MF_ZEROFILL)) { + if (page && page_is_in_memobj(page) && pte_is_dirty(&old, PTL1_SIZE) && + args->memobj && !(args->memobj->flags & MF_ZEROFILL)) { memobj_flush_page(args->memobj, phys, PTL1_SIZE); } - if (!(old & PFL1_FILEOFF)) { + if (!pte_is_fileoff(&old, PTL1_SIZE)) { if(args->free_physical) { if (!page) { /* Anonymous || !XPMEM attach */ @@ -1582,11 +1587,11 @@ static int clear_range_l2(void *args0, pte_t *ptep, uint64_t base, page = phys_to_page(phys); } - if (page && page_is_in_memobj(page) && (old & PFL2_DIRTY)) { + if (page && page_is_in_memobj(page) && pte_is_dirty(&old, PTL2_SIZE)) { memobj_flush_page(args->memobj, phys, PTL2_SIZE); } - if (!(old & PFL2_FILEOFF)) { + if (!pte_is_fileoff(&old, PTL2_SIZE)) { if(args->free_physical) { if (!page) { /* Anonymous || !XPMEM attach */ @@ -1663,13 +1668,13 @@ static int clear_range_l3(void *args0, pte_t *ptep, uint64_t base, page = phys_to_page(phys); } - if (page && page_is_in_memobj(page) && (old & PFL3_DIRTY)) { + if (page && page_is_in_memobj(page) && pte_is_dirty(&old, PTL3_SIZE)) { memobj_flush_page(args->memobj, phys, PTL3_SIZE); } dkprintf("%s: phys=%ld, pte_get_phys(&old),PTL3_SIZE\n", __FUNCTION__, pte_get_phys(&old)); - if (!(old & PFL3_FILEOFF)) { + if (!pte_is_fileoff(&old, PTL3_SIZE)) { if(args->free_physical) { if (!page) { /* Anonymous || !XPMEM attach */ diff --git a/executer/user/arch/x86_64/arch_syscall.c b/executer/user/arch/x86_64/arch_syscall.c index 4aa63874..bae50d17 100644 --- a/executer/user/arch/x86_64/arch_syscall.c +++ b/executer/user/arch/x86_64/arch_syscall.c @@ -48,7 +48,7 @@ archdep_syscall(struct syscall_wait_desc *w, long *ret) if (*ret >= PATH_MAX) { *ret = -ENAMETOOLONG; } - if (ret < 0) { + if (*ret < 0) { return 0; } __dprintf("open: %s\n", pathbuf); diff --git a/executer/user/libsched_yield.c b/executer/user/libsched_yield.c index 99be0f78..b69af142 100644 --- a/executer/user/libsched_yield.c +++ b/executer/user/libsched_yield.c @@ -11,7 +11,9 @@ typedef int (*int_void_fn)(void); +#if 0 static int_void_fn orig_sched_yield = 0; +#endif int sched_yield(void) { diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 2e3f9c05..edd000ed 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -3333,9 +3333,9 @@ int main_loop(struct thread_data_s *my_thread) } /* Don't print when got a msg to stdout */ - if (!(w.sr.number == __NR_write && w.sr.args[0] == 1)) + if (!(w.sr.number == __NR_write && w.sr.args[0] == 1)) { __dprintf("[%d] got syscall: %ld\n", cpu, w.sr.number); - + } //pthread_mutex_lock(lock); my_thread->remote_tid = w.sr.rtid; @@ -3441,11 +3441,13 @@ int main_loop(struct thread_data_s *my_thread) term = (w.sr.args[0] & 0xff00) >> 8; if(isatty(2)){ if(sig){ - if(!ischild) + if(!ischild) { fprintf(stderr, "Terminate by signal %d\n", sig); + } } - else if(term) + else if(term) { __dprintf("Exit status: %d\n", term); + } } } diff --git a/kernel/ap.c b/kernel/ap.c index 1105672a..0323e707 100644 --- a/kernel/ap.c +++ b/kernel/ap.c @@ -209,8 +209,10 @@ store_fake_cpu_info(struct sysfs_ops *ops0, void *instance, void *buf, static struct fake_cpu_info_ops show_fci_online = { .member = ONLINE, - .ops.show = &show_fake_cpu_info, - .ops.store = &store_fake_cpu_info, + .ops = { + .show = &show_fake_cpu_info, + .store = &store_fake_cpu_info, + }, }; void diff --git a/kernel/mem.c b/kernel/mem.c index b2660548..1b361270 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -547,7 +547,7 @@ static void *mckernel_allocate_aligned_pages_node(int npages, int p2align, ihk_mc_ap_flag flag, int pref_node, int is_user, uintptr_t virt_addr) { unsigned long pa = 0; - int i, node; + int i = 0, node; #ifndef IHK_RBTREE_ALLOCATOR struct ihk_page_allocator_desc *pa_allocator; #endif diff --git a/kernel/profile.c b/kernel/profile.c index d434ad7d..4ebc0b4d 100644 --- a/kernel/profile.c +++ b/kernel/profile.c @@ -72,7 +72,7 @@ char *profile_event_names[] = "" }; -mcs_lock_node_t job_profile_lock = {0, NULL}; +mcs_lock_node_t job_profile_lock = { 0 }; struct profile_event *job_profile_events = NULL; int job_nr_processes = -1; int job_nr_processes_left = -1; @@ -445,7 +445,7 @@ void profile_dealloc_proc_events(struct process *proc) kfree(proc->profile_events); } -void static profile_clear_process(struct process *proc) +static void profile_clear_process(struct process *proc) { proc->profile_elapsed_ts = 0; if (!proc->profile_events) return; @@ -454,7 +454,7 @@ void static profile_clear_process(struct process *proc) sizeof(*proc->profile_events) * PROFILE_EVENT_MAX); } -void static profile_clear_thread(struct thread *thread) +static void profile_clear_thread(struct thread *thread) { thread->profile_start_ts = 0; thread->profile_elapsed_ts = 0;