switch context: Move to arch-dependent (arch_switch_context())

Fujitsu: POSTK_DEBUG_ARCH_DEP_22
Change-Id: I6faf8d9daa1e639350c2cd83db9bb27b9d37ba01
This commit is contained in:
Ken Sato
2018-08-29 11:17:51 +09:00
committed by Masamichi Takagi
parent 895a8c4099
commit 0fdeb254b3
3 changed files with 3 additions and 50 deletions

View File

@@ -1281,7 +1281,6 @@ int ihk_mc_interrupt_cpu(int cpu, int vector)
return 0; return 0;
} }
#ifdef POSTK_DEBUG_ARCH_DEP_22
/* /*
* @ref.impl linux-linaro/arch/arm64/kernel/process.c::tls_thread_switch() * @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; return last;
} }
#endif /* POSTK_DEBUG_ARCH_DEP_22 */
/*@ /*@
@ requires \valid(thread); @ requires \valid(thread);

View File

@@ -94,6 +94,8 @@ int gettime_local_support = 0;
extern int ihk_mc_pt_print_pte(struct page_table *pt, void *virt); extern int ihk_mc_pt_print_pte(struct page_table *pt, void *virt);
extern int kprintf(const char *format, ...); extern int kprintf(const char *format, ...);
extern int interrupt_from_user(void *); 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{ static struct idt_entry{
uint32_t desc[4]; uint32_t desc[4];
@@ -1642,9 +1644,6 @@ int ihk_mc_interrupt_cpu(int cpu, int vector)
return 0; 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 *arch_switch_context(struct thread *prev, struct thread *next)
{ {
struct thread *last; struct thread *last;
@@ -1666,7 +1665,7 @@ struct thread *arch_switch_context(struct thread *prev, struct thread *next)
} }
#ifdef PROFILE_ENABLE #ifdef PROFILE_ENABLE
if (prev->profile && prev->profile_start_ts != 0) { if (prev && prev->profile && prev->profile_start_ts != 0) {
prev->profile_elapsed_ts += prev->profile_elapsed_ts +=
(rdtsc() - prev->profile_start_ts); (rdtsc() - prev->profile_start_ts);
prev->profile_start_ts = 0; prev->profile_start_ts = 0;
@@ -1685,7 +1684,6 @@ struct thread *arch_switch_context(struct thread *prev, struct thread *next)
} }
return last; return last;
} }
#endif
/*@ /*@
@ requires \valid(thread); @ requires \valid(thread);

View File

@@ -64,9 +64,7 @@ static void dump_tree(struct process_vm *vm) {
static void dump_tree(struct process_vm *vm) {} static void dump_tree(struct process_vm *vm) {}
#endif #endif
#ifdef POSTK_DEBUG_ARCH_DEP_22
extern struct thread *arch_switch_context(struct thread *prev, struct thread *next); 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 long alloc_debugreg(struct thread *proc);
extern void save_debugreg(unsigned long *debugreg); extern void save_debugreg(unsigned long *debugreg);
extern void restore_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 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_create_thread(struct thread *);
extern void procfs_delete_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; struct list_head resource_set_list;
mcs_rwlock_lock_t resource_set_lock; mcs_rwlock_lock_t resource_set_lock;
@@ -3245,44 +3239,7 @@ void schedule(void)
next->vm->address_space->page_table) next->vm->address_space->page_table)
ihk_mc_load_page_table(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); 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 * We must hold the lock throughout the context switch, otherwise