Changeset 641 for trunk/kernel/kern
- Timestamp:
- Oct 10, 2019, 1:42:04 PM (5 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/do_syscall.c
r637 r641 110 110 sys_get_best_core, // 53 111 111 sys_get_nb_cores, // 54 112 sys_get_thread_info, // 55 112 113 }; 113 114 … … 177 178 case SYS_GET_BEST_CORE: return "GET_BEST_CORE"; // 53 178 179 case SYS_GET_NB_CORES: return "GET_NB_CORES"; // 54 180 case SYS_GET_THREAD_INFO: return "GET_THREAD_INFO"; // 55 179 181 180 182 default: return "undefined"; -
trunk/kernel/kern/rpc.c
r640 r641 349 349 rpc_server[index]( desc_xp ); 350 350 351 // update responses counter 352 responses = hal_remote_atomic_add( rsp_xp , -1 ); 353 351 354 #if DEBUG_RPC_SERVER_GENERIC 352 355 cycle = (uint32_t)hal_get_cycles(); 353 356 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 354 printk("\n[%s] RPC thread[%x,%x] completes rpc %s / client_cxy %x/ cycle %d\n",355 __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], desc_cxy, cycle );357 printk("\n[%s] RPC thread[%x,%x] completes rpc %s / responses %d / cycle %d\n", 358 __FUNCTION__, server_ptr->process->pid, server_ptr->trdid, rpc_str[index], responses, cycle ); 356 359 #endif 357 360 // decrement expected responses counter 358 responses = hal_remote_atomic_add( rsp_xp , -1 );359 360 361 // unblock client thread if last response 361 362 if( responses == 1 ) … … 2388 2389 2389 2390 ////////////////////////////////////////////////////////// 2390 void rpc_vmm_resize_vseg_client( cxy_t 2391 struct process_s * process,2392 struct vseg_s * vseg,2393 intptr_t 2394 intptr_t 2391 void rpc_vmm_resize_vseg_client( cxy_t cxy, 2392 pid_t pid, 2393 intptr_t base, 2394 intptr_t new_base, 2395 intptr_t new_size ) 2395 2396 { 2396 2397 #if DEBUG_RPC_VMM_RESIZE_VSEG … … 2411 2412 2412 2413 // set input arguments in RPC descriptor 2413 rpc.args[0] = (uint64_t) (intptr_t)process;2414 rpc.args[1] = (uint64_t) (intptr_t)vseg;2414 rpc.args[0] = (uint64_t)pid; 2415 rpc.args[1] = (uint64_t)base; 2415 2416 rpc.args[2] = (uint64_t)new_base; 2416 2417 rpc.args[3] = (uint64_t)new_size; … … 2438 2439 #endif 2439 2440 2441 pid_t pid; 2440 2442 process_t * process; 2443 intptr_t base; 2441 2444 vseg_t * vseg; 2442 2445 intptr_t new_base; … … 2448 2451 2449 2452 // get arguments from client RPC descriptor 2450 process = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 2451 vseg = (vseg_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 2452 new_base = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 2453 new_size = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); 2453 pid = (pid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 2454 base = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 2455 new_base = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[2] ) ); 2456 new_size = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[3] ) ); 2457 2458 // get local pointer on target process 2459 process = cluster_get_local_process_from_pid( pid ); 2460 2461 // get target vseg from vaddr 2462 vmm_get_vseg( process , base , &vseg ); 2454 2463 2455 2464 // call relevant kernel function … … 2474 2483 ///////////////////////////////////////////////// 2475 2484 void rpc_vmm_remove_vseg_client( cxy_t cxy, 2476 p rocess_t * process,2477 vseg_t * vseg)2485 pid_t pid, 2486 intptr_t base ) 2478 2487 { 2479 2488 #if DEBUG_RPC_VMM_REMOVE_VSEG … … 2494 2503 2495 2504 // set input arguments in RPC descriptor 2496 rpc.args[0] = (uint64_t) (intptr_t)process;2497 rpc.args[1] = (uint64_t) (intptr_t)vseg;2505 rpc.args[0] = (uint64_t)pid; 2506 rpc.args[1] = (uint64_t)base; 2498 2507 2499 2508 // register RPC request in remote RPC fifo … … 2519 2528 #endif 2520 2529 2530 pid_t pid; 2531 intptr_t vaddr; 2521 2532 process_t * process; 2522 2533 vseg_t * vseg; … … 2527 2538 2528 2539 // get arguments from RPC descriptor 2529 process = (process_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 2530 vseg = (vseg_t *)(intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 2540 pid = (pid_t) hal_remote_l64( XPTR( client_cxy , &desc->args[0] ) ); 2541 vaddr = (intptr_t)hal_remote_l64( XPTR( client_cxy , &desc->args[1] ) ); 2542 2543 // get local pointer on target process 2544 process = cluster_get_local_process_from_pid( pid ); 2545 2546 // get target vseg from vaddr 2547 vmm_get_vseg( process , vaddr , &vseg ); 2531 2548 2532 2549 // call relevant kernel function -
trunk/kernel/kern/rpc.h
r640 r641 130 130 * the caller. It exit with a Panic message if remote fifo is still full after 131 131 * (CONFIG_RPC_PUT_MAX_ITERATIONS) retries. 132 * - When the RPC <blocking> field is true, this function blocks and deschedule .133 * It returns only when the server acknowledges the RPC by writing in the RPC134 * "response" field, and unblocks the client.132 * - When the RPC <blocking> field is true, this function blocks and deschedule 133 * the client thread. It returns only when the server completes the RPC and 134 * unblocks the client thread. 135 135 * - When the <blocking> field is false, this function returns as soon as the RPC 136 * has been registered in the FIFO, and the server thread must directly signal137 * completion to the client thread.136 * has been registered in the FIFO, and the client thread must block itself when 137 * all RPCS have been registered in all target clusters. 138 138 *********************************************************************************** 139 139 * @ cxy : server cluster identifier … … 520 520 521 521 /*********************************************************************************** 522 * [25] The RPC_VMM_RESIZE_VSEG allows a client thread to request a remote vseg 523 * resize. Both the VSL and the GPT are updated in the remote cluster. 522 * [25] The RPC_VMM_RESIZE_VSEG allows a client thread to request a remote cluster 523 * to resize a vseg identified by the <base> argument in a process descriptor 524 * identified by the <pid> argument, as defined by the <new_base> and <new_size> 525 * arguments. Both the VSL and the GPT are updated in the remote cluster. 524 526 *********************************************************************************** 525 527 * @ cxy : server cluster identifier. 526 * @ p rocess : [in] local pointer on remote process.527 * @ vseg : [in] local pointer on remote vseg.528 * @ new_base : [in] new vseg base address.528 * @ pid : [in] process identifier. 529 * @ base : [in] vseg base. 530 * @ new_base : [in] new vseg base. 529 531 * @ new_size : [in] new vseg size. 530 532 **********************************************************************************/ 531 533 void rpc_vmm_resize_vseg_client( cxy_t cxy, 532 struct process_s * process,533 struct vseg_s * vseg,534 pid_t pid, 535 intptr_t base, 534 536 intptr_t new_base, 535 537 intptr_t new_size ); … … 538 540 539 541 /*********************************************************************************** 540 * [26] The RPC_VMM_REMOVE_VSEG allows a client thread to request a remote vseg 541 * delete. Bothe the VSL and the GPT are updated in the remote cluster. 542 *********************************************************************************** 543 * @ cxy : server cluster identifier. 544 * @ process : [in] local pointer on remote process. 545 * @ vseg : [in] local pointer on remote vseg. 546 **********************************************************************************/ 547 void rpc_vmm_remove_vseg_client( cxy_t cxy, 548 struct process_s * process, 549 struct vseg_s * vseg ); 542 * [26] The RPC_VMM_REMOVE_VSEG allows a client thread to request a remote cluster 543 * to delete a vseg identified by the <vaddr> argument in a process descriptor 544 * identified by the <pid> argument. 545 * Both the VSL and the GPT are updated in the remote cluster. 546 *********************************************************************************** 547 * @ cxy : server cluster identifier. 548 * @ pid : [in] process identifier. 549 * @ base : [in] vseg base. 550 **********************************************************************************/ 551 void rpc_vmm_remove_vseg_client( cxy_t cxy, 552 pid_t pid, 553 intptr_t base ); 550 554 551 555 void rpc_vmm_remove_vseg_server( xptr_t xp ); -
trunk/kernel/kern/scheduler.c
r640 r641 255 255 __FUNCTION__, process->pid, thread->trdid, local_cxy, thread->core->lid, cycle ); 256 256 #endif 257 258 #if CONFIG_INSTRUMENTATION_PGFAULTS259 uint32_t local_nr = thread->info.local_pgfault_nr;260 uint32_t local_cost = (local_nr == 0) ? 0 : (thread->info.local_pgfault_cost / local_nr);261 uint32_t global_nr = thread->info.global_pgfault_nr;262 uint32_t global_cost = (global_nr == 0) ? 0 : (thread->info.global_pgfault_cost / global_nr);263 uint32_t false_nr = thread->info.false_pgfault_nr;264 uint32_t false_cost = (false_nr == 0) ? 0 : (thread->info.false_pgfault_cost / false_nr);265 printk("\n***** page faults for thread[%x,%x]\n"266 " - %d local : %d cycles\n"267 " - %d global : %d cycles\n"268 " - %d false : %d cycles\n",269 process->pid, thread->trdid,270 local_nr, local_cost,271 global_nr, global_cost,272 false_nr, false_cost );273 #endif274 257 // destroy process descriptor if last thread 275 258 if( count == 1 ) -
trunk/kernel/kern/thread.c
r640 r641 183 183 dqdt_increment_threads(); 184 184 185 #if CONFIG_INSTRUMENTATION_PGFAULTS 186 thread->info.false_pgfault_nr = 0; 187 thread->info.false_pgfault_cost = 0; 188 thread->info.false_pgfault_max = 0; 189 thread->info.local_pgfault_nr = 0; 190 thread->info.local_pgfault_cost = 0; 191 thread->info.local_pgfault_max = 0; 192 thread->info.global_pgfault_nr = 0; 193 thread->info.global_pgfault_cost = 0; 194 thread->info.global_pgfault_max = 0; 195 #endif 196 185 197 #if DEBUG_THREAD_INIT 186 198 cycle = (uint32_t)hal_get_cycles(); … … 890 902 core_t * core = thread->core; 891 903 892 893 #if DEBUG_THREAD_DESTROY || CONFIG_INSTRUMENTATION_PGFAULTS 904 #if DEBUG_THREAD_DESTROY 894 905 uint32_t cycle; 895 906 thread_t * this = CURRENT_THREAD; … … 908 919 #if CONFIG_INSTRUMENTATION_PGFAULTS 909 920 process->vmm.false_pgfault_nr += thread->info.false_pgfault_nr; 921 process->vmm.false_pgfault_cost += thread->info.false_pgfault_cost; 910 922 process->vmm.local_pgfault_nr += thread->info.local_pgfault_nr; 923 process->vmm.local_pgfault_cost += thread->info.local_pgfault_cost; 911 924 process->vmm.global_pgfault_nr += thread->info.global_pgfault_nr; 912 process->vmm.false_pgfault_cost += thread->info.false_pgfault_cost;913 process->vmm.local_pgfault_cost += thread->info.local_pgfault_cost;914 925 process->vmm.global_pgfault_cost += thread->info.global_pgfault_cost; 915 926 #endif … … 917 928 #if (CONFIG_INSTRUMENTATION_PGFAULTS & 1) 918 929 uint32_t false_nr = thread->info.false_pgfault_nr; 930 uint32_t false_cost = thread->info.false_pgfault_cost; 931 uint32_t false_max = thread->info.false_pgfault_max; 932 uint32_t false_one = false_nr ? (false_cost / false_nr ) : 0; 933 919 934 uint32_t local_nr = thread->info.local_pgfault_nr; 935 uint32_t local_cost = thread->info.local_pgfault_cost; 936 uint32_t local_max = thread->info.local_pgfault_max; 937 uint32_t local_one = local_nr ? (local_cost / local_nr ) : 0; 938 920 939 uint32_t global_nr = thread->info.global_pgfault_nr; 921 uint32_t false_cost = thread->info.false_pgfault_cost;922 uint32_t local_cost = thread->info.local_pgfault_cost;923 940 uint32_t global_cost = thread->info.global_pgfault_cost; 924 printk("***** thread[%x,%x] page-faults\n" 925 " - false %d ( %d cycles )\n" 926 " - local %d ( %d cycles )\n" 927 " - global %d ( %d cycles )\n", 928 this->process->pid, this->trdid, 929 false_nr , false_cost / false_nr, 930 local_nr , local_cost / local_nr, 931 global_nr, global_cost / global_nr ); 941 uint32_t global_max = thread->info.global_pgfault_max; 942 uint32_t global_one = global_nr ? (global_cost / global_nr) : 0; 943 944 printk("\n***** thread[%x,%x] page-faults\n" 945 " - false : %d events / cost %d cycles / max %d cycles\n" 946 " - local : %d events / cost %d cycles / max %d cycles\n" 947 " - global : %d events / cost %d cycles / max %d cycles\n", 948 thread->process->pid, thread->trdid, 949 false_nr , false_one , false_max, 950 local_nr , local_one , local_max, 951 global_nr, global_one, global_max ); 932 952 #endif 933 953 -
trunk/kernel/kern/thread.h
r635 r641 28 28 #include <hal_kernel_types.h> 29 29 #include <shared_syscalls.h> 30 #include <shared_almos.h> 30 31 #include <hal_special.h> 31 32 #include <hal_kentry.h> … … 95 96 96 97 /*************************************************************************************** 97 * This structure defines thread instrumentation informations.98 **************************************************************************************/99 100 typedef struct thread_info_s101 {102 uint32_t false_pgfault_nr; /*! number of local page fault */103 uint32_t local_pgfault_nr; /*! number of local page fault */104 uint32_t global_pgfault_nr; /*! number of global page fault */105 uint32_t false_pgfault_cost; /*! cumulated cost */106 uint32_t local_pgfault_cost; /*! cumulated cost */107 uint32_t global_pgfault_cost; /*! cumulated cost */108 109 cycle_t last_cycle; /*! last cycle counter value (date) */110 cycle_t usr_cycles; /*! user execution duration (cycles) */111 cycle_t sys_cycles; /*! system execution duration (cycles) */112 }113 thread_info_t;114 115 /***************************************************************************************116 98 * This structure defines a thread descriptor. 117 99 * It is used for both the user threads and the kernel threads. … … 119 101 * - The TRDID 16 LSB bits contain the LTID (Local Thread Index). 120 102 * - The TRDID 16 MSB bits contain the CXY of cluster containing the thread. 121 * The main thread LTID value is always 0.103 * For the main thread the LTID value is always 0, in the owner cluster. 122 104 * The LTID is used to index the th_tbl[] array in the local process descriptor. 123 105 * This TRDID is computed by the process_register_thread() function, when the user 124 106 * thread is registered in the local copy of the process descriptor. 125 107 * 126 * WARNING (1) Don't modify the first 4 fields order, as this order is used by the 127 * hal_kentry assembly code for the TSAR architectures. 128 * 129 * WARNING (2) Most of the thread state is private and accessed only by this thread, 130 * but some fields are shared, and can be modified by other threads. 131 * - the "blocked" bit_vector can be modified by another thread 132 * running in another cluster (using atomic instructions), 133 * to change this thread scheduling status. 134 * - the "flags" bit_vector can be modified by another thread 135 * running in another cluster (using atomic instructions), 136 * to register requests such as ACK or DELETE. 137 * - the "join_xp" field can be modified by the joining thread, 138 * and this rendez-vous is protected by the dedicated "join_lock". 139 * 140 * WARNING (3) When this thread is blocked on a shared resource (queuelock, condvar, 141 * or chdev), it registers in the associated waiting queue, using the 142 * "wait_list" (local list) or "wait_xlist" (trans-cluster list) fields. 108 * Implementation notes: 109 * 110 * (1) Don't modify the first 4 fields order, as this order is used by the 111 * hal_kentry assembly code for the TSAR architectures. 112 * 113 * (2) Most of the thread state is private and accessed only by this thread, 114 * but some fields are shared, and can be modified by other threads. 115 * - the "blocked" bit_vector can be modified by another thread 116 * running in another cluster (using atomic instructions), 117 * to change this thread scheduling status. 118 * - the "flags" bit_vector can be modified by another thread 119 * running in another cluster (using atomic instructions), 120 * to register requests such as ACK or DELETE. 121 * - the "join_xp" field can be modified by the joining thread, 122 * and this rendez-vous is protected by the dedicated "join_lock". 123 * 124 * (3) When this thread is blocked on a shared resource (queuelock, condvar, 125 * or chdev), it registers in the associated waiting queue, using the 126 * "wait_list" (local list) or "wait_xlist" (trans-cluster list) fields. 127 * 128 * (4) The thread_info_t structure is defined in the shared_almos.h file in the 129 * /kernel/syscall/shared_include directory. 143 130 **************************************************************************************/ 144 131
Note: See TracChangeset
for help on using the changeset viewer.