From 0fdeb254b393e06aec3c9cd12c1530aaa920e3d8 Mon Sep 17 00:00:00 2001 From: Ken Sato Date: Wed, 29 Aug 2018 11:17:51 +0900 Subject: [PATCH] switch context: Move to arch-dependent (arch_switch_context()) Fujitsu: POSTK_DEBUG_ARCH_DEP_22 Change-Id: I6faf8d9daa1e639350c2cd83db9bb27b9d37ba01 --- arch/arm64/kernel/cpu.c | 2 -- arch/x86_64/kernel/cpu.c | 8 +++----- kernel/process.c | 43 ---------------------------------------- 3 files changed, 3 insertions(+), 50 deletions(-) diff --git a/arch/arm64/kernel/cpu.c b/arch/arm64/kernel/cpu.c index 2c834af7..6701c7f1 100644 --- a/arch/arm64/kernel/cpu.c +++ b/arch/arm64/kernel/cpu.c @@ -1281,7 +1281,6 @@ int ihk_mc_interrupt_cpu(int cpu, int vector) return 0; } -#ifdef POSTK_DEBUG_ARCH_DEP_22 /* * @ref.impl linux-linaro/arch/arm64/kernel/process.c::tls_thread_switch() */ @@ -1357,7 +1356,6 @@ struct thread *arch_switch_context(struct thread *prev, struct thread *next) return last; } -#endif /* POSTK_DEBUG_ARCH_DEP_22 */ /*@ @ requires \valid(thread); diff --git a/arch/x86_64/kernel/cpu.c b/arch/x86_64/kernel/cpu.c index 47df0cde..3570903e 100644 --- a/arch/x86_64/kernel/cpu.c +++ b/arch/x86_64/kernel/cpu.c @@ -94,6 +94,8 @@ int gettime_local_support = 0; extern int ihk_mc_pt_print_pte(struct page_table *pt, void *virt); extern int kprintf(const char *format, ...); extern int interrupt_from_user(void *); +extern void perf_start(struct mc_perf_event *event); +extern void perf_reset(struct mc_perf_event *event); static struct idt_entry{ uint32_t desc[4]; @@ -1642,9 +1644,6 @@ int ihk_mc_interrupt_cpu(int cpu, int vector) return 0; } -#ifdef POSTK_DEBUG_ARCH_DEP_22 -extern void perf_start(struct mc_perf_event *event); -extern void perf_reset(struct mc_perf_event *event); struct thread *arch_switch_context(struct thread *prev, struct thread *next) { struct thread *last; @@ -1666,7 +1665,7 @@ struct thread *arch_switch_context(struct thread *prev, struct thread *next) } #ifdef PROFILE_ENABLE - if (prev->profile && prev->profile_start_ts != 0) { + if (prev && prev->profile && prev->profile_start_ts != 0) { prev->profile_elapsed_ts += (rdtsc() - prev->profile_start_ts); prev->profile_start_ts = 0; @@ -1685,7 +1684,6 @@ struct thread *arch_switch_context(struct thread *prev, struct thread *next) } return last; } -#endif /*@ @ requires \valid(thread); diff --git a/kernel/process.c b/kernel/process.c index 4b6593a2..c4739672 100644 --- a/kernel/process.c +++ b/kernel/process.c @@ -64,9 +64,7 @@ static void dump_tree(struct process_vm *vm) { static void dump_tree(struct process_vm *vm) {} #endif -#ifdef POSTK_DEBUG_ARCH_DEP_22 extern struct thread *arch_switch_context(struct thread *prev, struct thread *next); -#endif /* POSTK_DEBUG_ARCH_DEP_22 */ extern long alloc_debugreg(struct thread *proc); extern void save_debugreg(unsigned long *debugreg); extern void restore_debugreg(unsigned long *debugreg); @@ -87,10 +85,6 @@ int ptrace_detach(int pid, int data); extern unsigned long do_kill(struct thread *, int pid, int tid, int sig, struct siginfo *info, int ptracecont); extern void procfs_create_thread(struct thread *); extern void procfs_delete_thread(struct thread *); -#ifndef POSTK_DEBUG_ARCH_DEP_22 -extern void perf_start(struct mc_perf_event *event); -extern void perf_reset(struct mc_perf_event *event); -#endif /* !POSTK_DEBUG_ARCH_DEP_22 */ struct list_head resource_set_list; mcs_rwlock_lock_t resource_set_lock; @@ -3245,44 +3239,7 @@ void schedule(void) next->vm->address_space->page_table) ihk_mc_load_page_table(next->vm->address_space->page_table); -#ifdef POSTK_DEBUG_ARCH_DEP_22 last = arch_switch_context(prev, next); -#else - dkprintf("[%d] schedule: tlsblock_base: 0x%lX\n", - ihk_mc_get_processor_id(), next->tlsblock_base); - - /* Set up new TLS.. */ - ihk_mc_init_user_tlsbase(next->uctx, next->tlsblock_base); - - /* Performance monitoring inherit */ - if(next->proc->monitoring_event) { - if(next->proc->perf_status == PP_RESET) - perf_reset(next->proc->monitoring_event); - if(next->proc->perf_status != PP_COUNT) { - perf_reset(next->proc->monitoring_event); - perf_start(next->proc->monitoring_event); - } - } - -#ifdef PROFILE_ENABLE - if (prev && prev->profile && prev->profile_start_ts != 0) { - prev->profile_elapsed_ts += - (rdtsc() - prev->profile_start_ts); - prev->profile_start_ts = 0; - } - - if (next->profile && next->profile_start_ts == 0) { - next->profile_start_ts = rdtsc(); - } -#endif - - if (prev) { - last = ihk_mc_switch_context(&prev->ctx, &next->ctx, prev); - } - else { - last = ihk_mc_switch_context(NULL, &next->ctx, prev); - } -#endif /* POSTK_DEBUG_ARCH_DEP_22 */ /* * We must hold the lock throughout the context switch, otherwise