Changeset 443 for trunk/kernel/syscalls/sys_trace.c
- Timestamp:
- May 16, 2018, 4:15:22 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_trace.c
r407 r443 1 1 /* 2 * sys_trace.c - show kernel active processes and threads2 * sys_trace.c - activate / desactivate the context switches trace for a given core 3 3 * 4 * Author Alain Greiner (c) (2016,2017 )4 * Author Alain Greiner (c) (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 27 27 #include <thread.h> 28 28 #include <errno.h> 29 #include <shared_syscalls.h> 29 30 #include <syscalls.h> 30 31 31 /////////////////////////////// ///32 int sys_trace( uint32_t operation,33 pid_t pid,34 uint32_t trdid )32 /////////////////////////////// 33 int sys_trace( bool_t active, 34 cxy_t cxy, 35 lid_t lid ) 35 36 { 36 // get extended pointer on target thread 37 xptr_t thread_xp = thread_get_xptr( pid , trdid ); 37 uint32_t ncores; 38 38 39 if( thread_xp == XPTR_NULL ) 39 thread_t * this = CURRENT_THREAD; 40 process_t * process = this->process; 41 42 #if DEBUG_SYS_TRACE 43 uint64_t tm_start; 44 uint64_t tm_end; 45 tm_start = hal_get_cycles(); 46 if( DEBUG_SYS_TRACE < tm_start ) 47 printk("\n[DBG] %s : thread %d enter / process %x / cycle = %d\n", 48 __FUNCTION__, this, this->process->pid, (uint32_t)tm_start ); 49 #endif 50 51 // check cluster identifier 52 if( cluster_is_undefined( cxy ) ) 40 53 { 41 printk("\n[ERROR] in %s : undefined thread for PID = %x / TRDID = %x\n", 42 __FUNCTION__ , pid , trdid ); 43 CURRENT_THREAD->errno = EINVAL; 54 55 #if DEBUG_SYSCALLS_ERROR 56 printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n", 57 __FUNCTION__ , cxy , this->trdid , process->pid ); 58 #endif 59 this->errno = EINVAL; 44 60 return -1; 45 61 } 46 62 47 if( operation == TRACE_OFF ) 63 // check core local index 64 ncores = hal_remote_lw( XPTR( cxy , &LOCAL_CLUSTER->cores_nr ) ); 65 if( lid >= ncores ) 48 66 { 49 // desactivate thread trace TODO50 67 51 printk("\n[DBG] %s : trace OFF for thread %x in process %x\n", 52 __FUNCTION__ , trdid , pid ); 53 } 54 else if( operation == TRACE_ON ) 55 { 56 // activate thread trace TODO 57 58 printk("\n[DBG] %s : trace ON for thread %x in process %x\n", 59 __FUNCTION__ , trdid , pid ); 60 } 61 else 62 { 63 printk("\n[ERROR] in %s : undefined operation\n", __FUNCTION__ ); 64 CURRENT_THREAD->errno = EINVAL; 68 #if DEBUG_SYSCALLS_ERROR 69 printk("\n[ERROR] in %s : illegal lid argument %x / thread %x / process %x\n", 70 __FUNCTION__ , lid , this->trdid , process->pid ); 71 #endif 72 this->errno = EINVAL; 65 73 return -1; 66 74 } 67 75 76 // get local pointer on target core 77 core_t * core = &LOCAL_CLUSTER->core_tbl[lid]; 78 79 // get extended pointer on target scheduler trace field 80 xptr_t trace_xp = XPTR( cxy , &core->scheduler.trace ); 81 82 if ( active ) hal_remote_sw( trace_xp , 1 ); 83 else hal_remote_sw( trace_xp , 0 ); 84 68 85 hal_fence(); 86 87 #if DEBUG_SYS_TRACE 88 tm_end = hal_get_cycles(); 89 if( DEBUG_SYS_TRACE < tm_end ) 90 printk("\n[DBG] %s : thread %x exit / process %x / cost = %d / cycle %d\n", 91 __FUNCTION__, this, this->process->pid, (uint32_t)(tm_end - tm_start) , (uint32_t)tm_end ); 92 #endif 69 93 70 94 return 0;
Note: See TracChangeset
for help on using the changeset viewer.