Changeset 438 for trunk/kernel/kern/dqdt.c
- Timestamp:
- Apr 4, 2018, 2:49:02 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/dqdt.c
r437 r438 28 28 #include <hal_remote.h> 29 29 #include <printk.h> 30 #include <chdev.h> 30 31 #include <cluster.h> 31 32 #include <bits.h> … … 33 34 34 35 35 /////////////////////////////////////////// 36 void dqdt_local_print( dqdt_node_t * node ) 37 { 38 printk("DQDT node : level = %d / cluster = %x / threads = %x / pages = %x\n", 39 node->level, 40 local_cxy, 41 node->threads, 42 node->pages ); 43 } 44 45 ///////////////////////////////////////// 46 void dqdt_global_print( xptr_t node_xp ) 36 /////////////////////////////////////////////////////////////////////////////////////////// 37 // Extern variables 38 /////////////////////////////////////////////////////////////////////////////////////////// 39 40 extern chdev_directory_t chdev_dir; // defined in chdev.h / allocated in kernel_init.c 41 42 43 /////////////////////////////////////////////////////////////////////////////////////////// 44 // This static recursive function traverse the DQDT quad-tree from root to bottom. 45 /////////////////////////////////////////////////////////////////////////////////////////// 46 static void dqdt_recursive_print( xptr_t node_xp ) 47 47 { 48 48 uint32_t i; 49 dqdt_node_t local_node; 50 51 // get root node local copy 52 hal_remote_memcpy( XPTR( local_cxy , &local_node ), node_xp , sizeof(dqdt_node_t) ); 53 54 // display DQDT node content 55 dqdt_local_print( &local_node ); 49 dqdt_node_t node; 50 51 // get node local copy 52 hal_remote_memcpy( XPTR( local_cxy , &node ), node_xp , sizeof(dqdt_node_t) ); 53 54 // display node content 55 nolock_printk("- level %d in cluster %x (node %x) : threads = %x / pages = %x\n", 56 node.level, GET_CXY( node_xp ), GET_PTR( node_xp ), node.threads, node.pages ); 56 57 57 58 // recursive call on children if node is not terminal 58 if ( local_node.level > 0 )59 if ( node.level > 0 ) 59 60 { 60 61 for ( i = 0 ; i < 4 ; i++ ) 61 62 { 62 if ( local_node.children[i] != XPTR_NULL ) 63 dqdt_global_print( local_node.children[i] ); 63 if ( node.children[i] != XPTR_NULL ) dqdt_recursive_print( node.children[i] ); 64 64 } 65 65 } 66 } 67 68 /////////////////// 69 void dqdt_display() 70 { 71 reg_t save_sr; 72 73 // build extended pointer on DQDT root node 74 cluster_t * cluster = LOCAL_CLUSTER; 75 uint32_t level = cluster->dqdt_root_level; 76 xptr_t root_xp = XPTR( 0 , &cluster->dqdt_tbl[level] ); 77 78 // get pointers on TXT0 chdev 79 xptr_t txt0_xp = chdev_dir.txt_tx[0]; 80 cxy_t txt0_cxy = GET_CXY( txt0_xp ); 81 chdev_t * txt0_ptr = GET_PTR( txt0_xp ); 82 83 // get extended pointer on remote TXT0 chdev lock 84 xptr_t lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock ); 85 86 // get TXT0 lock in busy waiting mode 87 remote_spinlock_lock_busy( lock_xp , &save_sr ); 88 89 // print header 90 nolock_printk("\n***** DQDT state\n\n"); 91 92 // call recursive function 93 dqdt_recursive_print( root_xp ); 94 95 // release lock 96 remote_spinlock_unlock_busy( lock_xp , save_sr ); 66 97 } 67 98 … … 161 192 } // end dqdt_init() 162 193 163 164 /////////////////////////////////////////////////////////////////////////// 165 // This recursive function is called by the dqdt_global_update() function. 194 /////////////////////////////////////////////////////////////////////////// 195 // This recursive function is called by the dqdt_update_threads() function. 166 196 // It traverses the quad tree from clusters to root. 167 197 /////////////////////////////////////////////////////////////////////////// 168 static void dqdt_propagate( xptr_t node, // extended pointer on current node 169 int32_t threads_var, // number of threads variation 170 int32_t pages_var ) // number of pages variation 198 // @ node : extended pointer on current node 199 // @ increment : number of threads variation 200 /////////////////////////////////////////////////////////////////////////// 201 static void dqdt_propagate_threads( xptr_t node, 202 int32_t increment ) 171 203 { 172 204 // get current node cluster identifier and local pointer 173 cxy_t cxy = (cxy_t)GET_CXY( node );174 dqdt_node_t * ptr = (dqdt_node_t *)GET_PTR( node );205 cxy_t cxy = GET_CXY( node ); 206 dqdt_node_t * ptr = GET_PTR( node ); 175 207 176 208 // update current node threads number 177 hal_remote_atomic_add( XPTR( cxy , &ptr->threads ) , threads_var ); 178 179 // update current node pages number 180 hal_remote_atomic_add( XPTR( cxy , &ptr->pages ) , pages_var ); 209 hal_remote_atomic_add( XPTR( cxy , &ptr->threads ) , increment ); 181 210 182 211 // get extended pointer on parent node … … 184 213 185 214 // propagate if required 186 if ( parent != XPTR_NULL ) 187 { 188 dqdt_propagate( parent, threads_var, pages_var ); 189 } 190 } 191 192 ///////////////////////// 193 void dqdt_global_update() 215 if ( parent != XPTR_NULL ) dqdt_propagate_threads( parent, increment ); 216 } 217 218 /////////////////////////////////////////////////////////////////////////// 219 // This recursive function is called by the dqdt_update_pages() function. 220 // It traverses the quad tree from clusters to root. 221 /////////////////////////////////////////////////////////////////////////// 222 // @ node : extended pointer on current node 223 // @ increment : number of pages variation 224 /////////////////////////////////////////////////////////////////////////// 225 static void dqdt_propagate_pages( xptr_t node, 226 int32_t increment ) 227 { 228 // get current node cluster identifier and local pointer 229 cxy_t cxy = GET_CXY( node ); 230 dqdt_node_t * ptr = GET_PTR( node ); 231 232 // update current node threads number 233 hal_remote_atomic_add( XPTR( cxy , &ptr->pages ) , increment ); 234 235 // get extended pointer on parent node 236 xptr_t parent = (xptr_t)hal_remote_lwd( XPTR( cxy , &ptr->parent ) ); 237 238 // propagate if required 239 if ( parent != XPTR_NULL ) dqdt_propagate_pages( parent, increment ); 240 } 241 242 ///////////////////////////////////////////// 243 void dqdt_update_threads( int32_t increment ) 194 244 { 195 245 cluster_t * cluster = LOCAL_CLUSTER; 196 246 dqdt_node_t * node = &cluster->dqdt_tbl[0]; 197 247 198 // get variations199 int32_t threads_var = cluster->threads_var;200 int32_t pages_var = cluster->pages_var;201 202 // propagate this variation to DQDT upper levels203 if( (threads_var || pages_var) && (node->parent != XPTR_NULL) )204 {205 dqdt_propagate( node->parent, threads_var, pages_var );206 }207 208 // update variations209 hal_atomic_add( &cluster->threads_var , -threads_var );210 hal_atomic_add( &cluster->pages_var , -pages_var );211 }212 213 ///////////////////////////////////////////////////214 void dqdt_local_update_threads( int32_t increment )215 {216 cluster_t * cluster = LOCAL_CLUSTER;217 218 // register change for future propagation in DQDT219 hal_atomic_add( &cluster->threads_var , increment );220 221 248 // update DQDT node level 0 222 hal_atomic_add( &cluster->dqdt_tbl[0].threads , increment ); 223 } 224 225 ///////////////////////////////////////////////// 226 void dqdt_local_update_pages( int32_t increment ) 227 { 228 cluster_t * cluster = LOCAL_CLUSTER; 229 230 // register change for future propagation in DQDT 231 hal_atomic_add( &cluster->pages_var , increment ); 249 hal_atomic_add( &node->threads , increment ); 250 251 // propagate to DQDT upper levels 252 if( node->parent != XPTR_NULL ) dqdt_propagate_threads( node->parent , increment ); 253 } 254 255 /////////////////////////////////////////// 256 void dqdt_update_pages( int32_t increment ) 257 { 258 cluster_t * cluster = LOCAL_CLUSTER; 259 dqdt_node_t * node = &cluster->dqdt_tbl[0]; 232 260 233 261 // update DQDT node level 0 234 hal_atomic_add( &cluster->dqdt_tbl[0].pages , increment ); 235 } 262 hal_atomic_add( &node->pages , increment ); 263 264 // propagate to DQDT upper levels 265 if( node->parent != XPTR_NULL ) dqdt_propagate_pages( node->parent , increment ); 266 } 267 236 268 237 269 //////////////////////////////////////////////////////////////////////////////// … … 289 321 cluster_t * cluster = LOCAL_CLUSTER; 290 322 uint32_t level = cluster->dqdt_root_level; 291 xptr_t root 323 xptr_t root_xp = XPTR( 0 , &cluster->dqdt_tbl[level] ); 292 324 293 325 // call recursive function 294 return dqdt_select_cluster( root , false );326 return dqdt_select_cluster( root_xp , false ); 295 327 } 296 328 … … 301 333 cluster_t * cluster = LOCAL_CLUSTER; 302 334 uint32_t level = cluster->dqdt_root_level; 303 xptr_t root 335 xptr_t root_xp = XPTR( 0 , &cluster->dqdt_tbl[level] ); 304 336 305 337 // call recursive function 306 return dqdt_select_cluster( root , true );307 } 308 338 return dqdt_select_cluster( root_xp , true ); 339 } 340
Note: See TracChangeset
for help on using the changeset viewer.