35
35
36
36
#include "sched.h"
37
37
38
- #define print_each 10000
38
+ #define print_each 1000
39
+ #define threshold print_each * 1000
39
40
40
41
static u64 print_counter = 0 ;
41
42
@@ -494,9 +495,7 @@ static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
494
495
struct rb_node * parent = NULL ;
495
496
struct sched_entity * entry ;
496
497
int leftmost = 1 ;
497
- // // aghax
498
- // struct rq* rq = rq_of(cfs_rq);
499
- // se->rank = rq->rq_rank++;
498
+
500
499
501
500
/*
502
501
* Find the right place in the rbtree:
@@ -3206,6 +3205,7 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
3206
3205
{
3207
3206
// =e
3208
3207
struct sched_entity * parent_se ;
3208
+ int this_cpu = smp_processor_id ();
3209
3209
//
3210
3210
/* 'current' is not kept within the tree. */
3211
3211
if (se -> on_rq ) {
@@ -3221,7 +3221,7 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
3221
3221
if (entity_is_task (se )) {
3222
3222
parent_se = se -> real_parent ;
3223
3223
list_del (& se -> node );
3224
- parent_se -> children_size -- ;
3224
+ parent_se -> children_size [ this_cpu ] -- ;
3225
3225
}
3226
3226
//
3227
3227
}
@@ -3309,6 +3309,7 @@ static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
3309
3309
{
3310
3310
// =e
3311
3311
struct sched_entity * prev_parent_se ;
3312
+ int this_cpu = smp_processor_id ();
3312
3313
//
3313
3314
/*
3314
3315
* If still on the runqueue then deactivate_task()
@@ -3328,20 +3329,17 @@ static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
3328
3329
/* in !on_rq case, update occurred at dequeue */
3329
3330
update_load_avg (prev , 0 );
3330
3331
3331
-
3332
-
3333
-
3334
3332
// =e
3335
3333
if (entity_is_task (prev )) {
3336
3334
prev_parent_se = prev -> real_parent ;
3337
- list_add_tail (& prev -> node , & prev_parent_se -> children );
3338
- prev_parent_se -> children_size ++ ;
3335
+ list_add_tail (& prev -> node , & prev_parent_se -> children [ this_cpu ] );
3336
+ prev_parent_se -> children_size [ this_cpu ] ++ ;
3339
3337
3340
3338
// =aghax
3341
3339
/*
3342
3340
* FIFO Measurement
3343
3341
*/
3344
- prev -> disorder_tag = prev_parent_se -> disorder_counter ++ ;
3342
+ prev -> disorder_tag [ this_cpu ] = prev_parent_se -> disorder_counter [ this_cpu ] ++ ;
3345
3343
//
3346
3344
}
3347
3345
//
@@ -4219,10 +4217,15 @@ static inline void hrtick_update(struct rq *rq)
4219
4217
4220
4218
static void print_fifo (struct sched_entity * se , struct sched_entity * cfs_selected ){
4221
4219
struct sched_entity * child ;
4220
+ int i ;
4222
4221
printk (KERN_INFO "====== printing childs of %d vruntime=%llu, cfs selected: %d ======\n" , task_of (se )-> pid , se -> vruntime , task_of (cfs_selected )-> pid );
4223
- list_for_each_entry (child , & se -> children , node ){
4224
- printk (KERN_INFO "child: %d vruntime=%llu\n" , task_of (child )-> pid , se -> vruntime );
4222
+ for_each_possible_cpu (i ){
4223
+ list_for_each_entry (child , & se -> children [i ], node ){
4224
+ printk (KERN_INFO "child: %d vruntime=%llu\n" , task_of (child )-> pid , se -> vruntime );
4225
+ }
4226
+ printk (KERN_INFO "====\n" );
4225
4227
}
4228
+
4226
4229
printk (KERN_INFO "=======================================================\n" );
4227
4230
}
4228
4231
@@ -4238,6 +4241,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
4238
4241
struct sched_entity * se = & p -> se ;
4239
4242
// =e
4240
4243
struct sched_entity * parent_se ;
4244
+ int cpu = rq -> cpu ;
4241
4245
//
4242
4246
4243
4247
for_each_sched_entity (se ) {
@@ -4250,14 +4254,14 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
4250
4254
parent_se = se -> real_parent ;
4251
4255
// printk(KERN_INFO "enqueue_task_fair: %d , %d %d %d\n", p->pid, parent_se != NULL, entity_is_task(se), se != cfs_rq->curr);
4252
4256
if (parent_se && se != cfs_rq -> curr ){
4253
- parent_se -> children_size ++ ;
4254
- list_add_tail (& se -> node , & parent_se -> children );
4257
+ parent_se -> children_size [ cpu ] ++ ;
4258
+ list_add_tail (& se -> node , & parent_se -> children [ cpu ] );
4255
4259
4256
4260
// =aghax
4257
4261
/*
4258
4262
* FIFO Measurement
4259
4263
*/
4260
- se -> disorder_tag = parent_se -> disorder_counter ++ ;
4264
+ se -> disorder_tag [ cpu ] = parent_se -> disorder_counter [ cpu ] ++ ;
4261
4265
//
4262
4266
}
4263
4267
}
@@ -4323,7 +4327,7 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags)
4323
4327
parent_se = se -> real_parent ;
4324
4328
if (parent_se && cfs_rq -> curr != se ){
4325
4329
list_del (& se -> node );
4326
- parent_se -> children_size -- ;
4330
+ parent_se -> children_size [ rq -> cpu ] -- ;
4327
4331
}
4328
4332
}
4329
4333
//
@@ -5371,6 +5375,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)
5371
5375
struct sched_entity * fifo_selected_se = NULL ;
5372
5376
struct sched_entity * parent_se ;
5373
5377
int flag = 0 ;
5378
+ int cpu = rq -> cpu ;
5374
5379
//
5375
5380
int new_tasks ;
5376
5381
@@ -5422,27 +5427,25 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)
5422
5427
5423
5428
5424
5429
// =e
5425
-
5426
5430
parent_se = se -> real_parent ;
5427
- if (parent_se && parent_se -> children_size ){
5431
+ if (parent_se && parent_se -> children_size [ cpu ] ){
5428
5432
flag = 1 ;
5429
5433
// print_fifo(parent_se, se);
5430
- fifo_selected_se = list_first_entry (& parent_se -> children , struct sched_entity , node );
5434
+ fifo_selected_se = list_first_entry (& parent_se -> children [ cpu ] , struct sched_entity , node );
5431
5435
if (fifo_selected_se && fifo_selected_se != se ){
5432
- //print_fifo(parent_se, se);
5433
- swap (fifo_selected_se -> vruntime , se -> vruntime );
5434
- se = fifo_selected_se ; // We shoud play with this line for switching between default and improved mode
5436
+ // swap(fifo_selected_se->vruntime, se->vruntime); // We shoud play with this line for switching between default and improved mode
5437
+ // se = fifo_selected_se; // We shoud play with this line for switching between default and improved mode
5435
5438
flag = 2 ;
5436
5439
}
5437
5440
5438
5441
// =aghax
5439
5442
/*
5440
5443
* FIFO Measurements
5441
5444
*/
5442
- if (se -> disorder_tag < parent_se -> last_disorder ) {
5443
- parent_se -> disorder_aggregate ++ ;
5445
+ if (se -> disorder_tag [ cpu ] < parent_se -> last_disorder [ cpu ] ) {
5446
+ parent_se -> disorder_aggregate [ cpu ] ++ ;
5444
5447
}
5445
- parent_se -> last_disorder = se -> disorder_tag ;
5448
+ parent_se -> last_disorder [ cpu ] = se -> disorder_tag [ cpu ] ;
5446
5449
//
5447
5450
}
5448
5451
//
@@ -5455,11 +5458,11 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)
5455
5458
*/
5456
5459
if (parent_se && print_counter < print_each )
5457
5460
{
5458
- printk (KERN_INFO "DISORDER AGGREGATE :-----> %llu\n"
5459
- ,parent_se -> disorder_aggregate );
5461
+ // printk(KERN_INFO "DISORDER AGGREGATE :-----> %llu\n"
5462
+ // ,parent_se->disorder_aggregate[cpu] );
5460
5463
}
5461
5464
5462
- if (print_counter >= 3 * print_each )
5465
+ if (print_counter >= threshold )
5463
5466
print_counter = 0 ;
5464
5467
5465
5468
print_counter ++ ;
@@ -5523,19 +5526,19 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)
5523
5526
*/
5524
5527
parent_se = se -> real_parent ;
5525
5528
if (parent_se ) {
5526
- if (se -> disorder_tag < parent_se -> last_disorder ) {
5527
- parent_se -> disorder_aggregate ++ ;
5529
+ if (se -> disorder_tag [ cpu ] < parent_se -> last_disorder [ cpu ] ) {
5530
+ parent_se -> disorder_aggregate [ cpu ] ++ ;
5528
5531
}
5529
- parent_se -> last_disorder = se -> disorder_tag ;
5532
+ parent_se -> last_disorder [ cpu ] = se -> disorder_tag [ cpu ] ;
5530
5533
}
5531
5534
5532
5535
if (parent_se && print_counter < print_each )
5533
5536
{
5534
- printk (KERN_INFO "DISORDER AGGREGATE :-----> %llu\t SCHED_TAG ----> "
5535
- "%llu\n" , parent_se -> disorder_aggregate , parent_se -> disorder_tag );
5537
+ printk (KERN_INFO "DISORDER AGGREGATE :-----> %llu\n "
5538
+ , parent_se -> disorder_aggregate [ cpu ] );
5536
5539
}
5537
5540
5538
- if (print_counter >= 10 * print_each )
5541
+ if (print_counter >= threshold )
5539
5542
print_counter = 0 ;
5540
5543
5541
5544
print_counter ++ ;
@@ -5562,7 +5565,7 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev)
5562
5565
/*
5563
5566
* FIFO Measurement
5564
5567
*/
5565
- if (print_counter >= 10 * print_each )
5568
+ if (print_counter >= threshold )
5566
5569
print_counter = 0 ;
5567
5570
5568
5571
print_counter ++ ;
0 commit comments